@@ -7,12 +7,13 @@ use std::fmt::{Display, Formatter};
77use std:: hash:: { Hash , Hasher } ;
88use std:: sync:: Arc ;
99
10- use vortex_dtype:: { DType , FieldPath } ;
10+ use vortex_dtype:: DType ;
1111use vortex_error:: { VortexExpect , VortexResult } ;
1212
13- use crate :: ArrayRef ;
1413use crate :: expr:: display:: DisplayTreeExpr ;
1514use crate :: expr:: { ChildName , ExprId , ExprVTable , ExpressionView , StatsCatalog , VTable } ;
15+ use crate :: stats:: Stat ;
16+ use crate :: ArrayRef ;
1617
1718/// A node in a Vortex expression tree.
1819///
@@ -158,39 +159,17 @@ impl Expression {
158159 ///
159160 /// Some expressions, in theory, have falsifications but this function does not support them
160161 /// such as `x < (y < z)` or `x LIKE "needle%"`.
161- pub fn stat_falsification ( & self , catalog : & mut dyn StatsCatalog ) -> Option < Expression > {
162+ pub fn stat_falsification ( & self , catalog : & dyn StatsCatalog ) -> Option < Expression > {
162163 self . vtable . as_dyn ( ) . stat_falsification ( self , catalog)
163164 }
164165
165- /// An expression for the upper non-null bound of this expression, if available.
166- ///
167- /// This function returns None if there is no upper bound, or it is difficult to compute.
168- ///
169- /// The returned expression evaluates to null if the maximum value is unknown. In that case, you
170- /// _must not_ assume the array is empty _nor_ may you assume the array only contains non-null
171- /// values.
172- pub fn stat_max ( & self , catalog : & mut dyn StatsCatalog ) -> Option < Expression > {
173- self . vtable . as_dyn ( ) . stat_max ( self , catalog)
174- }
175-
176- /// An expression for the lower non-null bound of this expression, if available.
166+ /// Returns an expression representing the zoned statistic for the given stat, if available.
177167 ///
178- /// See [`Expression::stat_max`] for important details.
179- pub fn stat_min ( & self , catalog : & mut dyn StatsCatalog ) -> Option < Expression > {
180- self . vtable . as_dyn ( ) . stat_min ( self , catalog)
181- }
182-
183- /// An expression for the NaN count for a column, if available.
184- ///
185- /// This method returns `None` if the NaNCount stat is unknown.
186- pub fn stat_nan_count ( & self , catalog : & mut dyn StatsCatalog ) -> Option < Expression > {
187- self . vtable . as_dyn ( ) . stat_nan_count ( self , catalog)
188- }
189-
190- // TODO(ngates): I'm not sure what this is really for? We need to clean up stats compute for
191- // expressions.
192- pub fn stat_field_path ( & self ) -> Option < FieldPath > {
193- self . vtable . as_dyn ( ) . stat_field_path ( self )
168+ /// The [`StatsCatalog`] returns expressions that can be evaluated using the zone map as a
169+ /// scope. Expressions can implement this function to propagate such statistics through the
170+ /// expression tree. For example, the `a + 10` expression could propagate `min: min(a) + 10`.
171+ pub fn stat_expression ( & self , stat : Stat , catalog : & dyn StatsCatalog ) -> Option < Expression > {
172+ self . vtable . as_dyn ( ) . stat_expression ( self , stat, catalog)
194173 }
195174
196175 /// Format the expression as a compact string.
0 commit comments