Skip to content

Commit d02df89

Browse files
robert3005claude
andauthored
Move expression analysis, rewrites and statistics pruning into vortex-expr (#10734)
Expression analysis, the rewrite transforms and statistics pruning are only used by scan planning (vortex-layout, vortex-file, vortex-spatial and one `replace` call in vortex-datafusion); nothing in vortex-array's arrays or execution calls them. They move to a new `vortex-expr` crate: - `vortex_expr::analysis` (annotations, labeling, field-access analysis, `referenced_field_paths`), also re-exported at the crate root as before - `vortex_expr::forms::conjuncts` - `vortex_expr::transform::{partition_bound, partition_bound_annotations, BoundPartitionedExpr, replace, find_between}` - `vortex_expr::stats`: the stat-expression helpers, `StatBinder`, the falsify/satisfy rewrite rules and `StatsSession`, which turn filter predicates into pruning predicates for zone maps and file stats vortex-array keeps the statistics themselves (`StatsSet`, `ArrayStats`, `Stat`, `Precision`) and the `StatFn` scalar function. `vortex_array::expr::transform` is removed; `find_between` is no longer part of `BoundExpression::optimize`. - `BoundExpression::{falsify, satisfy}` were inherent methods; they become the `BoundExpressionPruneExt` extension trait. - `LikeVariant`, which only the LIKE pruning rule uses, moves with it. - `DynamicComparisonExpr` gains `operator()`, `default()` and `with_operator()`, since the pruning rules can no longer reach its fields. - The falsification tests for `is_null`, `is_not_null` and `list_contains` move to `vortex_expr::stats::rewrite`, and the one optimizer test that used `replace` builds the replaced expression directly. --------- Signed-off-by: Claude <noreply@anthropic.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent c750fbd commit d02df89

172 files changed

Lines changed: 1036 additions & 1624 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Cargo.lock‎

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

‎Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ members = [
1313
"vortex-io",
1414
"vortex-cloud",
1515
"vortex-array",
16+
"vortex-expr",
1617
"vortex-arrow",
1718
"vortex-row",
1819
"vortex-tensor",
@@ -319,6 +320,7 @@ vortex-datetime-parts = { version = "0.1.0", path = "./encodings/datetime-parts"
319320
vortex-decimal-byte-parts = { version = "0.1.0", path = "encodings/decimal-byte-parts", default-features = false }
320321
vortex-edition = { version = "0.1.0", path = "./vortex-edition", default-features = false }
321322
vortex-error = { version = "0.1.0", path = "./vortex-error", default-features = false }
323+
vortex-expr = { version = "0.1.0", path = "./vortex-expr", default-features = false }
322324
vortex-fastlanes = { version = "0.1.0", path = "./encodings/fastlanes", default-features = false }
323325
vortex-file = { version = "0.1.0", path = "./vortex-file", default-features = false }
324326
vortex-fsst = { version = "0.1.0", path = "./encodings/fsst", default-features = false }

‎docs/developer-guide/internals/stats-pruning.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ the proof was unknown, usually because a required stat was missing or inexact.
1010

1111
The pruning pipeline has two phases:
1212

13-
1. `Expression::falsify(scope, session)` asks the session's
14-
`StatsRewriteRule`s to rewrite a filter into an abstract proof expression.
13+
1. `BoundExpressionPruneExt::falsify(session)`, from `vortex_expr::stats::rewrite`, asks the
14+
session's `StatsRewriteRule`s to rewrite a bound filter into an abstract proof expression.
1515
Rules describe semantics in terms of `vortex.stat(input, aggregate_fn)`
1616
placeholders. These placeholders name the statistic needed by the proof, but
1717
not where that statistic is stored.

‎encodings/alp/benches/alp_compress.rs‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ use vortex_array::VortexSessionExecute;
2222
use vortex_array::aggregate_fn::session::AggregateFnSession;
2323
use vortex_array::arrays::PrimitiveArray;
2424
use vortex_array::dtype::NativePType;
25-
use vortex_array::dtype::session::DTypeSession;
2625
use vortex_array::memory::MemorySession;
2726
use vortex_array::optimizer::kernels::KernelSession;
28-
use vortex_array::scalar_fn::session::ScalarFnSession;
2927
use vortex_array::session::ArraySession;
30-
use vortex_array::stats::session::StatsSession;
3128
use vortex_array::validity::Validity;
3229
use vortex_buffer::Buffer;
3330
use vortex_buffer::buffer;
@@ -67,11 +64,8 @@ static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
6764
let session = VortexSession::empty()
6865
.with::<ArraySession>()
6966
.with::<KernelSession>()
70-
.with::<DTypeSession>()
71-
.with::<ScalarFnSession>()
7267
.with::<AggregateFnSession>()
73-
.with::<MemorySession>()
74-
.with::<StatsSession>();
68+
.with::<MemorySession>();
7569
vortex_alp::initialize(&session);
7670
session
7771
});

‎encodings/datetime-parts/benches/split_temporal.rs‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@ use rand::SeedableRng as _;
1212
use rand::rngs::StdRng;
1313
use vortex_array::IntoArray;
1414
use vortex_array::VortexSessionExecute;
15-
use vortex_array::aggregate_fn::session::AggregateFnSession;
1615
use vortex_array::arrays::PrimitiveArray;
1716
use vortex_array::arrays::TemporalArray;
18-
use vortex_array::dtype::session::DTypeSession;
1917
use vortex_array::extension::datetime::TimeUnit;
20-
use vortex_array::memory::MemorySession;
2118
use vortex_array::optimizer::kernels::KernelSession;
22-
use vortex_array::scalar_fn::session::ScalarFnSession;
23-
use vortex_array::session::ArraySession;
24-
use vortex_array::stats::session::StatsSession;
2519
use vortex_array::validity::Validity;
2620
use vortex_buffer::Buffer;
2721
use vortex_datetime_parts::split_temporal;
@@ -35,16 +29,8 @@ fn main() {
3529
divan::main();
3630
}
3731

38-
static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
39-
VortexSession::empty()
40-
.with::<ArraySession>()
41-
.with::<KernelSession>()
42-
.with::<DTypeSession>()
43-
.with::<ScalarFnSession>()
44-
.with::<AggregateFnSession>()
45-
.with::<MemorySession>()
46-
.with::<StatsSession>()
47-
});
32+
static SESSION: LazyLock<VortexSession> =
33+
LazyLock::new(|| VortexSession::empty().with::<KernelSession>());
4834

