Skip to content

refactor: make evaluator cast dispatch static#318

Merged
KKould merged 6 commits intomainfrom
refactor/static-cast-dispatch-pr
Apr 8, 2026
Merged

refactor: make evaluator cast dispatch static#318
KKould merged 6 commits intomainfrom
refactor/static-cast-dispatch-pr

Conversation

@KKould
Copy link
Copy Markdown
Member

@KKould KKould commented Apr 8, 2026

What problem does this PR solve?

Evaluator casts were still selected through runtime type matching, which added avoidable overhead and kept a lot of cast-related logic and tests concentrated in dispatcher-style code.

There were also several no-op cast paths that still flowed through binding/execution even when the source and target types were already identical, plus the projection executor was still rebuilding its temporary arena values buffer for each row.

Issue link:

What is changed and how it works?

  • Make evaluator cast dispatch static so the concrete cast evaluator is chosen up front, and keep eval_cast as the only cast execution entrypoint.
  • Remove the old dynamic cast-selection flow and update binder/expression paths to rely on the bound cast evaluator instead of scattered runtime type checks.
  • Short-circuit same-type casts during binding so redundant cast expressions can be skipped early.
  • Push Cow<LogicalType> through the relevant evaluator factory / type-combination paths to reduce unnecessary cloning where the type only needs to be borrowed.
  • Split evaluator dispatch code into dedicated binary.rs, unary.rs, and cast.rs files while keeping per-type implementations in the existing flat evaluator files.
  • Move semantic cast/binary tests next to the corresponding type implementation files, and expand cast coverage so each evaluator file tests the target types it actually implements.
  • Reuse the projection executor arena temporary values buffer across rows instead of rebuilding it each time.

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

The main review surface is:

  1. static cast dispatch and same-type cast short-circuiting across binder/expression/evaluator creation
  2. evaluator module reshaping plus the per-type cast test relocation/coverage expansion
  3. projection executor temporary buffer reuse

Validation used for this branch:

  • cargo test -q

@KKould KKould self-assigned this Apr 8, 2026
@KKould KKould merged commit 04a464c into main Apr 8, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant