rahil-c commented on code in PR #17573:
URL: https://github.com/apache/hudi/pull/17573#discussion_r2631515348
##########
hudi-common/src/main/java/org/apache/hudi/common/schema/HoodieSchemaUtils.java:
##########
@@ -307,6 +325,31 @@ public static HoodieSchemaField
createNewSchemaField(String name, HoodieSchema s
return HoodieSchemaField.fromAvroField(avroField);
}
+ /**
+ * Creates a new schema field with the specified properties, including field
order.
+ * This is equivalent to HoodieAvroUtils.createNewSchemaField() but returns
HoodieSchemaField.
+ *
+ * @param name field name
+ * @param schema field schema
+ * @param doc field documentation (can be null)
+ * @param defaultValue default value (can be null)
+ * @param order field order for sorting
+ * @return new HoodieSchemaField instance
+ * @throws IllegalArgumentException if name, schema, or order is null/empty
+ * @since 1.2.0
+ */
+ public static HoodieSchemaField createNewSchemaField(String name,
HoodieSchema schema,
+ String doc, Object
defaultValue, HoodieFieldOrder order) {
+ ValidationUtils.checkArgument(name != null && !name.isEmpty(), "Field name
cannot be null or empty");
+ ValidationUtils.checkArgument(schema != null, "Field schema cannot be
null");
+ ValidationUtils.checkArgument(order != null, "Field order cannot be null");
+
+ // Delegate to HoodieAvroUtils
+ Schema.Field avroField = HoodieAvroUtils.createNewSchemaField(
+ name, schema.toAvroSchema(), doc, defaultValue, order.toAvroOrder());
+ return HoodieSchemaField.fromAvroField(avroField);
+ }
Review Comment:
I think the only logic difference between the two methods is that one is
passing the order field and the other is not.
<img width="975" height="777" alt="Screenshot 2025-12-18 at 7 03 14 AM"
src="https://github.com/user-attachments/assets/99236898-8364-4885-9fa4-4242fca398c0"
/>, so im not sure if its a question of logic resuse. I think we should keep
this for now.
--
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]