Skip to content

Commit b691d5a

Browse files
committed
Move expressions out of vortex-array into vortex-expr
Unbound `Expression`, binding, traversal, lambdas, proto serialization and the expression constructors now live in `vortex-expr`; `vortex-array` keeps arrays, the scalar function machinery, the builtins it is built on, and `BoundExpression` with its reduce node and optimizer. The scalar function vtable reduces over bound expressions, so keeping them next to it lets every reduction rule stay monomorphized for expression trees as well as array trees. `vortex-expr` re-exports `BoundExpression`. The layering is `vortex-array -> vortex-expr -> vortex-functions`. - `ScalarFnVTable::simplify` is generic over `ReduceNode`, like `reduce`, but stays a separate hook that only the expression optimizer applies: a simplification may rewrite a node into one whose nullability differs, which the array optimizer cannot accept (it must keep the exact dtype and defer constant masks to the kernel rules). `ReduceNode::is_same` lets rules such as the COALESCE rewrite compare operands. - `new_expr`, `try_new_expr` and `try_new_bound_expr` move to `vortex_expr::ScalarFnExprExt`, `ArrayRef::apply`/`apply_bound` to `vortex_expr::ArrayExprExt`, and the expression half of the builtins to `vortex_expr::ExprBuiltins`. `ExprDisplay` moves to `vortex_array::scalar_fn::display`, and the tree renderer to `vortex_array::expr::display`. - `ArrayRef::take_slot_unchecked`/`put_slot_unchecked` become public, like `with_slots`, so row-count substitution in `vortex-expr` still rewrites lazy arrays in place. `vortex_array::expr` otherwise keeps only `stats`, which moves with the aggregate split. The core builtins' expression-level tests move to `vortex-expr`; the few array-level tests that used expressions now go through `ArrayBuiltins`. The `expr_*` benches move to `vortex-expr`, which joins the CodSpeed shard that builds `vortex-functions`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ps4mp7KF5c4p66aoSoXx5j Signed-off-by: Claude <noreply@anthropic.com>
1 parent b6e0486 commit b691d5a

187 files changed

Lines changed: 3994 additions & 3845 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.

‎.github/workflows/codspeed.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- { shard: 3, name: "Array dictionaries", packages: "vortex-array", array-group: "dictionary", features: "--features _test-harness" }
5757
- { shard: 4, name: "Array builders & views", packages: "vortex-array", array-group: "builders", features: "--features _test-harness" }
5858
- { shard: 5, name: "Core & encodings", packages: "vortex-buffer vortex-error vortex-mask vortex-compute vortex-file vortex-alp vortex-bytebool vortex-datetime-parts" }
59-
- { shard: 6, name: "Main library, functions & storage", packages: "vortex vortex-functions vortex-arrow vortex-btrblocks vortex-compressor vortex-row" }
59+
- { shard: 6, name: "Main library, functions & storage", packages: "vortex vortex-expr vortex-functions vortex-arrow vortex-btrblocks vortex-compressor vortex-row" }
6060
- { shard: 7, name: "FastLanes & decimals", packages: "vortex-decimal-byte-parts vortex-fastlanes", features: "--features _test-harness" }
6161
- { shard: 8, name: "Encodings & layout", packages: "vortex-onpair vortex-pco vortex-runend vortex-sequence vortex-sparse vortex-zigzag vortex-zstd vortex-layout" }
6262
- { shard: 9, name: "Strings, tensor & spatial", packages: "vortex-fsst vortex-tensor vortex-spatial", features: "--features _test-harness" }
@@ -92,7 +92,7 @@ jobs:
9292
groups = {
9393
"dictionary": ("dict_", "chunked_dict_", "patches_"),
9494
"selection": ("take_", "filter_", "piecewise_sequence_"),
95-
"compute": ("aggregate_", "cast_", "expr_", "binary_ops", "compare", "kleene_bool"),
95+
"compute": ("aggregate_", "cast_", "binary_ops", "compare", "kleene_bool"),
9696
}
9797
manifest = tomllib.loads(pathlib.Path("vortex-array/Cargo.toml").read_text())
9898
benches = []

