voonhous commented on code in PR #18540:
URL: https://github.com/apache/hudi/pull/18540#discussion_r3143820891
##########
hudi-client/hudi-spark-client/src/main/scala/org/apache/spark/sql/avro/HoodieSparkSchemaConverters.scala:
##########
@@ -278,10 +282,22 @@ object HoodieSparkSchemaConverters extends
SparkAdapterSupport {
metadataBuilder.putString(HoodieSchema.TYPE_METADATA_FIELD,
HoodieSchema.Blob.TYPE_DESCRIPTOR)
}
val metadata = metadataBuilder.build()
- StructField(f.name(), schemaType.dataType, schemaType.nullable,
metadata)
+ // For BLOB: force nullable-everywhere at the Spark type layer. The
RFC-100
+ // canonical schema declares `type`, `reference.external_path`, and
+ // `reference.managed` as strictly non-null, but that contract is
conditional
+ // ("required when parent is present") and Spark's type system can't
model it.
+ // Projecting BLOB as nullable-everywhere for Spark avoids
downstream pain
+ // (Cast / TableOutputResolver / Cast.canCast rewrites); the on-disk
physical
+ // schema stays RFC-100 compliant because the write path goes through
+ // HoodieSchema.Blob.createBlob(), which uses the canonical fields
verbatim.
+ if (isBlob) {
+ StructField(f.name(), withAllFieldsNullable(schemaType.dataType),
nullable = true, metadata)
Review Comment:
Your example should fail during the write stage IIUC as the write side
`create_blob` by Hoodie schema will see a TYPE as null as invalid. i.e. writer
side will fail.
Followup task with more details on why this is written this way: #18601
--
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]