Repository navigation
Conversation
`equals`, `notEquals`, `less`, `greater`, `lessOrEquals` and `greaterOrEquals` were never JIT-compiled when an argument is a `Date`, `Date32`, `DateTime` or `DateTime64`. Compile the pairs that the interpreted comparison evaluates on the stored integers, with the same results: - two values of the same kind, including `DateTime` values with different time zones, which are absolute timestamps; - `Date` vs `Date32`, both day numbers from the same epoch; - `DateTime` vs a plain number; - `DateTime64` vs `DateTime64` of the same scale, and `DateTime` vs `DateTime64`, where the `DateTime` is multiplied by 10^scale, which cannot overflow. `Date` vs `DateTime` needs the time zone, and `DateTime64` values of different scales are rescaled with an overflow check that can throw, so both stay interpreted, as do `Time` and `Time64`. Date conditions inside expressions get faster, for example 1.45x for `countIf(ts >= ... AND ts < ... AND value > 500)` and 1.82x for a `Date` range with `Date` vs `Date32`, on one thread. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 3, 2026
…isons Co-Authored-By: Claude Opus 5.5 <[email protected]>
scanhex12
added a commit
that referenced
this pull request
Nov 4, 2026
It is done, and for more types, by #128974, which the device's expressions are to take once it is merged. Until then, a predicate with a comparison of dates is evaluated on the CPU. `05447_gpu_filtered_read` checks the plans of reads filtered by numbers rather than by dates.
scanhex12
added a commit
that referenced
this pull request
Nov 4, 2026
It is done, and for more types, by #128974, which the device's expressions are to take once it is merged. Until then, a predicate with a comparison of dates is evaluated on the CPU.
This branch has not been deployed
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.
equals,notEquals,less,greater,lessOrEqualsandgreaterOrEqualswere never JIT-compiled when an argument is aDate,Date32,DateTimeorDateTime64(a "TODO support date/date32" inFunctionsComparison.h). This compiles the pairs that the interpreted comparison evaluates on the stored integers, with the same results:DateTimevalues with different time zones, which are absolute timestamps;DatevsDate32, both day numbers from the same epoch;DateTimevs a plain number;DateTime64vsDateTime64of the same scale, andDateTimevsDateTime64, where theDateTimeis multiplied by 10^scale, which cannot overflow.DatevsDateTimeneeds the time zone, andDateTime64values of different scales are rescaled with an overflow check that can throw, so both stay interpreted, as doTimeandTime64.Results
50M rows,
Memorytable, server-side medians of 9 interleaved runs, JIT on vs off:countIfwith aDateTimerangecountIfwith aDaterange andDatevsDate32countIfwithDateTime64vsDateTimesum(if(...))time bucketA new stateless test compares compiled and interpreted results for 3003 rows (edge values and generated values) × 16 type pairs × 6 operators, and checks that the compiled query runs every comparison compiled (
CompiledFunctionRows).Stacked on the PR for the profile events (#128973).
Related: #126979
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Comparisons of
Date,Date32,DateTimeandDateTime64values of the same kind (and ofDateTimewithDateTime64) can now be JIT-compiled as part of expressions (compile_expressions), which makes date conditions inside expressions up to 1.8x faster.