4935
const BENCH_ARGS: &[(usize, TimeUnit)] = &[
5036
(65_536, TimeUnit::Seconds),

‎encodings/decimal-byte-parts/benches/dbp_assemble.rs‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,9 @@ mod arrays {
111111
use vortex_array::ArrayRef;
112112
use vortex_array::IntoArray;
113113
use vortex_array::VortexSessionExecute;
114-
use vortex_array::aggregate_fn::session::AggregateFnSession;
115114
use vortex_array::dtype::DecimalDType;
116115
use vortex_array::dtype::DecimalType;
117-
use vortex_array::dtype::session::DTypeSession;
118-
use vortex_array::memory::MemorySession;
119116
use vortex_array::optimizer::kernels::KernelSession;
120-
use vortex_array::scalar_fn::session::ScalarFnSession;
121-
use vortex_array::session::ArraySession;
122-
use vortex_array::stats::session::StatsSession;
123117
use vortex_array::validity::Validity;
124118
use vortex_buffer::buffer;
125119
use vortex_decimal_byte_parts::_benchmarking::assemble_decimal;
@@ -131,16 +125,8 @@ mod arrays {
131125
use crate::common::arrays::cases;
132126
use crate::common::arrays::decimal_array;
133127

134-
pub(super) static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
135-
VortexSession::empty()
136-
.with::<ArraySession>()
137-
.with::<KernelSession>()
138-
.with::<DTypeSession>()
139-
.with::<ScalarFnSession>()
140-
.with::<AggregateFnSession>()
141-
.with::<MemorySession>()
142-
.with::<StatsSession>()
143-
});
128+
pub(super) static SESSION: LazyLock<VortexSession> =
129+
LazyLock::new(|| VortexSession::empty().with::<KernelSession>());
144130

145131
#[divan::bench(args = cases())]
146132
fn dbp_assemble(bencher: Bencher, (values_type, len): (DecimalType, usize)) {

‎encodings/decimal-byte-parts/benches/dbp_split.rs‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,8 @@ mod arrays {
8484
use rand::SeedableRng;
8585
use rand::rngs::StdRng;
8686
use vortex_array::VortexSessionExecute;
87-
use vortex_array::aggregate_fn::session::AggregateFnSession;
8887
use vortex_array::dtype::DecimalType;
89-
use vortex_array::dtype::session::DTypeSession;
90-
use vortex_array::memory::MemorySession;
9188
use vortex_array::optimizer::kernels::KernelSession;
92-
use vortex_array::scalar_fn::session::ScalarFnSession;
93-
use vortex_array::session::ArraySession;
94-
use vortex_array::stats::session::StatsSession;
9589
use vortex_array::validity::Validity;
9690
use vortex_decimal_byte_parts::split_decimal;
9791
use vortex_error::VortexExpect;
@@ -100,16 +94,8 @@ mod arrays {
10094
use crate::common::arrays::cases;
10195
use crate::common::arrays::decimal_array;
10296

103-
pub(super) static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
104-
VortexSession::empty()
105-
.with::<ArraySession>()
106-
.with::<KernelSession>()
107-
.with::<DTypeSession>()
108-
.with::<ScalarFnSession>()
109-
.with::<AggregateFnSession>()
110-
.with::<MemorySession>()
111-
.with::<StatsSession>()
112-
});
97+
pub(super) static SESSION: LazyLock<VortexSession> =
98+
LazyLock::new(|| VortexSession::empty().with::<KernelSession>());
11399

114100
#[divan::bench(args = cases())]
115101
fn dbp_split_all_valid(bencher: Bencher, (values_type, len): (DecimalType, usize)) {

‎encodings/fastlanes/benches/bitpack_blocked.rs‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@ use mimalloc::MiMalloc;
1313
use vortex_array::VortexSessionExecute;
1414
use vortex_array::aggregate_fn::session::AggregateFnSession;
1515
use vortex_array::arrays::PrimitiveArray;
16-
use vortex_array::dtype::session::DTypeSession;
17-
use vortex_array::memory::MemorySession;
1816
use vortex_array::optimizer::kernels::KernelSession;
19-
use vortex_array::scalar_fn::session::ScalarFnSession;
2017
use vortex_array::session::ArraySession;
21-
use vortex_array::stats::session::StatsSession;
2218
use vortex_fastlanes::bitpack_compress::bitpack_encode_blocked;
2319
use vortex_session::VortexSession;
2420

@@ -34,11 +30,7 @@ static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
3430
let session = VortexSession::empty()
3531
.with::<ArraySession>()
3632
.with::<KernelSession>()
37-
.with::<DTypeSession>()
38-
.with::<ScalarFnSession>()
39-
.with::<AggregateFnSession>()
40-
.with::<MemorySession>()
41-
.with::<StatsSession>();
33+
.with::<AggregateFnSession>();
4234
vortex_fastlanes::initialize(&session);
4335
session
4436
});

‎encodings/fastlanes/benches/bitpack_blocked_decompress.rs‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@ use vortex_array::VortexSessionExecute;
1515
use vortex_array::aggregate_fn::session::AggregateFnSession;
1616
use vortex_array::arrays::PrimitiveArray;
1717
use vortex_array::dtype::NativePType;
18-
use vortex_array::dtype::session::DTypeSession;
1918
use vortex_array::memory::MemorySession;
2019
use vortex_array::optimizer::kernels::KernelSession;
21-
use vortex_array::scalar_fn::session::ScalarFnSession;
2220
use vortex_array::session::ArraySession;
23-
use vortex_array::stats::session::StatsSession;
2421
use vortex_fastlanes::BitPackedArraySlotsExt;
2522
use vortex_fastlanes::bitpack_compress::bitpack_encode_blocked;
2623
use vortex_fastlanes::bitpack_decompress::unpack_array_blocked;
@@ -38,11 +35,8 @@ static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
3835
let session = VortexSession::empty()
3936
.with::<ArraySession>()
4037
.with::<KernelSession>()
41-
.with::<DTypeSession>()
42-
.with::<ScalarFnSession>()
4338
.with::<AggregateFnSession>()
44-
.with::<MemorySession>()
45-
.with::<StatsSession>();
39+
.with::<MemorySession>();
4640
vortex_fastlanes::initialize(&session);
4741
session
4842
});

