voonhous commented on code in PR #18837:
URL: https://github.com/apache/hudi/pull/18837#discussion_r3340114606


##########
hudi-trino-plugin/src/main/java/io/trino/plugin/hudi/HudiSplitSource.java:
##########
@@ -104,9 +104,24 @@ public HudiSplitSource(
             HoodieTableMetaClient metaClient = tableHandle.getMetaClient();
             HoodieEngineContext engineContext = new 
HoodieLocalEngineContext(metaClient.getStorage().getConf());
 
-            HoodieTableMetadata tableMetadata = HoodieTableMetadata.create(
-                    engineContext,
-                    tableHandle.getMetaClient().getStorage(), metadataConfig, 
metaClient.getBasePath().toString(), true);
+            HoodieTableMetadata tableMetadata;
+            if (enableMetadataTable) {
+                HoodieBackedTableMetadata mdt = new HoodieBackedTableMetadata(
+                        engineContext, metaClient.getStorage(), 
metadataConfig, metaClient.getBasePath().toString(), true);
+                if (mdt.isMetadataTableInitialized()) {
+                    tableMetadata = mdt;
+                }
+                else {
+                    log.warn("Metadata table not initialized on disk for %s; 
falling back to FileSystemBackedTableMetadata",
+                            tableHandle.getSchemaTableName());

Review Comment:
   Now routed through `NativeTableMetadataFactory` in 
9454f87c8de698bb11b02b8c675def5ddb2c2dc0. On the not-initialized path there is 
effectively nothing to leak: `HoodieBackedTableMetadata`'s constructor 
(`initIfNeeded`) leaves `metadataFileSystemView` null and opens reader caches 
lazily (only on first read, which never happens since we fall back), so 
`close()` is a near no-op here. The factory follows the same pattern (it also 
discards the MDT without closing), so this is no behavior change; centralizing 
it means any future close fix in the factory is inherited automatically.



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