[SQL] Support for OVER window queries with UNSIGNED and UUID NOT NULL sort orders#5904
Open
mihaibudiu wants to merge 1 commit intomainfrom
Open
[SQL] Support for OVER window queries with UNSIGNED and UUID NOT NULL sort orders#5904mihaibudiu wants to merge 1 commit intomainfrom
mihaibudiu wants to merge 1 commit intomainfrom
Conversation
… sort orders Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
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.
Fixes #5890
Rolling aggregates use radix sort, and require unsigned values as sort keys. To actually sort signed values, the compiler encodes signed values into unsigned values by using twice the number of bits. (One extra bit is needed in general to encode the NULL value as well).
OVER windows were previously rejecting sorting over unsigned values - this PR fixes this omission. Twice as many bits are still needed for nullable unsigned types.
UUID is treated as a u128 type. Unfortunately this means that UUID NULL needs actually 256 bits (129 to be more precise, but we always use powers of two currently)... so we cannot do it.
By adding unit tests I realized that there is a bug in the implementation for signed types too. Fixing this bug required changing the encoding of the integers into the rolling aggregate tree. As a consequence, programs using the new encoding won't be able to load the state from programs using the old encoding. To prevent this, I have renamed some functions, which should cause the compiler to generate new hashes for the operators around rolling aggregates.
I decided to leave OVER windows for BINARY objects for a later PR.