Skip to content

Move remaining expressions out of vortex-array to vortex-expr - #10768

Draft
robert3005 wants to merge 7 commits into
developfrom
rk/split-array-07-expr
Draft

robert3005 wants to merge 7 commits into
developfrom
rk/split-array-07-expr

Conversation

@robert3005

@robert3005 robert3005 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

after #10762 we can further split expressions into vortex-expr. We flip dependency order into vortex-array → vortex-expr → vortex-functions. we need #11817 first then this is a clean move

@robert3005 robert3005 added the changelog/break A breaking API change label Oct 24, 2026
@github-actions
github-actions Bot temporarily deployed to docs-preview/pr-10768 October 24, 2026 12:42 Inactive
@robert3005
robert3005 force-pushed the rk/split-array-07-expr branch from d195163 to b691d5a Compare October 24, 2026 12:54
@codspeed

codspeed Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 1.54%

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚡ 2 improved benchmarks
❌ 3 regressed benchmarks
✅ 2063 untouched benchmarks
🆕 3 new benchmarks
⏩ 90 skipped benchmarks1
🗄️ 2 archived benchmarks run2

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation compare[1] 48 µs 57.9 µs -17.14%
❌ CPU Simulation take_map[(0.1, 1.0)] 229.2 µs 261.6 µs -12.39%
❌ CPU Simulation take_map[(0.1, 0.5)] 149.6 µs 167.6 µs -10.76%
⚡ CPU Simulation i64_bitmap_span_2_20[4] 94.5 µs 78.8 µs +19.89%
⚡ CPU Simulation compare[1] 62.6 µs 52.6 µs +19.1%
🆕 CPU Simulation pack_return_dtype[200] N/A 340.8 µs N/A
🆕 CPU Simulation pack_return_dtype[350] N/A 600.5 µs N/A
🆕 CPU Simulation optimize_or_chain[200] N/A 666.3 µs N/A

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing rk/split-array-07-expr (fbfa998) with develop (1990852)

Open in CodSpeed

Footnotes

  1. 90 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. 2 benchmarks were run, but are now archived. If they were deleted in another branch, consider rebasing to remove them from the report. Instead if they were added back, click here to restore them. ↩

@github-actions
github-actions Bot temporarily deployed to docs-preview/pr-10768 October 24, 2026 13:02 Inactive
@robert3005
robert3005 force-pushed the rk/split-array-06-scalar-fns branch 2 times, most recently from 06bffcd to 137c718 Compare October 25, 2026 05:26
@robert3005
robert3005 force-pushed the rk/split-array-07-expr branch from b691d5a to e57d7c2 Compare October 25, 2026 06:49
@github-actions
github-actions Bot temporarily deployed to docs-preview/pr-10768 October 25, 2026 06:58 Inactive
@robert3005
robert3005 marked this pull request as draft October 26, 2026 09:48
@robert3005
robert3005 force-pushed the rk/split-array-06-scalar-fns branch from 137c718 to 0713434 Compare October 26, 2026 10:44
@robert3005
robert3005 force-pushed the rk/split-array-07-expr branch from e57d7c2 to d8a74d2 Compare October 26, 2026 10:44
@github-actions
github-actions Bot temporarily deployed to docs-preview/pr-10768 October 26, 2026 10:54 Inactive
@robert3005
robert3005 force-pushed the rk/split-array-06-scalar-fns branch from 0713434 to e33c436 Compare October 26, 2026 11:25
@robert3005
robert3005 force-pushed the rk/split-array-07-expr branch from d8a74d2 to 123df13 Compare October 26, 2026 11:25
@github-actions
github-actions Bot temporarily deployed to docs-preview/pr-10768 October 26, 2026 11:34 Inactive
@robert3005
robert3005 force-pushed the rk/split-array-06-scalar-fns branch 4 times, most recently from 595165d to 7644dd2 Compare November 9, 2026 03:32
@robert3005
robert3005 force-pushed the rk/split-array-07-expr branch from 123df13 to 49d5a26 Compare November 9, 2026 04:06
@robert3005
robert3005 force-pushed the rk/split-array-06-scalar-fns branch from 7644dd2 to 6814544 Compare November 9, 2026 12:05
@robert3005
robert3005 force-pushed the rk/split-array-07-expr branch from 49d5a26 to 2e0ca58 Compare November 9, 2026 12:30
@robert3005
robert3005 force-pushed the rk/split-array-06-scalar-fns branch from 6814544 to 1173f1a Compare November 9, 2026 12:45
@robert3005
robert3005 force-pushed the rk/split-array-07-expr branch from 2e0ca58 to 7ffa022 Compare November 9, 2026 12:47
@robert3005
robert3005 force-pushed the rk/split-array-06-scalar-fns branch from 1173f1a to dcaa482 Compare November 9, 2026 19:33
@robert3005
robert3005 force-pushed the rk/split-array-07-expr branch from ba6a3ba to 7c10fd1 Compare November 9, 2026 20:17
@robert3005
robert3005 force-pushed the rk/split-array-06-scalar-fns branch from dcaa482 to 9383bb2 Compare November 10, 2026 12:55
@robert3005
robert3005 force-pushed the rk/split-array-07-expr branch from 7c10fd1 to 2d59169 Compare November 10, 2026 15:20
@lwwmanning

