Commit 23fe7bf
authored
feat(variant): Add support to write shredded variants for HoodieRecordType.AVRO (apache#18065)
Adds write support for shredded Variant on the AVRO record path. Variants are
decomposed into a typed_value column for better compression and column pruning.
Shredding is delegated to a VariantShreddingProvider (in hudi-common, loaded
reflectively), with a Spark 4 implementation built on Spark's
VariantShreddingWriter.
- Config: new advanced hoodie.parquet.variant.shredding.provider.class
(sinceVersion 1.3.0), auto-detected from the classpath when unset. Gated by
the existing write.shredding.enabled; reads governed by allow.reading.shredded.
- Write path: HoodieAvroFileWriterFactory builds the Parquet schema from the
effective (shredded) schema so value is nullable and typed_value is present;
injects the provider on a copied Properties so the shared config is never
mutated. Fails fast when shredding is required but no provider is available,
and on the not-yet-supported read-then-reshred path (apache#18931).
- Spark read: BaseSpark4Adapter recognizes both unshredded (2-field) and
shredded (3-field) physical layouts as Variant. Spark 4.0.x keeps a reorder
workaround for its hardcoded [value, metadata] converter; 4.1+ reads by name
(SPARK-54410), removable later (apache#18935). No session SQLConf mutation - Spark's
converter reads the flag via SQLConf.get.
- DDL parsing: shared StringUtils.splitTopLevelCommas (paren-aware) keeps
decimal(15, 1) intact, reused by both the shredding DDL parser and the vector
column metadata parser.
- Tests: Spark integration (TestVariantDataType) plus unit coverage for the
forced-shredding DDL (incl. decimal), shredded schema shape, the
read-then-reshred guard, and splitTopLevelCommas.
Limitations: shredded writes require Spark 4.0+; reading shredded data back
requires Spark 4.1+ (Spark 4.0 read deferred, apache#18931).
Closes apache#18066
Closes apache#177481 parent 5de762f commit 23fe7bf
13 files changed
Lines changed: 1290 additions & 46 deletions
File tree
- hudi-common/src/main/java/org/apache/hudi
- avro
- common
- config
- schema
- hudi-hadoop-common/src
- main/java/org/apache/hudi
- avro
- io/storage/hadoop
- test/java/org/apache/hudi
- avro
- io/hadoop
- hudi-io/src
- main/java/org/apache/hudi/common/util
- test/java/org/apache/hudi/common/util
- hudi-spark-datasource
- hudi-spark4-common/src/main
- java/org/apache/hudi/variant
- scala/org/apache/spark/sql/adapter
- hudi-spark4.0.x/src/main/scala/org/apache/spark/sql/execution/datasources/parquet
- hudi-spark/src/test/scala/org/apache/spark/sql/hudi/dml/schema
Lines changed: 66 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
Lines changed: 14 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
239 | 241 | | |
240 | 242 | | |
241 | | - | |
242 | | - | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
250 | 251 | | |
251 | 252 | | |
252 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
253 | 264 | | |
254 | 265 | | |
255 | 266 | | |
| |||
596 | 607 | | |
597 | 608 | | |
598 | 609 | | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | 610 | | |
605 | 611 | | |
606 | 612 | | |
| |||
Lines changed: 7 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
282 | 283 | | |
283 | 284 | | |
284 | 285 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | 286 | | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
300 | 293 | | |
301 | 294 | | |
302 | | - | |
303 | 295 | | |
304 | 296 | | |
305 | 297 | | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | 298 | | |
315 | 299 | | |
316 | 300 | | |
| |||
0 commit comments