-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: add variant builder implementation #11857
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
Conversation
f8f8e8f to
d806c66
Compare
d806c66 to
16210a0
Compare
|
@rdblue, @RussellSpitzer Please help review. Thanks. |
16210a0 to
d4f1d0e
Compare
core/src/main/java/org/apache/iceberg/variants/VariantArray.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/iceberg/variants/VariantSizeLimitException.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/iceberg/variants/VariantImpl.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/iceberg/variants/VariantConstants.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/iceberg/variants/VariantConstants.java
Outdated
Show resolved
Hide resolved
| Preconditions.checkArgument( | ||
| json != null && !json.isEmpty(), "Input JSON string cannot be null or empty."); | ||
|
|
||
| try (JsonParser parser = new JsonFactory().createParser(json)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are existing utilities in JSONUtil for a lot of the boilerplate around parsing and generating JSON. Is there a reason not to use the same approach here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to parse the JSON token by token so we can encode them in binary. Seems we only have the version to parse the JSON string into a full JSONNode and then create the object.
core/src/main/java/org/apache/iceberg/variants/VariantBuilder.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/iceberg/variants/VariantBuilderBase.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/iceberg/variants/VariantBuilderBase.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/iceberg/variants/VariantBuilderBase.java
Outdated
Show resolved
Hide resolved
9cba102 to
86bf18b
Compare
fa34686 to
3ad94d3
Compare
3ad94d3 to
38e6f2f
Compare
core/src/main/java/org/apache/iceberg/variants/VariantBuilderBase.java
Outdated
Show resolved
Hide resolved
38e6f2f to
6062741
Compare
6062741 to
cc91ec0
Compare
| } | ||
|
|
||
| protected void writeNullInternal() { | ||
| valueBuffer.writePrimitive(Variants.PhysicalType.NULL, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| valueBuffer.writePrimitive(Variants.PhysicalType.NULL, null); | |
| valueBuffer.writePrimitive(PhysicalType.NULL, null); |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
|
This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time. |
This PR adds the implementation to build a variant for primitive, object and array.
The usage:
Build from Json
VariantBuilder.parseJson(json_string);build a primitive
Nested arrays and objects can be supported as well. Please see the test cases for the usage. Compared to build from JSON string, we also support some additional types such as timestamp, date.
Part of: #10392