Skip to content

Commit 7f5705a

Browse files
committed
Mooooaarrrrr generics
Signed-off-by: Nicholas Gates <[email protected]>
1 parent 14820af commit 7f5705a

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

vortex-array/src/expr/exprs/get_item.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ use vortex_proto::expr as pb;
1111

1212
use crate::compute::mask;
1313
use crate::expr::exprs::root::root;
14-
use crate::expr::{ChildName, ExprId, Expression, ExpressionView, StatsCatalog, VTable, VTableExt};
14+
use crate::expr::{
15+
ChildName, ExprId, Expression, ExpressionView, StatsCatalog, VTable, VTableExt, is_root,
16+
};
1517
use crate::stats::Stat;
1618
use crate::{ArrayRef, ToCanonical};
1719

@@ -105,9 +107,12 @@ impl VTable for GetItem {
105107
// matching the nested DType such that we can write:
106108
// `get_item(expr.child(0).stat_expression(...), expr.data().field_name())`
107109

108-
// TODO(ngates): For now, we maintain the existing *broken* behavior of assuming that
109-
// getitem refers to a field on the root scope.
110-
catalog.stats_ref(&FieldPath::from_name(expr.data().clone()), stat)
110+
// For now, we check that the child is the root expression.
111+
if is_root(expr.child(0)) {
112+
catalog.stats_ref(&FieldPath::from_name(expr.data().clone()), stat)
113+
} else {
114+
None
115+
}
111116
}
112117
}
113118

vortex-array/src/expr/exprs/literal.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ impl VTable for Literal {
7979
stat: Stat,
8080
_catalog: &dyn StatsCatalog,
8181
) -> Option<Expression> {
82+
// NOTE(ngates): we return incorrect `1` values for counts here since we don't have
83+
// row-count information. We could resolve this in the future by introducing a `count()`
84+
// expression that evaluates to the row count of the provided scope. But since this is
85+
// only currently used for pruning, it doesn't change the outcome.
86+
8287
match stat {
8388
Stat::Min | Stat::Max => Some(lit(expr.data().clone())),
8489
Stat::IsConstant => Some(lit(true)),
@@ -91,23 +96,19 @@ impl VTable for Literal {
9196
}
9297

9398
match_each_float_ptype!(value.ptype(), |T| {
94-
match value.typed_value::<T>() {
95-
None => Some(lit(0u64)),
96-
Some(value) if value.is_nan() => Some(lit(1u64)),
97-
_ => Some(lit(0u64)),
99+
if value.typed_value::<T>().is_some_and(|v| v.is_nan()) {
100+
Some(lit(1u64))
101+
} else {
102+
Some(lit(0u64))
98103
}
99104
})
100105
}
101106
Stat::NullCount => {
102-
if expr.data().is_valid() {
103-
return Some(lit(0u64));
107+
if expr.data().is_null() {
108+
Some(lit(1u64))
109+
} else {
110+
Some(lit(0u64))
104111
}
105-
// TODO(ngates): this is really annoying. Stats (at least those used for pruning)
106-
// should represent bounds over the value of a single row. By referencing a
107-
// "count" we have no way to return a stats expression that would allow is_null
108-
// pruning. In practice, this might not be that important since most functionality
109-
// should be absorbed by some form of constant folding.
110-
None
111112
}
112113
Stat::IsSorted | Stat::IsStrictSorted | Stat::Sum | Stat::UncompressedSizeInBytes => {
113114
None

0 commit comments

Comments
 (0)