-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sql): implement UUID column type #2769
Merged
Merged
Conversation
This file contains 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
jerrinot
added
Java
Improvements that update Java code
Core
Related to storage, data type, etc.
labels
Nov 14, 2022
broken due to the UUID type introduction
bluestreak01
changed the title
feat(core): introduce UUID column type
feat(core): implement UUID column type
Jan 17, 2023
bluestreak01
changed the title
feat(core): implement UUID column type
feat(sql): implement UUID column type
Jan 17, 2023
there are still cleanups needed, but tests are green locally. Pushing to run tests on other architecture and to give reviewers a chance to see how this version looks like. Personally I'm not crazy about it, the stateful nature of wrappers makes things more complex and difficult to reason about.
This reverts commit 0792748.
# Conflicts: # core/src/main/java/io/questdb/cairo/TableUtils.java # core/src/main/java/io/questdb/cairo/map/CompactMapValue.java # core/src/main/java/io/questdb/cairo/map/FastMap.java # core/src/main/java/io/questdb/cairo/map/FastMapValue.java # core/src/main/java/io/questdb/cairo/wal/WalWriter.java # core/src/main/java/io/questdb/cairo/wal/WriterRowUtils.java # core/src/main/java/io/questdb/griffin/engine/functions/bind/StrBindVariable.java # core/src/main/java/io/questdb/griffin/engine/functions/cast/CastLong256ToStrFunctionFactory.java # core/src/main/java/io/questdb/std/Hash.java # core/src/test/java/io/questdb/cairo/map/FastMapTest.java # core/src/test/java/io/questdb/cairo/wal/WalWriterTest.java
set operations never generate casts from UUID to other types
eugenels
reviewed
Jan 20, 2023
eugenels
reviewed
Jan 20, 2023
the whole UUID impl assume Long128 and UUID storage is the same. hence no reason to keep Uuid.BYTES separated
eugenels
reviewed
Jan 20, 2023
core/src/main/java/io/questdb/cutlass/line/tcp/LineTcpMeasurementEvent.java
Show resolved
Hide resolved
bluestreak01
approved these changes
Jan 20, 2023
[PR Coverage check]😍 pass : 918 / 1020 (90.00%) file detail
|
eugenels
approved these changes
Jan 20, 2023
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.
Motivation
Storing and filtering UUID values is a common QuestDB use-case. Right now QuestDB does not support UUID natively and users typically resort to storing them as Strings. This works, but it's inefficient: UUID in a string column occupies 76 bytes even though it contains just 128 bits (=16 bytes) of information. Also, filtering is slower than it could be - to check a UUID is really matching a predicate, we have to read all these 76 bytes and compare them with a predicate value.
This PR adds a new column type optimized for storing UUID values. They occupy 16 bytes as they should and as a result filtering is also more efficient.
Interface and backward compatibility
This PR adds support to the PGWire protocol, which supports the UUID type too. Example in Java:
Moreover, a well-formed UUID string can still be inserted into a UUID column - QuestDB will convert it internally. This makes the transition from String to UUID columns smooth as many applications can get benefit from this functionality by just changing a column type from String to UUID.
Example
This also works with the ILP ingestion QuestDB ILP clients can
send
UUIDs
asstrings
to be converted to UUIDs by the server. Yet we plan to add a new type into ILP to optimize it further.