yihua commented on code in PR #8967:
URL: https://github.com/apache/hudi/pull/8967#discussion_r1230275601


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieWriteClient.java:
##########
@@ -1248,8 +1247,7 @@ protected void 
setWriteSchemaForDeletes(HoodieTableMetaClient metaClient) {
       if (lastInstant.isPresent()) {
         HoodieCommitMetadata commitMetadata = HoodieCommitMetadata.fromBytes(
             activeTimeline.getInstantDetails(lastInstant.get()).get(), 
HoodieCommitMetadata.class);
-        String extraSchema = commitMetadata.getExtraMetadata().get(SCHEMA_KEY);
-        if (!StringUtils.isNullOrEmpty(extraSchema)) {
+        if (commitMetadata.getExtraMetadata().containsKey(SCHEMA_KEY)) {

Review Comment:
   Right, let's not change the logic here.



##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestDeleteFromTable.scala:
##########
@@ -80,4 +82,36 @@ class TestDeleteFromTable extends HoodieSparkSqlTestBase {
       }
     })
   }
+
+  test("Test deleting from empty table") {
+    withRecordType()(withTempDir { tmp =>
+      Seq("cow", "mor").foreach { tableType =>
+        val tableName = generateTableName
+        spark.sql(
+          s"""
+             |CREATE TABLE $tableName (
+             |  id int,
+             |  dt string,
+             |  name string,
+             |  price double,
+             |  ts long
+             |) USING hudi
+             | tblproperties (
+             |    primaryKey = 'id',
+             |    tableType = '$tableType'
+             | )
+             | PARTITIONED BY (dt)
+             | LOCATION '${tmp.getCanonicalPath}'
+         """.stripMargin)
+
+
+        // Delete single row
+        spark.sql(s"DELETE FROM $tableName WHERE id = 1")

Review Comment:
   Agree.  @lvyanquan could you check why the schema is not added to the commit 
metadata for DELETE operation?



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