Copy link
Copy Markdown
Contributor

Posted by Claude Opus 5.5 on Will's behalf.

@devin-ai-integration, this PR conflicts with its base, #10762, since you merged develop into #10762. Please redo the move on the current head of #10762 rather than resolving the old conflicts one by one, and keep the PR stacked on it. The open thread about lower.rs is out of scope for this PR; Will will resolve it.

@lwwmanning
lwwmanning marked this pull request as ready for review November 23, 2026 00:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T01:31:42.566040Z 43e56a4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Base automatically changed from rk/split-array-06-scalar-fns to develop November 23, 2026 00:11
lwwmanning added a commit that referenced this pull request Nov 23, 2026
Splits non-core scalar functions out of `vortex-array` into a separate
`vortex-functions` crate to reduce `vortex-array`'s footprint and
compile surface as part of breaking up `vortex-array` (followed up by
#10768 and #10769).

`vortex-array` keeps the scalar function machinery (the `ScalarFnVTable`
trait, binding, reduction, execution, the session registry and kernel
registry) and the few functions its own arrays, validity and expressions
are built on: literal, get_item, pack and select, is_null, is_not_null,
not and the binary operators, and cast, mask and fill_null, which
canonical arrays apply to their own children. That module is renamed
from `scalar_fn::fns` to `scalar_fn::builtin`, matching `ArrayBuiltins`.
Every other scalar function moves to the new `vortex-functions` crate:

- byte_length, case_when, ext_storage, list_length, list_sum,
list_transform, lower, lower_bound, merge, replace_time_zone, strpos,
dynamic, dynamic_expression, stat, between, like, list_contains,
variant_get, is_nan and zip, with their expression constructors in
`vortex_functions::expr` (and `expr::bound`)
- their kernels and parent-reduce rules for vortex-array's encodings
(including `Widen`'s and the zip-backed nested `fill_null` kernels for
struct, list, fixed-size list, and map arrays), which
`vortex_functions::initialize` registers with the session's kernel
registry
- the `ArrayBuiltins`/`ExprBuiltins` methods for the moved functions,
which become the `ArrayFunctions`/`ExprFunctions` extension traits

`ArrayHaystack`, `LazyBitBufferBuilder`,
`DeduplicatedBuffers::{extend_from_iter, finish}`,
`ListScalar::element_values`, `is_not_null_node`,
`build_row_comparator`, `merge_typed_scalar_as_variant`,
`FillNull::{supports_dtype, short_circuit}`, and the `Widen` compute
helpers become public for the moved kernels; `ForeignExtDType` is public
under `_test-harness` for the moved tests.

Breaking change: callers that construct a `VortexSession` by hand
(instead of using `VortexSession::default()`) lose the moved scalar
functions, their kernels, and nested `fill_null` support for
struct/list/fixed-size-list/map arrays unless they call
`vortex_functions::initialize`.

---------

Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
Signed-off-by: Robert Kruszewski <github@robertk.io>
Signed-off-by: Will Manning <will@spiraldb.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Will Manning <will@spiraldb.com>
devin-ai-integration[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

vortex_expr::initialize(session);
vortex_functions::initialize(session);

P2 Badge Keep scalar-function registration out of the encoding helper

When a caller installs a custom scalar-function implementation under a standard ID and then calls register_default_encodings, these initializers silently replace that implementation because ScalarFnSession::register overwrites an existing same-ID vtable. This helper is documented as configuring file encodings, so expression/function initialization should remain in the top-level session setup rather than unexpectedly mutating an independent registry.

AGENTS.md reference: AGENTS.md:L25-L27


use vortex_functions::variant_get::VariantGet;

P2 Badge Register the moved VariantGet vtable during Parquet initialization

When a standalone user calls only vortex_parquet_variant::initialize and then deserializes a persisted variant_get expression, the session no longer contains the VariantGet vtable: it moved to vortex-functions, while the Parquet initializer still registers only its execution kernel. Expression::from_proto therefore reconstructs a non-executable foreign function instead, despite vortex_parquet_variant::initialize being documented as registering scalar-function support; initialize or directly register the moved dependency there.

AGENTS.md reference: AGENTS.md:L24-L26

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Only fuse range comparisons into Between during scan preparation when
the session has a stats rewrite registered for Between, preserving
zone-map pruning on minimal sessions that have not called
vortex_functions::initialize.

Also restore the empty-constant-chunk is_null regression test in
vortex-functions and update the vortex-functions crate doc for select.

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Re #10768 (comment) (both items were reviewed against the pre-rebase commit 10443fb):

  1. vortex-file::register_default_encodings no longer registers scalar functions after rebasing onto develop (post-Move scalar functions out of vortex-array into vortex-functions #10762), so custom scalar-function registrations are not overwritten.
  2. VariantGet was moved to vortex-functions in Move scalar functions out of vortex-array into vortex-functions #10762 (now on develop); this PR only updates test imports in encodings/parquet-variant/src/kernel.rs and does not touch vortex_parquet_variant::initialize.

@codex review

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
@lwwmanning

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 43e56a40fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@myrrc

myrrc commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Should not be merged because of https://github.com/vortex-data/vortex/pull/10768/changes#r4527014415. cc @robert3005

@myrrc myrrc added the do not merge Pull requests that are not intended to merge label Nov 23, 2026
robert3005 and others added 5 commits November 23, 2026 11:59
Expressions are about to move out of vortex-array into vortex-expr, which
means vortex-functions (whose scalar functions construct expressions) has to
sit above vortex-expr rather than below it. This commit flips the dependency
without moving the expression types yet:

- `select` returns to vortex-array's core builtins. The field-path analyses in
  vortex-expr (`referenced_field_paths`, immediate access) narrow through it
  alongside `get_item`, so it is part of the projection machinery those
  analyses are built on, like `get_item` and `pack`.
- `StatFn` moves from vortex-functions into `vortex_expr::stats::stat_fn`,
  registered by the new `vortex_expr::initialize`.
- The stats rewrite rules for `between`, `is_nan`, `like`, `list_contains`,
  `dynamic` and `dynamic_expression` move into `vortex_functions::pruning`,
  registered by `vortex_functions::initialize`. The shared pieces they
  build on (stat references, NaN guards, literal and cast stat folding)
  become the public `vortex_expr::stats::rewrite::helpers` module.
- `find_between` moves next to the `between` function it targets.

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: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
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`, and their
CodSpeed counts and durations move with them.

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: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
`select` and `is_null` are not needed by vortex-array's own arrays, so they
move to vortex-functions with their constructors, builder methods
(`ArrayFunctions::is_null`, `ExprFunctions::is_null`), tests and pruning
rewrites (`vortex_functions::pruning`). `not` stays in vortex-array, because
validity inversion and the `sum_v2` aggregate negate arrays lazily.

- `get_item` read through `select` by naming it. It now asks its child through
  the new `ScalarFnVTable::forwarded_field` hook, which reports the child whose
  field an output field passes through unchanged. `select` implements it, so
  `get_item(select(x))` still reduces to `get_item(x)` for arrays and
  expressions.
- `IsNull` and `IsNotNull` share the and/or null-check reduction through the
  public `reduce_null_check`; each passes its own nested check.
- The field-access analyses `referenced_field_paths` and
  `make_bound_free_field_annotator`, which look through `select`, move from
  vortex-expr to `vortex_layout::analysis`, next to the scans that use them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ps4mp7KF5c4p66aoSoXx5j
Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
…ex_array::stats

`Stat`, `Precision`, the stat bounds and the `StatsProvider` traits describe the
statistics every array carries, not expressions, so they join the per-array
statistics cache (`ArrayStats`, `StatsSet`) in `vortex_array::stats`.
`vortex_array::expr` now holds only `BoundExpression` and its optimizer.

Callers move from `vortex_array::expr::stats` to `vortex_array::stats`. The
umbrella crate's `vortex::expr::stats` keeps re-exporting the statistics
vocabulary alongside vortex-expr's stat expressions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ps4mp7KF5c4p66aoSoXx5j
Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>

This branch was successfully deployed

1 active and 1 inactive (outdated) deployments
vercel-docs — fbfa9981 Deployed Nov 23, 2026 by robert3005 via Publish preview / Deploy #13072
docs-preview/pr-10768 — 123df131 Deployed Oct 26, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/break A breaking API change do not merge Pull requests that are not intended to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants