Repository navigation
perf(calcite): answer temporal MIN/MAX from zone maps; scan them without java.time - #559
Merged
Merged
Conversation
…out java.time MIN/MAX of a date, time or timestamp column always scanned: the zone statistic is the raw storage integer, and the literal builder had no DATE/TIME/TIMESTAMP branch, so the rule abandoned. The scan path was slow on those columns too: it parsed the extension metadata and built a LocalDate/LocalTime/Instant for every row. Temporal resolves a column's kind and unit once and converts a raw storage integer straight to Calcite's internal form (epoch days, millis of day, epoch millis), with the decoders' rounding: a millisecond date and a timestamp floor, a time must lie within the day. The scan reads temporal columns through it, and the aggregate rule converts a zone statistic the same way before building the literal. The adapter declared TIME and TIMESTAMP at Calcite's default precision 0 while the scan delivered milliseconds, so a literal built for the column lost them: min(order_placedOn) came back .0 instead of .335. They are now TIME(3) and TIMESTAMP(3), the precision the values carry, and JDBC getString shows the milliseconds. Raincloud appian-order (4.28M rows), best of 3: min(placedOn), max(shipBy), max(inspectionTime) 337 -> 28 ms Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WtuVGQ5h5Lk6Zn4JnkxF1K
dfa1
force-pushed
the
feat/temporal-minmax-pushdown
branch
from
October 18, 2026 10:28
941b156 to
3cbdfc2
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 #558 (rebased onto main once it merges).
MIN/MAXof a date/time/timestamp column always scanned: the zone statistic is the raw storage integer and the literal builder had no temporal branch.Temporalresolves a column's kind and unit once and converts a raw integer to Calcite's internal form (epoch days, millis of day, epoch millis) with the decoders' rounding; the rule converts the statistic before building the literal.java.timeobject per row.TIME/TIMESTAMPwere declared at Calcite's default precision 0 while the scan delivered milliseconds, so a literal for the column lost them (min(order_placedOn)came back.0instead of.335). They are nowTIME(3)/TIMESTAMP(3); JDBCgetStringshows the milliseconds.Raincloud appian-order (4.28M rows):
min(placedOn), max(shipBy), max(inspectionTime)337 → 28 ms.Tests
TemporalPushDownTest: date/time/timestampMIN/MAX(pre-epoch µs, two chunks) pushed and equal to the scan (+ interval '0');Temporalrounding and out-of-day rejection.🤖 Generated with Claude Code
https://claude.ai/code/session_01WtuVGQ5h5Lk6Zn4JnkxF1K