prashantwason commented on code in PR #18181:
URL: https://github.com/apache/hudi/pull/18181#discussion_r2913380702


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/table/HoodieSparkTable.java:
##########
@@ -114,14 +110,9 @@ protected Option<HoodieTableMetadataWriter> 
getMetadataWriter(
       HoodieTableMetadataWriter metadataWriter = streamingWrites
           ? 
SparkMetadataWriterFactory.createWithStreamingWrites(getContext().getStorageConf(),
 config, failedWritesCleaningPolicy, getContext(), 
Option.of(triggeringInstantTimestamp))
           : SparkMetadataWriterFactory.create(getContext().getStorageConf(), 
config, failedWritesCleaningPolicy, getContext(), 
Option.of(triggeringInstantTimestamp), metaClient.getTableConfig());
-      try {
-        if (isMetadataTableExists || metaClient.getStorage().exists(
-            
HoodieTableMetadata.getMetadataTableBasePath(metaClient.getBasePath()))) {
-          isMetadataTableExists = true;
-          return Option.of(metadataWriter);
-        }
-      } catch (IOException e) {
-        throw new HoodieMetadataException("Checking existence of metadata 
table failed", e);
+      if (isMetadataTableExists || metadataWriter.isInitialized()) {

Review Comment:
   Updated the logic in the latest commit. The writer is now only created for a 
disabled MDT when `auto.delete.partitions` is also disabled. When auto-delete 
is enabled (default), the existing turn-off behavior is preserved — the writer 
is not created and `maybeDeleteMetadataTable()` cleans up the MDT. This fixes 
the CI failures in `testTurnOffMetadataTableAfterEnable` and 
`testTurnOffMetadataIndexAfterEnable`.
   
   The condition is now:
   ```java
   if (config.isMetadataTableEnabled()
       || (getMetaClient().getTableConfig().isMetadataTableAvailable() && 
!config.isAutoDeleteMdtPartitionsEnabled()))
   ```



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