‎encodings/fastlanes/benches/bitpack_compare.rs‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ use vortex_array::arrays::BoolArray;
2424
use vortex_array::arrays::ConstantArray;
2525
use vortex_array::arrays::PrimitiveArray;
2626
use vortex_array::builtins::ArrayBuiltins;
27-
use vortex_array::dtype::session::DTypeSession;
2827
use vortex_array::memory::MemorySession;
2928
use vortex_array::optimizer::kernels::KernelSession;
3029
use vortex_array::scalar_fn::fns::operators::Operator;
31-
use vortex_array::scalar_fn::session::ScalarFnSession;
3230
use vortex_array::session::ArraySession;
33-
use vortex_array::stats::session::StatsSession;
3431
use vortex_array::validity::Validity;
3532
use vortex_buffer::Alignment;
3633
use vortex_buffer::BufferMut;
@@ -52,11 +49,8 @@ static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
5249
let session = VortexSession::empty()
5350
.with::<ArraySession>()
5451
.with::<KernelSession>()
55-
.with::<DTypeSession>()
56-
.with::<ScalarFnSession>()
5752
.with::<AggregateFnSession>()
58-
.with::<MemorySession>()
59-
.with::<StatsSession>();
53+
.with::<MemorySession>();
6054
vortex_fastlanes::initialize(&session);
6155
session
6256
});

0 commit comments

Comments
 (0)