rdblue commented on code in PR #13219: URL: https://github.com/apache/iceberg/pull/13219#discussion_r2229427028
########## spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetWriters.java: ########## @@ -555,6 +575,44 @@ public Map.Entry<K, V> next() { } } + /** Variant writer converts from VariantVal to Variant */ + public static class VariantWriter implements ParquetValueWriter<VariantVal> { + private final ParquetValueWriter<Variant> writer; + private final List<TripleWriter<?>> children; + + protected VariantWriter(ParquetValueWriter<?> writer) { + this.writer = (ParquetValueWriter<Variant>) writer; + this.children = writer.columns(); + } + + @Override + public void write(int repetitionLevel, VariantVal variantVal) { + VariantMetadata metadata = + VariantMetadata.from( + ByteBuffer.wrap(variantVal.getMetadata()).order(ByteOrder.LITTLE_ENDIAN)); + VariantValue value = + VariantValue.from( + metadata, ByteBuffer.wrap(variantVal.getValue()).order(ByteOrder.LITTLE_ENDIAN)); + + writer.write(repetitionLevel, Variant.of(metadata, value)); + } + + @Override + public List<TripleWriter<?>> columns() { + return children; Review Comment: Why keep `children` and only use it here? This could also delegate to `writer` like the other methods: `return writer.children()`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org