@@ -17,9 +17,9 @@ use vortex_error::vortex_ensure;
1717
1818use crate :: ArrayRef ;
1919use crate :: expr:: Root ;
20+ use crate :: expr:: ScalarFn ;
2021use crate :: expr:: StatsCatalog ;
2122use crate :: expr:: VTable ;
22- use crate :: expr:: bound:: BoundExpression ;
2323use crate :: expr:: display:: DisplayTreeExpr ;
2424use crate :: expr:: stats:: Stat ;
2525
@@ -29,36 +29,39 @@ use crate::expr::stats::Stat;
2929/// expression consists of an encoding (vtable), heap-allocated metadata, and child expressions.
3030#[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
3131pub struct Expression {
32- /// The bound expression for this node.
33- bound : BoundExpression ,
32+ /// The scalar fn for this node.
33+ scalar_fn : ScalarFn ,
3434 /// Any children of this expression.
3535 children : Arc < [ Expression ] > ,
3636}
3737
3838impl Deref for Expression {
39- type Target = BoundExpression ;
39+ type Target = ScalarFn ;
4040
4141 fn deref ( & self ) -> & Self :: Target {
42- & self . bound
42+ & self . scalar_fn
4343 }
4444}
4545
4646impl Expression {
47- /// Create a new expression node from a bound expression and its children.
47+ /// Create a new expression node from a scalar_fn expression and its children.
4848 pub fn try_new (
49- bound : BoundExpression ,
49+ scalar_fn : ScalarFn ,
5050 children : impl Into < Arc < [ Expression ] > > ,
5151 ) -> VortexResult < Self > {
5252 let children: Arc < [ Expression ] > = children. into ( ) ;
5353
5454 vortex_ensure ! (
55- bound . signature( ) . arity( ) . matches( children. len( ) ) ,
55+ scalar_fn . signature( ) . arity( ) . matches( children. len( ) ) ,
5656 "Expression arity mismatch: expected {} children but got {}" ,
57- bound . signature( ) . arity( ) ,
57+ scalar_fn . signature( ) . arity( ) ,
5858 children. len( )
5959 ) ;
6060
61- Ok ( Self { bound, children } )
61+ Ok ( Self {
62+ scalar_fn,
63+ children,
64+ } )
6265 }
6366
6467 /// Returns true if this expression is of the given vtable type.
@@ -77,6 +80,11 @@ impl Expression {
7780 . vortex_expect ( "Expression options type mismatch" )
7881 }
7982
83+ /// Returns the scalar fn vtable for this expression.
84+ pub fn scalar_fn ( & self ) -> & ScalarFn {
85+ & self . scalar_fn
86+ }
87+
8088 /// Returns the children of this expression.
8189 pub fn children ( & self ) -> & Arc < [ Expression ] > {
8290 & self . children
@@ -111,15 +119,15 @@ impl Expression {
111119 . iter ( )
112120 . map ( |c| c. return_dtype ( scope) )
113121 . try_collect ( ) ?;
114- self . bound . return_dtype ( & dtypes)
122+ self . scalar_fn . return_dtype ( & dtypes)
115123 }
116124
117125 /// Evaluates the expression in the given scope, returning an array.
118126 pub fn evaluate ( & self , scope : & ArrayRef ) -> VortexResult < ArrayRef > {
119127 if self . is :: < Root > ( ) {
120128 return Ok ( scope. clone ( ) ) ;
121129 }
122- self . bound . evaluate ( self , scope)
130+ self . scalar_fn . evaluate ( self , scope)
123131 }
124132
125133 /// An expression over zone-statistics which implies all records in the zone evaluate to false.
0 commit comments