hudi-agent commented on code in PR #20326:
URL: https://github.com/apache/hudi/pull/20326#discussion_r4272737369


##########
hudi-spark-datasource/hudi-spark4-common/src/main/java/org/apache/hudi/variant/Spark4VariantShreddingProvider.java:
##########
@@ -176,7 +176,16 @@ private VariantSchema buildVariantSchema(Schema 
avroSchema, boolean isTopLevel,
           break;
 
         default:
-          // Scalar shredding
+          // Scalar shredding. On write (non-null builder), reject leaf types 
Spark 4 cannot shred,
+          // as SparkShreddingUtils.buildVariantSchema does with 
invalidVariantShreddingSchema.
+          if (builder != null && !isSparkShreddableScalar(tvSchema)) {
+            LogicalType logicalType = tvSchema.getLogicalType();
+            String typeName = tvSchema.getType().getName()
+                + (logicalType == null ? "" : " (" + logicalType.getName() + 
")");
+            throw new HoodieException("Variant shredding schema has a 
typed_value of type " + typeName

Review Comment:
   🤖 nit: could you move the supported-types list into a constant next to 
`isSparkShreddableScalar`, so the message and the switch are less likely to 
drift apart?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



-- 
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]

Reply via email to