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


##########
hudi-trino/src/main/java/io/trino/plugin/hudi/HudiMetadata.java:
##########
@@ -166,8 +165,9 @@ public HudiTableHandle getTableHandle(ConnectorSession 
session, SchemaTableName
         String inputFormat = 
table.getStorage().getStorageFormat().getInputFormat();
         HoodieTableType hoodieTableType = 
HudiTableTypeUtils.fromInputFormat(inputFormat);
         Lazy<HoodieTableMetaClient> lazyMetaClient = Lazy.lazily(() -> 
buildTableMetaClient(fileSystem, tableName.toString(), basePath));
-        Optional<Lazy<HoodieSchema>> hudiTableSchema = 
isResolveColumnNameCasingEnabled(session) ?
-                Optional.of(Lazy.lazily(() -> 
getLatestTableSchema(lazyMetaClient.get(), tableName.getTableName()))) : 
Optional.empty();
+        // Always carried in the handle (tableSchemaStr), so workers merge 
with the schema the planner resolved instead
+        // of resolving it again per split
+        Lazy<HoodieSchema> hudiTableSchema = Lazy.lazily(() -> 
getLatestTableSchema(lazyMetaClient.get(), tableName.getTableName()));

Review Comment:
   The new lazy schema is not reused by `getMergeRequiredColumnHandles`, whose 
CUSTOM branch still constructs another `TableSchemaResolver`, so a 
custom-merger scan resolves it twice on the coordinator. Pass `hudiTableSchema` 
into that helper and use it for `getMandatoryFieldsForMerging`.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiNoCacheFileOperations.java:
##########
@@ -80,6 +82,8 @@ public void testSelectWithFilter()
                         .addCopies(new 
FileOperationUtils.FileOperation("InputFile.newStream", INDEX_DEFINITION), 2)
                         .add(new 
FileOperationUtils.FileOperation("InputFile.newStream", 
METADATA_TABLE_PROPERTIES))
                         .addCopies(new 
FileOperationUtils.FileOperation("InputFile.newStream", TABLE_PROPERTIES), 2)
+                        .add(new 
FileOperationUtils.FileOperation("InputFile.newStream", LOG))

Review Comment:
   These cases only query the unsuffixed read-optimized table, so they do not 
exercise the merge-path worker fallback this PR is meant to remove. Add a 
realtime multi-split case that verifies worker reads reuse `tableSchemaStr` 
rather than resolving the schema per split.



##########
hudi-trino/src/main/java/io/trino/plugin/hudi/HudiMetadata.java:
##########
@@ -182,7 +182,7 @@ public HudiTableHandle getTableHandle(ConnectorSession 
session, SchemaTableName
                 TupleDomain.all(),
                 TupleDomain.all(),
                 OptionalLong.empty(),
-                hudiTableSchema);
+                Optional.of(hudiTableSchema));

Review Comment:
   With casing resolution disabled, legacy log-derived schemas with invalid 
defaults now go through `HudiTableHandle.buildTableSchema`, whose validating 
parser rejects schemas that `HoodieLogBlock.getSchemaFromHeader` deliberately 
accepts. Use `HoodieSchema.parse(tableSchemaStr, false)` for the worker-side 
parse and add a round-trip test for that legacy case.



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