yihua commented on code in PR #17772:
URL: https://github.com/apache/hudi/pull/17772#discussion_r2670883296


##########
hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/client/model/HoodieFlinkRecord.java:
##########
@@ -95,21 +95,21 @@ public HoodieRecord<RowData> newInstance(HoodieKey key) {
   }
 
   @Override
-  protected Comparable<?> doGetOrderingValue(Schema recordSchema, Properties 
props, String[] orderingFields) {
+  protected Comparable<?> doGetOrderingValue(HoodieSchema recordSchema, 
Properties props, String[] orderingFields) {
     if (orderingFields == null) {
       return OrderingValues.getDefault();
     } else {
       return OrderingValues.create(orderingFields, field -> {
         if (recordSchema.getField(field) == null) {

Review Comment:
   Also could you add unit tests to cover this method?



##########
hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/client/model/HoodieFlinkRecord.java:
##########
@@ -95,21 +95,21 @@ public HoodieRecord<RowData> newInstance(HoodieKey key) {
   }
 
   @Override
-  protected Comparable<?> doGetOrderingValue(Schema recordSchema, Properties 
props, String[] orderingFields) {
+  protected Comparable<?> doGetOrderingValue(HoodieSchema recordSchema, 
Properties props, String[] orderingFields) {
     if (orderingFields == null) {
       return OrderingValues.getDefault();
     } else {
       return OrderingValues.create(orderingFields, field -> {
         if (recordSchema.getField(field) == null) {

Review Comment:
   Four places to check in `HoodieFlinkRecord`
   ```
   doGetOrderingValue(HoodieSchema, Properties, String[])
           if (recordSchema.getField(field) == null) {
   getOrderingValueAsJava(HoodieSchema, Properties, String[])
           if (recordSchema.getField(field) == null) {
   getRecordKey(HoodieSchema, Option<BaseKeyGenerator>)
         
ValidationUtils.checkArgument(recordSchema.getField(RECORD_KEY_METADATA_FIELD) 
!= null,
   updateMetaField(HoodieSchema, int, String)
       boolean withOperation = recordSchema.getField(OPERATION_METADATA_FIELD) 
!= null;
   ```



##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/common/model/HoodieSparkRecord.java:
##########
@@ -365,7 +361,7 @@ protected Comparable<?> doGetOrderingValue(Schema 
recordSchema, Properties props
   }
 
   @Override
-  public Comparable<?> getOrderingValueAsJava(Schema recordSchema, Properties 
props, String[] orderingFields) {
+  public Comparable<?> getOrderingValueAsJava(HoodieSchema recordSchema, 
Properties props, String[] orderingFields) {

Review Comment:
   Same on `if (recordSchema.getField(field) == null) {` to avoid `null` check



##########
hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/client/model/HoodieFlinkRecord.java:
##########
@@ -139,9 +139,9 @@ public String getRecordKey(Schema recordSchema, 
Option<BaseKeyGenerator> keyGene
   }
 
   @Override
-  public String getRecordKey(Schema recordSchema, String keyFieldName) {
+  public String getRecordKey(HoodieSchema recordSchema, String keyFieldName) {
     if (key == null) {
-      String recordKey = 
Objects.toString(RowDataAvroQueryContexts.fromAvroSchema(recordSchema).getFieldQueryContext(keyFieldName).getFieldGetter().getFieldOrNull(data));
+      String recordKey = 
Objects.toString(RowDataAvroQueryContexts.fromAvroSchema(recordSchema.toAvroSchema()).getFieldQueryContext(keyFieldName).getFieldGetter().getFieldOrNull(data));

Review Comment:
   Is `RowDataAvroQueryContexts` going to be migrated away from Avro schema 
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]

Reply via email to