Skip to content

perf(calcite): push a filter on a narrow integer column through Calcite's cast - #560

Merged
dfa1 merged 1 commit into
mainfrom
feat/cast-unwrap
Oct 18, 2026
Merged

dfa1 merged 1 commit into
mainfrom
feat/cast-unwrap

Conversation

@dfa1

@dfa1 dfa1 commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Stacked on #559 (rebased onto main once it merges).

Calcite compares a SMALLINT/TINYINT column with an INTEGER literal through a cast (CAST($5):INTEGER < 5); the translation only accepted a bare column, so such a WHERE was 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 < 5 291 → 43 ms.

Tests

  • FilterTranslationTest: a widening cast translates as the column; a lossy cast does not.
  • vortex-jni cross-check: GROUP BY with three WHEREs on a Rust-written Int16 column is pushed down and equals the scan.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WtuVGQ5h5Lk6Zn4JnkxF1K

…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
dfa1 force-pushed the feat/cast-unwrap branch from 4eff711 to 3b11f75 Compare October 18, 2026 10:28
@dfa1
dfa1 merged commit 957be48 into main Oct 18, 2026
9 checks passed
@dfa1
dfa1 deleted the feat/cast-unwrap branch October 18, 2026 10:29
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