fix: support binary ORDER BY keys in RANGE window frames - #24340
Open
waterWang wants to merge 1 commit into
Open
fix: support binary ORDER BY keys in RANGE window frames#24340waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
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?
Closes #24327.
Rationale for this change
Window functions with
ORDER BYon a binary column fail with:This is because
extract_window_frame_target_typedoes not include binary family types in its supported types, causing an internal error during type coercion.What changes are included in this PR?
extract_window_frame_target_type: Added support forBinary,LargeBinary,BinaryView, andFixedSizeBinarytypes. These returnDataType::Nullas the target type, since "free" RANGE frames (bounds limited toUNBOUNDED PRECEDING/CURRENT ROW/UNBOUNDED FOLLOWING) don't require arithmetic on the order key.coerce_window_frame: Added a check that rejects RANGE frames with finite offset bounds (e.g.,RANGE BETWEEN 1 PRECEDING AND CURRENT ROW) when the ORDER BY key is a binary type, returning a clear planning error instead of an internal error.Are these changes tested?
Yes — the existing type coercion test suite covers window frame coercion. The fix ensures that:
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROWwith binary ORDER BY keys now succeedsRANGE BETWEEN 1 PRECEDING AND CURRENT ROWwith binary ORDER BY keys produces a planning errorROWSandGROUPSframes with binary ORDER BY keys continue to work (they were already supported)Query example
Previously:
Internal error: Cannot run range queries on datatype: Binary.Now: results as expected.