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

fanng 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 c2d1b1ef9 [#4714] feat(paimon-spark-connector): Add tests for 
partitionManagement of paimon table in paimon spark connector (#5860)
c2d1b1ef9 is described below

commit c2d1b1ef9deff1e74bdb3a3f3c37f2b5a5c08a35
Author: cai can <94670132+caica...@users.noreply.github.com>
AuthorDate: Wed Dec 25 15:49:32 2024 +0800

    [#4714] feat(paimon-spark-connector): Add tests for partitionManagement of 
paimon table in paimon spark connector (#5860)
    
    ### What changes were proposed in this pull request?
    
    Add tests for partitionManagement of paimon table in paimon spark
    connector
    
    ### Why are the changes needed?
    
    Fix: https://github.com/apache/gravitino/issues/4714
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    New ITs.
    
    ---------
    
    Co-authored-by: caican <cai...@xiaomi.com>
---
 .../test/paimon/SparkPaimonCatalogIT.java          | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git 
a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/paimon/SparkPaimonCatalogIT.java
 
b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/paimon/SparkPaimonCatalogIT.java
index c77a4642e..9d0364828 100644
--- 
a/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/paimon/SparkPaimonCatalogIT.java
+++ 
b/spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/integration/test/paimon/SparkPaimonCatalogIT.java
@@ -104,6 +104,37 @@ public abstract class SparkPaimonCatalogIT extends 
SparkCommonIT {
     checkDirExists(partitionPath);
   }
 
+  @Test
+  void testPaimonPartitionManagement() {
+    testPaimonListAndDropPartition();
+    // TODO: replace, add and load partition operations are unsupported now.
+  }
+
+  private void testPaimonListAndDropPartition() {
+    String tableName = "test_paimon_drop_partition";
+    dropTableIfExists(tableName);
+    String createTableSQL = getCreatePaimonSimpleTableString(tableName);
+    createTableSQL = createTableSQL + " PARTITIONED BY (name);";
+    sql(createTableSQL);
+
+    String insertData =
+        String.format(
+            "INSERT into %s values(1,'a','beijing'), (2,'b','beijing'), 
(3,'c','beijing');",
+            tableName);
+    sql(insertData);
+    List<String> queryResult = getTableData(tableName);
+    Assertions.assertEquals(3, queryResult.size());
+
+    List<String> partitions = getQueryData(String.format("show partitions %s", 
tableName));
+    Assertions.assertEquals(3, partitions.size());
+    Assertions.assertEquals("name=a;name=b;name=c", String.join(";", 
partitions));
+
+    sql(String.format("ALTER TABLE %s DROP PARTITION (`name`='a')", 
tableName));
+    partitions = getQueryData(String.format("show partitions %s", tableName));
+    Assertions.assertEquals(2, partitions.size());
+    Assertions.assertEquals("name=b;name=c", String.join(";", partitions));
+  }
+
   private String getCreatePaimonSimpleTableString(String tableName) {
     return String.format(
         "CREATE TABLE %s (id INT COMMENT 'id comment', name STRING COMMENT '', 
address STRING COMMENT '') USING paimon",

Reply via email to