the-other-tim-brown commented on code in PR #17546:
URL: https://github.com/apache/hudi/pull/17546#discussion_r2607069709
##########
hudi-common/src/main/java/org/apache/hudi/common/schema/HoodieSchemaUtils.java:
##########
@@ -573,4 +574,89 @@ public static HoodieSchema getRecordKeySchema() {
return RECORD_KEY_SCHEMA;
}
+ /**
+ * Finds the schema of a nested field given a dot-separated field name.
+ * This is equivalent to {@link
AvroSchemaUtils#findNestedFieldSchema(Schema, String, boolean)} but operates on
HoodieSchema.
+ *
+ * <p>Unlike {@link #findNestedField(HoodieSchema, String)}, this method
returns just the schema
+ * of the leaf field (unwrapped from union if nullable), not the field with
its parent lineage.
+ *
+ * @param schema the schema to search in
+ * @param fieldName the dot-separated field name (e.g.,
"user.profile.name")
+ * @param allowsMissingField if true, returns Option.empty() when field is
not found;
+ * if false, throws HoodieSchemaException
+ * @return Option containing the schema of the nested field, or
Option.empty() if not found and allowsMissingField is true
+ * @throws HoodieSchemaException if field is not found and
allowsMissingField is false
+ * @since 1.2.0
+ */
+ public static Option<HoodieSchema> findNestedFieldSchema(HoodieSchema
schema, String fieldName, boolean allowsMissingField) {
Review Comment:
This can simply call `findNestedField` and then return the schema to reduce
the code duplication
--
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]