[Feature] Support for VARIANT data type#2875
Open
XuQianJin-Stars wants to merge 1 commit intoapache:mainfrom
Open
[Feature] Support for VARIANT data type#2875XuQianJin-Stars wants to merge 1 commit intoapache:mainfrom
XuQianJin-Stars wants to merge 1 commit intoapache:mainfrom
Conversation
84e0b17 to
905563e
Compare
This file contains hidden or 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
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.
Purpose
Linked issue: close #2873
Introduce a first-class
Variantdata type throughout Fluss's row infrastructure, replacing the previous opaquebyte[]representation. This aligns Fluss with the Variant Binary Encoding spec and follows the same design pattern as Apache Paimon's Variant implementation, providing structuredvalue()andmetadata()access for semi-structured data.Brief change log
1. Core Types (
fluss-common)Variantinterface (fluss-common/.../row/Variant.java): Definesvalue(),metadata(),sizeInBytes(),copy()accessors, plus static helpersbytesToVariant(byte[])/variantToBytes(Variant)for backward-compatible wire format conversion.GenericVariantclass (fluss-common/.../row/GenericVariant.java): Default implementation storing twobyte[]fields (value + metadata) with properequals(),hashCode(),toString().VariantType(fluss-common/.../types/VariantType.java): AddsVARIANTto Fluss's type system withDataTypeRoot.VARIANTenum entry, parser support, JSON serde, and visitor pattern integration.2. Row Infrastructure (
fluss-common)DataGetters: AddedVariant getVariant(int pos)abstract method.InternalRowimplementations:GenericRow,BinaryRow(viaAlignedRow),CompactedRow,IndexedRow,ProjectedRow,PaddingRow,ColumnarRow— all implementgetVariant().InternalArrayimplementations:GenericArray,BinaryArray,ColumnarArray— all implementgetVariant().BinaryWriter,AbstractBinaryWriter,BinaryArrayWriter,SequentialBinaryWriter— addedwriteVariant(int pos, Variant).CompactedRowReader/Writer,IndexedRowReader/Writer— addedreadVariant()/writeVariant().ArrowVariantColumnVector(reader) andArrowVariantWriter(writer) for Arrow-based columnar storage;ArrowUtilsupdated.3. Client Converters (
fluss-client)PojoToRowConverter: Added VARIANT handling, supporting bothbyte[]andVariantinputs.RowToPojoConverter: Added VARIANT →byte[]conversion.4. Flink Bridge (
fluss-flink)FlussTypeToFlinkType: MapsVARIANT→ FlinkBYTES(with TODO for future native VariantType support).FlussRowToFlinkRowConverter: ConvertsVariant→byte[]viavariantToBytes().FlussRowToJsonConverters: SerializesVariantas binary JSON node.FlinkAsFlussRow/FlinkAsFlussArray: ImplementsgetVariant()by deserializing from Flink'sbyte[].PojoToRowConverter(Flink): Added VARIANT handling.RowDataSerializationSchema: Added VARIANT case.5. Spark Bridge (
fluss-spark)FlussToSparkTypeVisitor: MapsVARIANT→ SparkBinaryType(with TODO for Spark 4 native VariantType via shim mechanism).SparkAsFlussRow/SparkAsFlussArray: ImplementsgetVariant()by deserializing from Spark'sbyte[].6. Lake Connectors (
fluss-lake)FlussDataTypeToPaimonDataTypemaps VARIANT;PaimonRowAsFlussRow/PaimonArrayAsFlussArrayimplementgetVariant()(with TODO for native Paimon Variant once dependency is upgraded).FlussDataTypeToIcebergDataTypemaps VARIANT;IcebergRecordAsFlussRow/IcebergArrayAsFlussArrayimplementgetVariant().LanceArrowUtils,ArrowDataConverter,ShadedArrowBatchWriterupdated with VARIANT support.7. Utilities
InternalRowUtils,TypeUtils,PartitionUtils— added VARIANT handling.DataTypeJsonSerde— VARIANT serialization/deserialization.Tests
DataTypeVisitorTest: Updated to coverVariantTypein the type visitor test.InternalArrayAssert: AddedgetVariant()assertion support for test utilities.mvn compile -DskipTestsacross all modules (fluss-common, fluss-flink, fluss-spark, fluss-lake-paimon, fluss-lake-iceberg, fluss-lake-lance).API and Format
Variantinterface andGenericVariantclass influss-common.VARIANTadded toDataTypeRootandDataTypes.[4-byte value length (big-endian)][value bytes][metadata bytes]. TheVariant.variantToBytes()/Variant.bytesToVariant()methods handle the conversion, ensuring backward compatibility.BYTES/BinaryTypein Flink and Spark respectively (degraded mapping due to lack of native engine support), and to the corresponding binary types in lake formats.Documentation
website/docs/_configs/_partial_config.mdx: Auto-generated config documentation updated (unrelated config changes included in the regeneration).