Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions vortex-array/src/expr/bound_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ use vortex_error::VortexExpect;
use vortex_error::VortexResult;
use vortex_error::vortex_ensure;
use vortex_session::VortexSession;
use vortex_session::registry::CachedId;

use crate::dtype::DType;
use crate::expr::Expression;
use crate::expr::ExpressionId;
use crate::expr::display::DisplayTreeExpr;
use crate::expr::scope::Scope;
use crate::expr::traversal::TraversalOrder;
Expand Down Expand Up @@ -106,6 +108,17 @@ impl Hash for ExactBoundExpr {
}

impl BoundExpression {
/// Return the globally unique ID of this expression node implementation.
pub fn id(&self) -> ExpressionId {
match self {
Self::Scalar { scalar_fn, .. } => scalar_fn.id(),
Self::Root { .. } => {
static ID: CachedId = CachedId::new("vortex.expr.root");
*ID
}
}
}

/// Create a bound root expression with the given dtype.
pub fn new_root(dtype: DType) -> Self {
Self::Root { dtype }
Expand Down
11 changes: 11 additions & 0 deletions vortex-array/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use std::hash::Hasher;
use std::sync::Arc;

use vortex_error::VortexExpect;
use vortex_session::registry::Id;
use vortex_utils::aliases::hash_set::HashSet;

use crate::dtype::FieldName;
Expand All @@ -63,6 +64,7 @@ mod exprs;
pub(crate) mod field;
pub mod forms;
mod optimize;
pub mod optimizer;
pub mod proto;
pub mod scope;
pub mod stats;
Expand Down Expand Up @@ -120,8 +122,17 @@ pub use exprs::select_exclude;
pub use exprs::union_child_validities;
pub use exprs::variant_get;
pub use exprs::zip_expr;
pub use optimizer::BoundExpressionOptimizer;
pub use optimizer::BoundExpressionRewriteRule;
pub use optimizer::BoundExpressionRewriteRuleRef;
pub use scope::*;

/// A globally unique identifier for an expression node implementation.
///
/// Scalar-function nodes reuse their scalar-function ID. Other expression node implementations,
/// such as higher-order functions and lambda nodes, use IDs from the same global namespace.
pub type ExpressionId = Id;

pub trait VortexExprExt {
/// Accumulate all field references from this expression and its children in a set
fn field_references(&self) -> HashSet<FieldName>;
Expand Down
Loading
Loading