hudi-agent commented on code in PR #18540:
URL: https://github.com/apache/hudi/pull/18540#discussion_r3134442775
##########
hudi-client/hudi-spark-client/src/main/scala/org/apache/spark/sql/avro/HoodieSparkSchemaConverters.scala:
##########
@@ -363,6 +385,31 @@ object HoodieSparkSchemaConverters extends
SparkAdapterSupport {
}
}
+ private def matchesStructure(source: DataType, expected: DataType,
caseSensitive: Boolean): Boolean =
+ (source, expected) match {
+ case (s: StructType, e: StructType) =>
+ s.length == e.length && s.fields.zip(e.fields).forall { case (sf, ef)
=>
+ nameEquals(sf.name, ef.name, caseSensitive) &&
+ matchesStructure(sf.dataType, ef.dataType, caseSensitive)
+ }
+ case _ => source == expected
+ }
+
+ private def nameEquals(a: String, b: String, caseSensitive: Boolean):
Boolean =
+ if (caseSensitive) a == b else a.equalsIgnoreCase(b)
+
+ private def withAllFieldsNullable(dataType: DataType): DataType = dataType
match {
Review Comment:
🤖 nit: `withAllFieldsNullable` implies it only touches struct fields, but
the method also sets `containsNull = true` on arrays and `valueContainsNull =
true` on maps — a future reader scanning the name alone might not expect those
side effects. Something like `makeFullyNullable` or `forceNullable` would
describe the full scope more accurately.
<sub><i>- Generated by an AI agent and may contain mistakes. Please verify
any suggestions before applying.</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]