fix: Support RANGE window frames over Time32/Time64 ORDER BY keys - #24556
Closed
waterWang wants to merge 3 commits into
Closed
fix: Support RANGE window frames over Time32/Time64 ORDER BY keys#24556waterWang wants to merge 3 commits into
waterWang wants to merge 3 commits into
Conversation
Contributor
|
Duplicate of #24515, closing in favor of that. |
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.
Which issue does this PR close?
ORDER BYuses aTIMEcolumn #24514.Rationale for this change
Window functions whose leading
ORDER BYkey isTime32orTime64fail during type coercion, even when no frame clause is specified.ORDER BYwithout a frame defaults toRANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, andextract_window_frame_target_typehad no arm for the time types.Time32(Second),Time32(Millisecond),Time64(Microsecond),Time64(Nanosecond)and dictionary-wrapped time values are all affected. Those bounds only need to compare order key values, which time values support just asUtf8does.A finite offset like
INTERVAL '1' HOUR PRECEDINGis different: time/interval arithmetic wraps around the 24-hour clock, so it should produce a planning error rather than an internal error.What changes are included in this PR?
extract_window_frame_target_typeindatafusion/optimizer/src/analyzer/type_coercion.rs: addedTime32andTime64to the match arm that returns the order key type as-is (free range)datafusion/sqllogictest/test_files/window.slt: added tests for free range frames overTime64(Microsecond),Time32(Second),Time32(Millisecond), dictionary-wrapped time, andRANK(); planning error tests forINTERVALPRECEDING/FOLLOWING offsetsAre these changes tested?
Yes, by the new sqllogictest cases in
window.slt.Are there any user-facing changes?
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) overTime32/Time64ORDER BY keys now plan and execute successfully instead of failing with an internal error.RANGEwith anINTERVALPRECEDING/FOLLOWING offset over a time order key is now rejected with a planning error instead of an internal error.