with-orderBy: ORDER BY flows to downstream collect + overflow-safe temporal ordering (+10 TCK)#91
Merged
Merged
Conversation
…mporal ordering (+10 TCK) WithOrderBy1 [45] all 10 type examples: a non-aggregating WITH's ORDER BY over a kept input variable is now also pushed into the CTE body so a downstream aggregating WITH (collect) sees sorted rows; and the temporal < / > comparator uses an overflow-safe (seconds, ns) comparison so year-9999 datetimes no longer wrap int64 epoch-ns and sort smallest. Verified: rigorous full TCK pass-set diff zero regressions, 3776 to 3786; unit 944/944; functional clean.
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.
Summary
Closes the entire
WithOrderBy1[45] cluster — "Sort order should be consistent with comparisons where comparisons are defined" — across all 10 type examples (booleans, integers, floats, string, lists, dates, localtimes, times, localdatetimes, datetimes).Two root causes
WITH … ORDER BY <input-var> WITH collect(x)ignored the ORDER BY.An ORDER BY on a non-aggregating WITH was only pushed into the WITH's CTE body when it referenced a dropped input variable. For an ORDER BY over a kept input variable it stayed on the outer SELECT, which a downstream aggregating WITH (
collect) never observed — socollectaggregated in UNWIND order. Now, when every ORDER BY identifier is a live input variable and the WITH has no LIMIT/SKIP, the ORDER BY is also emitted inside the CTE body so the downstream aggregate sees sorted input (SQLite preserves an ordered subquery's order throughjson_group_array). The outer ORDER BY is still emitted for final-output ordering.Temporal
</>overflowed int64 for far-future years.gql_order_cmp_func's temporal path comparedparse_temporal_ns()values, whereepoch_seconds * 1e9overflows int64 around year ~2262 — so year-9999 datetimes compared as the smallest value, making<disagree with the ORDER BY key. Newcmp_temporal_strings()compares(epoch_seconds, sub_second_ns)componentwise (no overflow across the full Cypher year range).Verification
Windows CI is a known flake and is allowed to fail.
🤖 Generated with Claude Code