-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Core: add variant type support #11831
base: main
Are you sure you want to change the base?
Conversation
5a18496
to
68d690e
Compare
cc @rdblue, @RussellSpitzer, @flyrain and @JonasJ-ap. This is to add the changes in core to support variant type. |
core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/iceberg/avro/TestAvroSchemaProjection.java
Outdated
Show resolved
Hide resolved
68d690e
to
04958ca
Compare
b276d3f
to
fe6038a
Compare
@aihuaxu very important feature that will allow a lot more options for iceberg, thank you for your contribution |
@@ -56,6 +56,10 @@ class BuildAvroProjection extends AvroCustomOrderSchemaVisitor<Schema, Schema.Fi | |||
@Override | |||
@SuppressWarnings("checkstyle:CyclomaticComplexity") | |||
public Schema record(Schema record, List<String> names, Iterable<Schema.Field> schemaIterable) { | |||
if (current.isVariantType()) { |
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.
I think that the corresponding visit
method should be updated to call a new visitor variant
method. That will be cleaner.
The visitor should look for the variant
logical type, so we will need to implement the logical type.
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.
You are right. This is to workaround before the logical type is added in Avro by using Iceberg variant type. Let me add a comment for this.
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.
If we are updating the visitor implementations, I think we should also update the visit method. We can also delay making thes changes.
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.
You mean handle variant in the following visit method? As I mentioned that we don't have variant logical type in Schema.getType() from avro, we can't handle that for now. Let me know if understand correctly. I think this is needed for metadata change and I can defer until then.
abstract class AvroCustomOrderSchemaVisitor<T, F> {
public static <T, F> T visit(Schema schema, AvroCustomOrderSchemaVisitor<T, F> visitor) {
switch (schema.getType()) {
core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/iceberg/avro/TestBuildAvroProjection.java
Outdated
Show resolved
Hide resolved
e0a430f
to
1b56bf5
Compare
1b56bf5
to
6f570cd
Compare
760ed7d
to
eb11b53
Compare
core/src/test/java/org/apache/iceberg/avro/TestSchemaConversions.java
Outdated
Show resolved
Hide resolved
6427c06
to
fc10750
Compare
fc10750
to
86efa87
Compare
86efa87
to
50d1482
Compare
core/src/test/java/org/apache/iceberg/TestSchemaUnionByFieldName.java
Outdated
Show resolved
Hide resolved
final org.apache.avro.Schema actual = testSubject.record(expected, List.of(), null); | ||
assertThat(actual) | ||
.as("Variant projection produced undesired variant schema") | ||
.isEqualTo(expected); |
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.
I don't think that this is going to exercise the path that we want to when the visitor and visit method are updated. This should create a record schema and validate that visiting a file schema gives the correct projection to request, by name.
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.
I will delay the change in BuildAvroProjection as mentioned above so I removed the test. Will add this back when making the code change.
This is to add some required changes in API and core module for Variant support, including:
Part of: #10392