Skip to content

[SQL] Support for OVER window queries with UNSIGNED and UUID NOT NULL sort orders#5904

Open
mihaibudiu wants to merge 1 commit intomainfrom
issue5890
Open

[SQL] Support for OVER window queries with UNSIGNED and UUID NOT NULL sort orders#5904
mihaibudiu wants to merge 1 commit intomainfrom
issue5890

Conversation

@mihaibudiu
Copy link
Contributor

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.

… sort orders

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SQL] Support window queries sorting over unsigned types, UUID

1 participant