-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat(schema): Add VARIANT support to HoodieSchema #17751
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
base: master
Are you sure you want to change the base?
Conversation
| return DATE; | ||
| } else if (logicalType == LogicalTypes.uuid()) { | ||
| return UUID; | ||
| } else if (logicalType instanceof VariantLogicalType) { |
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.
Can we follow a similar pattern as the uuid where there is a singleton we can compare to instead of instanceof?
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.
Make sense, limit the number of object creation for types. Will eagerly initialize a singleton.
| } | ||
|
|
||
| /** | ||
| * Creates an unshredded Variant schema. |
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.
General question, can you have shredded and unshredded values in the same dataset? if so, it seems like the schema should be the same for these
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 quite understand this question. The implementation follows the parquet schema spec.
Nonetheless, will like to still understand what you're pushing towards.
Do you mean if we can have a unshredded_typed_column and shredded_typed_column in the dataset?
Or are you saying that since shredded_variant typed columns can hold unshredded data, we should just maintain the shredded type?
Unshredded
optional group variant_unshredded (VARIANT) {
required binary metadata;
required binary value;
}
Shredded
optional group variant_shredded (VARIANT) {
required binary metadata;
optional binary value;
optional int64 typed_value;
}
So, to use shredded schema to represent unshredded, we can just make typed_value null and populate value?
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'm wondering if the column can have both shredded and unshredded in the same file.
| * @param typedValueSchema the schema for the typed_value field (can be null if typed_value is not needed) | ||
| * @return a new HoodieSchema.Variant representing a shredded variant | ||
| */ | ||
| public static HoodieSchema.Variant createVariantShredded(HoodieSchema typedValueSchema) { |
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.
Do we need include shredding information in type/schema layer? IIUC, it's more about read/write optimization mechanism, which can be inferred or fetched from configuration during reading or writing.
Describe the issue this Pull Request addresses
Introduce the new
VARIANTschema type. This will look similar to a record/struct with a logical type associated with it. The implementation is inline with parquet spec.Linked task: #17745
Note: No reader and writer support has been added yet. It will be added in a separate PR.
Summary and Changelog
VARIANTsupport toHoodieSchemaVARIANTtype toHoodieSchemaTypeenum.Impact
Support for Variant types in accordance to parquet's spec.
Risk Level
Low
Documentation Update
None
Contributor's checklist