This is an automated email from the ASF dual-hosted git repository.

yuqi4733 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 00be7761dd [#8381]Improvement(OceanbaseTableOperations):   empty SQL 
statements should not stop all SQL statements in alterTable (#8456)
00be7761dd is described below

commit 00be7761dd653af6226b6546bff1a92a8e364035
Author: Sambhavi Pandey <[email protected]>
AuthorDate: Thu Sep 25 09:16:46 2025 +0530

    [#8381]Improvement(OceanbaseTableOperations):   empty SQL statements should 
not stop all SQL statements in alterTable (#8456)
    
    ### What changes were proposed in this pull request?
    Use of continue instead of return in alterTable method so that empty SQL
    statements no longer stop processing subsequent changes.
    
    ### Why are the changes needed?
    empty SQL statements no longer stop processing subsequent changes in
    alterTable method
    
    
    Fix: #8381
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    Unit testing
    
    ---------
    
    Co-authored-by: Sambhavi Pandey <[email protected]>
    Co-authored-by: Sambhavi Pandey <[email protected]>
---
 .../operation/OceanBaseTableOperations.java        |  2 +-
 .../operation/TestOceanBaseTableOperations.java    | 33 ++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git 
a/catalogs/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/operation/OceanBaseTableOperations.java
 
b/catalogs/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/operation/OceanBaseTableOperations.java
index f37c1cdfc1..697308dda2 100644
--- 
a/catalogs/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/operation/OceanBaseTableOperations.java
+++ 
b/catalogs/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/operation/OceanBaseTableOperations.java
@@ -217,7 +217,7 @@ public class OceanBaseTableOperations extends 
JdbcTableOperations {
         String sql = generateAlterTableSql(databaseName, tableName, change);
         if (StringUtils.isEmpty(sql)) {
           LOG.info("No changes to alter table {} from database {}", tableName, 
databaseName);
-          return;
+          continue;
         }
         JdbcConnectorUtils.executeUpdate(connection, sql);
       }
diff --git 
a/catalogs/catalog-jdbc-oceanbase/src/test/java/org/apache/gravitino/catalog/oceanbase/operation/TestOceanBaseTableOperations.java
 
b/catalogs/catalog-jdbc-oceanbase/src/test/java/org/apache/gravitino/catalog/oceanbase/operation/TestOceanBaseTableOperations.java
index 0427aea095..cedcabe038 100644
--- 
a/catalogs/catalog-jdbc-oceanbase/src/test/java/org/apache/gravitino/catalog/oceanbase/operation/TestOceanBaseTableOperations.java
+++ 
b/catalogs/catalog-jdbc-oceanbase/src/test/java/org/apache/gravitino/catalog/oceanbase/operation/TestOceanBaseTableOperations.java
@@ -1133,4 +1133,37 @@ public class TestOceanBaseTableOperations extends 
TestOceanBase {
         operationsWithOceanBaseDriver.calculateDatetimePrecision("TIME", 10, 
0),
         "TIME type should return precision for OceanBase driver");
   }
+
+  @Test
+  public void testAlterTableSkipsEmptySql() {
+    String tableName = RandomStringUtils.randomAlphabetic(16).toLowerCase() + 
"_skip_empty_sql";
+    List<JdbcColumn> columns = new ArrayList<>();
+    columns.add(
+        JdbcColumn.builder()
+            .withName("col_1")
+            .withType(Types.IntegerType.get())
+            .withNullable(false)
+            .build());
+
+    // Create table
+    TABLE_OPERATIONS.create(
+        TEST_DB_NAME,
+        tableName,
+        columns.toArray(new JdbcColumn[0]),
+        "test_table",
+        Collections.emptyMap(),
+        null,
+        Distributions.NONE,
+        Indexes.EMPTY_INDEXES);
+
+    // Alter table with one valid change and one empty SQL change
+    TableChange validChange =
+        TableChange.updateColumnComment(new String[] {"col_1"}, "Updated 
comment");
+    TableChange emptyChange = TableChange.deleteColumn(new String[] 
{"non_existent_col"}, true);
+    Assertions.assertDoesNotThrow(
+        () -> TABLE_OPERATIONS.alterTable(TEST_DB_NAME, tableName, 
emptyChange, validChange));
+    // Verify the valid change was applied
+    JdbcTable table = TABLE_OPERATIONS.load(TEST_DB_NAME, tableName);
+    Assertions.assertEquals("Updated comment", table.columns()[0].comment());
+  }
 }

Reply via email to