hudi-agent commented on code in PR #19502:
URL: https://github.com/apache/hudi/pull/19502#discussion_r3733080400


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##########
@@ -314,21 +315,42 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath: 
String,
               } else {
                 0
               }
-              val reader = HoodieFileGroupReader.builder()
-                .withReaderContext(readerContext)
-                .withHoodieTableMetaClient(metaClient)
-                .withLatestCommitTime(queryTimestamp)
-                .withBaseFileOption(fileSlice.getBaseFile)
-                .withLogFiles(fileSlice.getLogFiles)
-                .withPartitionPath(fileSlice.getPartitionPath)
-                .withDataSchema(dataSchema)
-                .withRequestedSchema(requestedSchema)
-                .withInternalSchemaOpt(internalSchemaOpt)
-                .withProps(props)
-                .withStart(file.start)
-                .withLength(baseFileLength)
-                .withShouldUseRecordPosition(shouldUseRecordPosition)
-                .build()
+              val reader: HoodieRecordReader[InternalRow] =

Review Comment:
   🤖 nit: same near-identical builder chain duplicated across both branches 
(only the reader class and `withShouldUseRecordPosition` differ) — worth 
extracting the shared config so the two paths can't drift apart.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieMergeOnReadRDDV2.scala:
##########
@@ -191,18 +192,34 @@ class HoodieMergeOnReadRDDV2(@transient sc: SparkContext,
         } else {
           val readerContext = new 
SparkFileFormatInternalRowReaderContext(fileGroupBaseFileReader.value, 
optionalFilters,
             Seq.empty, storageConf, metaClient.getTableConfig)
-          val fileGroupReader = HoodieFileGroupReader.builder()
-            .withReaderContext(readerContext)
-            .withHoodieTableMetaClient(metaClient)
-            .withLatestCommitTime(tableState.latestCommitTimestamp.orNull)
-            .withLogFiles(logFiles.stream())
-            .withBaseFileOption(baseFileOption)
-            .withPartitionPath(partitionPath)
-            .withProps(properties)
-            .withDataSchema(tableSchema.schema)
-            .withRequestedSchema(requiredSchema.schema)
-            
.withInternalSchemaOpt(HOption.ofNullable(tableSchema.internalSchema.orNull))
-            .build()
+          val fileGroupReader: HoodieRecordReader[InternalRow] =

Review Comment:
   🤖 nit: the two builder chains are almost identical except for the reader 
class and `withShouldUseRecordPosition`. Could you factor the shared 
`.withReaderContext(...)...withInternalSchemaOpt(...)` configuration into a 
small helper (or select just the builder up front) to avoid the copy-paste?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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