Skip to content

Commit b3ec563

Browse files
feat[vortex-expr]: remove pruning expr in favor of checked_pruning_expr. (#3501)
This allows the creation of pruning expression with only some stats available, this also verifies that the stats exist before the predicate creation --------- Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent a66614d commit b3ec563

File tree

10 files changed

+285
-169
lines changed

10 files changed

+285
-169
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vortex-dtype/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ static_assertions = { workspace = true }
2828
vortex-error = { workspace = true, features = ["flatbuffers"] }
2929
vortex-flatbuffers = { workspace = true, features = ["dtype"] }
3030
vortex-proto = { workspace = true, features = ["dtype"] }
31+
vortex-utils = { workspace = true }
3132

3233
[dev-dependencies]
3334
serde_json = { workspace = true }

vortex-dtype/src/field.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::sync::Arc;
1010

1111
use itertools::Itertools;
1212
use vortex_error::{VortexResult, vortex_bail};
13+
use vortex_utils::aliases::hash_set::HashSet;
1314

1415
use crate::DType;
1516

@@ -208,6 +209,28 @@ impl Display for FieldPath {
208209
}
209210
}
210211

212+
#[derive(Default, Clone, Debug)]
213+
/// Contains a set of field paths, and can answer efficient field path contains queries.
214+
pub struct FieldPathSet {
215+
/// While this is currently a set wrapper it can be replaced with a trie.
216+
// TODO(joe): this can be replaced with a `FieldPath` trie
217+
set: HashSet<FieldPath>,
218+
}
219+
220+
impl FieldPathSet {
221+
/// Checks if a set contains a field path
222+
pub fn contains(&self, path: &FieldPath) -> bool {
223+
self.set.contains(path)
224+
}
225+
}
226+
227+
impl FromIterator<FieldPath> for FieldPathSet {
228+
fn from_iter<T: IntoIterator<Item = FieldPath>>(iter: T) -> Self {
229+
let set = HashSet::from_iter(iter);
230+
Self { set }
231+
}
232+
}
233+
211234
#[cfg(test)]
212235
mod tests {
213236
use super::*;

vortex-expr/src/let_.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl VortexExpr for Let {
8181

8282
fn unchecked_evaluate(&self, scope: &Scope) -> VortexResult<ArrayRef> {
8383
let v = self.bind.unchecked_evaluate(scope)?;
84-
let ctx_p = scope.copy_with_value(self.var.clone(), v);
84+
let ctx_p = scope.copy_with_array(self.var.clone(), v);
8585
self.expr.unchecked_evaluate(&ctx_p)
8686
}
8787

@@ -98,7 +98,7 @@ impl VortexExpr for Let {
9898

9999
fn return_dtype(&self, scope: &ScopeDType) -> VortexResult<DType> {
100100
let v = self.bind.return_dtype(scope)?;
101-
let ctx_p = scope.copy_with_value(self.var.clone(), v);
101+
let ctx_p = scope.copy_with_dtype(self.var.clone(), v);
102102
self.expr.return_dtype(&ctx_p)
103103
}
104104
}

vortex-expr/src/pruning/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
mod pruning_predicate;
1+
mod pruning_expr;
22
mod relation;
33

4-
pub use pruning_predicate::{PruningPredicate, access_path_stat_field_name};
4+
pub use pruning_expr::{
5+
RequiredStats, checked_pruning_expr, field_path_stat_field_name, pruning_expr,
6+
};

0 commit comments

Comments
 (0)