‎AGENTS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ documentation in `docs/`, and benchmark tooling in `vortex-bench/` and `benchmar
2222
- `vortex-array` contains the core `Array` trait and the base encodings, including most
2323
Apache Arrow-style encodings.
2424
- `encodings/*` contains more specialized compressed encodings.
25+
- `vortex-expr` contains expression trees, their optimizer, and the analyses and rewrites built on
26+
them. `vortex-functions` contains the scalar functions that `vortex-array` itself is not built on.
2527
- `vortex-file` implements file IO. It uses `LayoutReader` from `vortex-layout`.
2628
- `vortex-io` holds the core async and blocking IO traits, plus the generic `object_store`
2729
adapters that implement them.

‎Cargo.lock‎

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

‎docs/concepts/expressions.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ to the returned data.
99
Expressions are defined as abstract scalar functions. These vtables define the signature of the function, properties
1010
such as whether the function is strict, and the actual logic for executing the function over input arrays.
1111

12-
The built-in scalar functions can be found in the `vortex-array::expr` module, with additional use-case specific
13-
functions provided by integration and plugin crates.
12+
The scalar function framework and the handful of functions the array crate itself is built on live in
13+
`vortex_array::scalar_fn`; expression trees, their optimizer and the analyses built on them live in the
14+
`vortex-expr` crate; `vortex-functions` holds the rest of the built-in scalar functions, with additional
15+
use-case specific functions provided by integration and plugin crates.
1416

1517
In the future, we plan to add full support for spatial functions, date-time functions, and more.
1618

‎encodings/fsst/Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ rand = { workspace = true, optional = true }
2222
vortex-array = { workspace = true }
2323
vortex-buffer = { workspace = true }
2424
vortex-error = { workspace = true }
25+
vortex-expr = { workspace = true }
2526
vortex-functions = { workspace = true }
2627
vortex-mask = { workspace = true }
2728
vortex-session = { workspace = true }
@@ -36,6 +37,7 @@ rand = { workspace = true }
3637
rstest = { workspace = true }
3738
test-with = { workspace = true }
3839
vortex-array = { workspace = true, features = ["_test-harness"] }
40+
vortex-expr = { workspace = true }
3941

4042
[[bench]]
4143
name = "fsst_compress"

‎encodings/fsst/benches/fsst_url_compare.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ use vortex_array::arrays::VarBinArray;
1616
use vortex_array::arrays::VarBinViewArray;
1717
use vortex_array::arrays::varbin::VarBinArrayExt;
1818
use vortex_array::builtins::ArrayBuiltins;
19-
use vortex_array::expr::lit;
20-
use vortex_array::expr::root;
2119
use vortex_array::memory::MemorySession;
2220
use vortex_array::optimizer::kernels::KernelSession;
2321
use vortex_array::scalar::Scalar;
2422
use vortex_array::scalar_fn::builtin::operators::Operator;
2523
use vortex_array::session::ArraySession;
24+
use vortex_expr::ArrayExprExt;
25+
use vortex_expr::lit;
26+
use vortex_expr::root;
2627
use vortex_fsst::fsst_compress;
2728
use vortex_fsst::fsst_train_compressor;
2829
use vortex_fsst::test_utils::HIGH_MATCH_DOMAIN;

‎encodings/fsst/src/kernel.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ mod tests {
4444
use vortex_array::assert_arrays_eq;
4545
use vortex_array::dtype::DType;
4646
use vortex_array::dtype::Nullability;
47-
use vortex_array::expr::root;
4847
use vortex_error::VortexResult;
48+
use vortex_expr::ArrayExprExt;
49+
use vortex_expr::root;
4950
use vortex_functions::expr::byte_length;
5051
use vortex_mask::Mask;
5152
use vortex_session::VortexSession;

‎encodings/parquet-variant/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ vortex-edition = { workspace = true }
3737
rstest = { workspace = true }
3838
tokio = { workspace = true, features = ["full"] }
3939
vortex-array = { workspace = true, features = ["_test-harness"] }
40+
vortex-expr = { workspace = true }
4041
vortex-file = { workspace = true, features = ["tokio"] }
4142
vortex-io = { workspace = true, features = ["tokio"] }
4243
vortex-layout = { workspace = true }

‎encodings/parquet-variant/src/json_to_variant_tests.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ use vortex_array::assert_nth_scalar_is_null;
2626
use vortex_array::dtype::DType;
2727
use vortex_array::dtype::Nullability;
2828
use vortex_array::dtype::PType;
29-
use vortex_array::expr::root;
3029
use vortex_error::VortexResult;
3130
use vortex_error::vortex_bail;
3231
use vortex_error::vortex_err;
32+
use vortex_expr::ArrayExprExt;
33+
use vortex_expr::root;
3334
use vortex_functions::expr::variant_get;
3435
use vortex_functions::variant_get::VariantPath;
3536
use vortex_json::Json;

‎encodings/parquet-variant/src/kernel.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,14 @@ mod tests {
325325
use vortex_array::dtype::DType as VortexDType;
326326
use vortex_array::dtype::Nullability;
327327
use vortex_array::dtype::PType;
328-
use vortex_array::expr::root;
329328
use vortex_array::validity::Validity;
330329
use vortex_arrow::ArrowSessionExt;
331330
use vortex_error::VortexResult;
332331
use vortex_error::vortex_bail;
333332
use vortex_error::vortex_ensure;
334333
use vortex_error::vortex_err;
334+
use vortex_expr::ArrayExprExt;
335+
use vortex_expr::root;
335336
use vortex_functions::expr::variant_get;
336337
use vortex_functions::variant_get::VariantPath;
337338
use vortex_functions::variant_get::VariantPathElement;

0 commit comments

Comments
 (0)