wombatu-kun commented on code in PR #18375:
URL: https://github.com/apache/hudi/pull/18375#discussion_r3198647388


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieWriteConfig.java:
##########
@@ -3756,6 +3764,40 @@ protected void setDefaults() {
       autoAdjustConfigsForConcurrencyMode(isLockProviderPropertySet);
     }
 
+    /**
+     * When the table's base file format requires SPARK record type (e.g. 
Lance) but the user
+     * has not configured a Spark-compatible record merger, inject
+     * {@link #DEFAULT_SPARK_RECORD_MERGER_CLASS} into {@link 
HoodieWriteConfig#RECORD_MERGE_IMPL_CLASSES}.
+     *
+     * <p>The injection runs for every merge mode (not just {@link 
RecordMergeMode#CUSTOM}) because
+     * the Hudi write path resolves the engine-side record type from
+     * {@code config.getRecordMerger().getRecordType()} when picking a {@code 
HoodieFileWriter}.
+     * For Lance, that resolution must yield {@code SPARK}; otherwise the 
writer falls back to
+     * the AVRO path and writes throw
+     * {@code ClassCastException: SerializableIndexedRecord cannot be cast to 
InternalRow}.
+     * On the read side, {@code COMMIT_TIME} and {@code EVENT_TIME} hardcode 
their merger
+     * instances in {@code BaseSparkInternalRowReaderContext.getRecordMerger}, 
so the value
+     * populated here is harmless for those modes and only takes effect under 
{@code CUSTOM}.
+     */
+    private void autoSelectSparkRecordMergerForBaseFileFormat() {
+      HoodieFileFormat tableLevel = 
HoodieFileFormat.getValue(writeConfig.getString(HoodieTableConfig.BASE_FILE_FORMAT.key()));

Review Comment:
   Done in commit fd85491409dc — renamed `tableLevel` to `tableConfigFormat` so 
it's clear the value comes from `HoodieTableConfig.BASE_FILE_FORMAT` (paired 
with `format` as the resolved-with-fallback variable).



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