Skip to content

Conversation

@pepijnve
Copy link
Contributor

@pepijnve pepijnve commented Oct 24, 2025

Which issue does this PR close?

Rationale for this change

When CaseExpr needs to evaluate a PhysicalExpr for a subset of the rows of the input RecordBatch it will first filter the record batch using a selection vector. This filter steps filters all columns of the RecordBatch, including ones that may not be accessed by the PhysicalExpr. For wide (many columns) record batches and narrow expressions (few column references) it can be beneficial to project the record batch first to reduce the amount of wasted filtering work.

What changes are included in this PR?

  • Determines the set of columns used by the sub expressions of a case expression
  • Derives a projection vector from this set
  • Derives sub expressions using the projection vector
  • When appropriate, projects incoming record batches and uses the projected sub expressions for evaluation

Are these changes tested?

  • Covered by existing tests

Are there any user-facing changes?

No

@github-actions github-actions bot added the physical-expr Changes to the physical-expr crates label Oct 24, 2025
@pepijnve
Copy link
Contributor Author

This PR builds on the work done in #18152 and will be marked ready for review once/if that PR lands.

@pepijnve pepijnve force-pushed the project_case_internal branch from d3cd191 to 70024ad Compare October 24, 2025 22:43
- Use usize::MAX as null marker instead of zero
- Introduce `ResultState` enum
- Make diagrams more representative
- Extend documentation of `merge`
@pepijnve pepijnve force-pushed the project_case_internal branch from 5b86121 to b751a08 Compare October 25, 2025 13:41
@pepijnve pepijnve force-pushed the project_case_internal branch from b751a08 to e17be32 Compare October 25, 2025 14:34
@pepijnve pepijnve force-pushed the project_case_internal branch from e17be32 to 6691bc6 Compare October 27, 2025 13:16
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Oct 27, 2025
@pepijnve pepijnve force-pushed the project_case_internal branch from 6691bc6 to d7e49c5 Compare October 27, 2025 20:24
@pepijnve pepijnve closed this Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve performance of queries of the form SELECT *, CASE ... END

1 participant