suryaprasanna commented on code in PR #17505:
URL: https://github.com/apache/hudi/pull/17505#discussion_r2739039371


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/utils/SparkValidatorUtils.java:
##########
@@ -146,14 +149,37 @@ public static Dataset<Row> 
getRecordsFromCommittedFiles(SQLContext sqlContext,
             sqlContext.emptyDataFrame().rdd(), newStructTypeSchema);
       }
     }
-    return readRecordsForBaseFiles(sqlContext, committedFiles);
+    return readRecordsForBaseFiles(sqlContext, committedFiles, table);
   }
 
   /**
    * Get records from specified list of data files.
    */
-  public static Dataset<Row> readRecordsForBaseFiles(SQLContext sqlContext, 
List<String> baseFilePaths) {
-    return 
sqlContext.read().parquet(JavaScalaConverters.convertJavaListToScalaSeq(baseFilePaths));
+  public static Dataset<Row> readRecordsForBaseFiles(SQLContext sqlContext, 
List<String> baseFilePaths,
+      HoodieTable table) {
+    final HoodieSchema readerSchema;
+    String schemaStr = table.getConfig().getWriteSchema();
+    boolean isPopulateMetaFieldsEnabled = 
table.getConfig().populateMetaFields();
+    if (!StringUtils.isNullOrEmpty(schemaStr)) {
+      Schema schema = new 
Schema.Parser().parse(table.getConfig().getWriteSchema());
+      readerSchema = HoodieSchema.fromAvroSchema(
+          isPopulateMetaFieldsEnabled ? 
HoodieAvroUtils.addMetadataFields(schema) : schema);
+    } else {
+      LOG.warn("Schema not found from write config, defaulting to parsing 
schema from latest commit.");
+      try {
+        readerSchema = new 
TableSchemaResolver(table.getMetaClient()).getTableSchema();
+      } catch (Exception e) {
+        LOG.error(String.format("Failed parsing schema from latest commit with 
exception %s, "

Review Comment:
   Done.



-- 
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