voonhous commented on code in PR #17833:
URL: https://github.com/apache/hudi/pull/17833#discussion_r2889791854
##########
hudi-common/src/test/java/org/apache/hudi/common/schema/TestHoodieSchema.java:
##########
@@ -1179,11 +1179,11 @@ public void
testCreateShreddedVariantWithoutTypedValue() {
// Verify fields should have metadata and nullable value, but no
typed_value
List<HoodieSchemaField> fields = variantSchema.getFields();
assertEquals(2, fields.size());
- assertEquals("metadata", fields.get(0).name());
- assertEquals("value", fields.get(1).name());
+ assertEquals("value", fields.get(0).name());
Review Comment:
```
Test Table with Variant Data Type *** FAILED ***
org.apache.spark.SparkRuntimeException: [MALFORMED_VARIANT] Variant binary
is malformed. Please check the data source is valid. SQLSTATE: 22023
at
org.apache.spark.types.variant.VariantUtil.malformedVariant(VariantUtil.java:179)
at org.apache.spark.types.variant.Variant.<init>(Variant.java:62)
at org.apache.spark.types.variant.Variant.<init>(Variant.java:53)
at
org.apache.spark.sql.catalyst.expressions.variant.VariantGet$.cast(variantExpressions.scala:410)
at
org.apache.spark.sql.catalyst.expressions.variant.VariantGet.cast(variantExpressions.scala)
at
org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.processNext(Unknown
Source)
at
org.apache.spark.sql.execution.BufferedRowIterator.hasNext(BufferedRowIterator.java:43)
at
org.apache.spark.sql.execution.WholeStageCodegenEvaluatorFactory$WholeStageCodegenPartitionEvaluator$$anon$1.hasNext(WholeStageCodegenEvaluatorFactory.scala:50)
at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
```
I was getting this error. The fix was that the schema needs to be in the
same order as spark's `VariantVal` constructor:
```java
public org.apache.spark.unsafe.types.VariantVal(byte[] value, byte[]
metadata) {
this.value = value;
this.metadata = metadata;
}
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]