refactor: make scalar expressions arena-backed - #380
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #380 +/- ##
==========================================
+ Coverage 92.95% 93.07% +0.11%
==========================================
Files 255 257 +2
Lines 43770 45289 +1519
==========================================
+ Hits 40687 42152 +1465
- Misses 3083 3137 +54
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue link: N/A
ScalarExpressioncurrently owns nested expression values in some paths while other planner structures use arena references. This mixes ownership models, requires repeated cloning and allocation, complicates expression traversal and serialization, and makes plan formatting allocate intermediate strings.The ORM layer also converts already-bound expressions back into owned
ScalarExpressionvalues before allocating them again. Once those expressions retain theirExprRefidentity, column pruning must avoid applying the same relative position remap more than once to a shared expression node in a single remap batch.What is changed and how it works?
ExprRefacross binding, planning, optimization, execution, ORM, and serialization.ExprRefreference serialization and updates column/default-expression serialization accordingly.ScalarExpressionvariant.ExprRef, full-expression callbacks, and an explicit fast short-circuit hook.PositionRemapperbatch.PositionRemapper::newclears the set so shared nodes are remapped once per mapping without leaking visited state into the next level.ExprRefform. Already-bound expressions retain their references; only unbound literals/raw expressions are allocated into the current arena.Display-style adapter. Recursive formatting writes directly tofmt::Formatter, while owned strings remain at API boundaries such asLogicalPlan::explainand expression output names.table.columnand index names in EXPLAIN output instead of exposing internal IDs.IN/NOT INandEXISTS/NOT EXISTSplan coverage into sqllogictest and updates existing EXPLAIN baselines to full semantic output.Code changes
Check List
Tests
Side effects
The arena-backed representation changes Rust-facing expression and ORM trait signatures, including generated/manual
Modelimplementations. SQL behavior and semantic EXPLAIN names are preserved.Note for reviewer
This is a broad mechanical refactor, so the main semantic review points are:
ExprRefownership and lifetime boundaries inPlanArena/TableArena.ExprVisitorandExprVisitorMuttraversal and short-circuit behavior.PositionRemapperbatch is constructed.ScalarExpression.The only warning observed during local test runs is the pre-existing dead-code warning for
execute_mut.