voonhous commented on code in PR #21095:
URL: https://github.com/apache/hudi/pull/21095#discussion_r4811649346
##########
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:
Done in 7ae316748a69. `getMergeRequiredColumnHandles` now takes the handle's
lazy schema and asks the merger against it, so a custom-merger scan resolves
the schema once.
##########
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:
Good catch. When commit metadata has no schema, `TableSchemaResolver` falls
back to `readSchemaFromLogFile`, which goes through the lenient header parse.
Workers now parse with `HoodieSchema.parse(tableSchemaStr, false)`
(7ae316748a69). `TestHudiTableHandle` round-trips a schema with an invalid
default (a string default on a long field). It fails with the validating parse.
##########
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:
Added `testRealtimeMergeSplitsReuseHandleSchema` (7ae316748a69). It queries
the `_rt` table of `HUDI_TIMESTAMP_KEYGEN_PT_EPOCH_TO_YYYY_MM_DD_HH_V8_MOR`,
which has several merge splits.
It pins 1 timeline read and 16 log reads. Without the change, the same query
read the timeline 5 times and log files 20 times.
--
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]