yihua commented on code in PR #17573:
URL: https://github.com/apache/hudi/pull/17573#discussion_r2633260231
##########
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:
Given that this is the delegation, it is OK for now.
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieMergeOnReadRDDV2.scala:
##########
@@ -193,8 +192,8 @@ class HoodieMergeOnReadRDDV2(@transient sc: SparkContext,
.withBaseFileOption(baseFileOption)
.withPartitionPath(partitionPath)
.withProps(properties)
- .withDataSchema(HoodieSchema.parse(tableSchema.avroSchemaStr))
-
.withRequestedSchema(HoodieSchema.parse(requiredSchema.avroSchemaStr))
+ .withDataSchema(tableSchema.tableSchema)
+ .withRequestedSchema(requiredSchema.tableSchema)
Review Comment:
Should this be renamed from `tableSchema` to `schema` since it's not always
table schema?
##########
hudi-common/src/main/java/org/apache/hudi/common/schema/HoodieSchemaUtils.java:
##########
@@ -582,6 +618,7 @@ public static HoodieSchema getRecordKeySchema() {
* @param fields list of fields to project
* @return projected schema containing only specified fields
*/
+
Review Comment:
@rahil-c Could you check this separately?
--
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]