Repository navigation
perf(calcite): push a filter on a narrow integer column through Calcite's cast - #560
Merged
Merged
Conversation
…te's cast Calcite compares a SMALLINT or TINYINT column with an INTEGER literal through a cast: order_serverId < 5 arrives as CAST($5):INTEGER < 5. The filter translation accepted only a bare column, so such a WHERE was neither pushed nor enforced by the scan, and every aggregate filtered on it fell back to Calcite. A column under a cast that widens it without loss (an integer to a wider integer, REAL to DOUBLE) now translates as the column itself. A lossy cast (BIGINT to DOUBLE rounds past 2^53) is still left to Calcite. Raincloud appian-order (4.28M rows), best of 3: group by order_destination ... where order_serverId < 5 291 -> 43 ms Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WtuVGQ5h5Lk6Zn4JnkxF1K
dfa1
force-pushed
the
feat/cast-unwrap
branch
from
October 18, 2026 10:28
4eff711 to
3b11f75
Compare
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.
Stacked on #559 (rebased onto main once it merges).
Calcite compares a
SMALLINT/TINYINTcolumn with anINTEGERliteral through a cast (CAST($5):INTEGER < 5); the translation only accepted a bare column, so such aWHEREwas neither pushed nor enforced, and its aggregates scanned. A column under a lossless widening cast (integer → wider integer,REAL→DOUBLE) now translates as the column; a lossy one (BIGINT→DOUBLE) stays with Calcite.Raincloud appian-order (4.28M rows):
group by order_destination ... where order_serverId < 5291 → 43 ms.Tests
FilterTranslationTest: a widening cast translates as the column; a lossy cast does not.GROUP BYwith threeWHEREs on a Rust-writtenInt16column is pushed down and equals the scan.🤖 Generated with Claude Code
https://claude.ai/code/session_01WtuVGQ5h5Lk6Zn4JnkxF1K