hudi-agent commented on code in PR #18595:
URL: https://github.com/apache/hudi/pull/18595#discussion_r3143210124


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieWriteClient.java:
##########
@@ -1359,9 +1359,22 @@ protected void 
setWriteSchemaForDeletes(HoodieTableMetaClient metaClient) {
         if (!StringUtils.isNullOrEmpty(extraSchema)) {
           config.setSchema(commitMetadata.getExtraMetadata().get(SCHEMA_KEY));
         } else {
-          throw new HoodieIOException("Latest commit does not have any schema 
in commit metadata");
+          Option<Schema> tableCreateSchema = 
metaClient.getTableConfig().getTableCreateSchema();
+          if (tableCreateSchema.isPresent()) {
+            LOG.warn("Schema not found in commit metadata, using table create 
schema");
+            config.setSchema(tableCreateSchema.get().toString());
+          } else {
+            throw new HoodieIOException("Latest commit does not have any 
schema in commit metadata and table create schema is not available");
+          }
         }
       } else {
+        Option<Schema> tableCreateSchema = 
metaClient.getTableConfig().getTableCreateSchema();
+        if (tableCreateSchema.isPresent()) {
+          LOG.warn("No commit history found, using table create schema for 
delete operation");
+          config.setSchema(tableCreateSchema.get().toString());
+        } else {
+          LOG.warn("None rows are deleted because the table is empty and no 
schema available");
+        }
         LOG.debug("No rows are deleted because the table is empty");

Review Comment:
   🤖 This PR's title is about fixing the delete-from-twice-on-empty-table 
exception, but the only change to `setWriteSchemaForDeletes` is now this added 
`LOG.debug` line — the previous `tableCreateSchema` fallback has been dropped. 
Was the fallback removed because master's 
`TableSchemaResolver.getTableSchemaIfPresent(false)` (from PR #18030) already 
covers #18330? If yes, can you confirm the original repro no longer fails on 
master and consider closing this PR? If not, the actual fix seems to be missing 
now.
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieWriteClient.java:
##########
@@ -1359,9 +1359,22 @@ protected void 
setWriteSchemaForDeletes(HoodieTableMetaClient metaClient) {
         if (!StringUtils.isNullOrEmpty(extraSchema)) {
           config.setSchema(commitMetadata.getExtraMetadata().get(SCHEMA_KEY));
         } else {
-          throw new HoodieIOException("Latest commit does not have any schema 
in commit metadata");
+          Option<Schema> tableCreateSchema = 
metaClient.getTableConfig().getTableCreateSchema();
+          if (tableCreateSchema.isPresent()) {
+            LOG.warn("Schema not found in commit metadata, using table create 
schema");
+            config.setSchema(tableCreateSchema.get().toString());
+          } else {
+            throw new HoodieIOException("Latest commit does not have any 
schema in commit metadata and table create schema is not available");
+          }
         }
       } else {
+        Option<Schema> tableCreateSchema = 
metaClient.getTableConfig().getTableCreateSchema();
+        if (tableCreateSchema.isPresent()) {
+          LOG.warn("No commit history found, using table create schema for 
delete operation");
+          config.setSchema(tableCreateSchema.get().toString());
+        } else {
+          LOG.warn("None rows are deleted because the table is empty and no 
schema available");
+        }
         LOG.debug("No rows are deleted because the table is empty");

Review Comment:
   🤖 The added log line `LOG.debug("No rows are deleted because the table is 
empty")` sits outside the inner if/else and fires regardless of whether the 
schema was found, which makes the message misleading — if the schema was 
successfully resolved from the latest commit, rows *will* be deleted. Could you 
remove this line or move it into the appropriate branch?
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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