You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by lz...@apache.org on 2023/08/28 04:12:34 UTC

[incubator-paimon] branch master updated (913f3c365 -> c8b4772f3)

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

lzljs3620320 pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git


    from 913f3c365 [flink] Remove the duplicate parts of the test case (#1894)
     new 578c4085a [spark] Add test for truncate table
     new c8b4772f3 [doc] Document Spark truncate table

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/content/how-to/writing-tables.md                   | 17 +++++++++++++----
 .../java/org/apache/paimon/spark/SparkWriteITCase.java  | 13 ++++++++++++-
 2 files changed, 25 insertions(+), 5 deletions(-)


[incubator-paimon] 01/02: [spark] Add test for truncate table

Posted by lz...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git

commit 578c4085ad8fb2a012c3f9cb092fe711f4a1e1b5
Author: waywtdcc <wa...@163.com>
AuthorDate: Tue Aug 1 13:49:05 2023 +0800

    [spark] Add test for truncate table
---
 .../test/java/org/apache/paimon/spark/SparkWriteITCase.java | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/paimon-spark/paimon-spark-common/src/test/java/org/apache/paimon/spark/SparkWriteITCase.java b/paimon-spark/paimon-spark-common/src/test/java/org/apache/paimon/spark/SparkWriteITCase.java
index bbe85c11b..999b28c1e 100644
--- a/paimon-spark/paimon-spark-common/src/test/java/org/apache/paimon/spark/SparkWriteITCase.java
+++ b/paimon-spark/paimon-spark-common/src/test/java/org/apache/paimon/spark/SparkWriteITCase.java
@@ -42,7 +42,7 @@ public class SparkWriteITCase {
 
     @BeforeAll
     public void startMetastoreAndSpark(@TempDir java.nio.file.Path tempDir) {
-        Path warehousePath = new Path("file:" + tempDir.toString());
+        Path warehousePath = new Path("file:///" + tempDir.toString());
         spark = SparkSession.builder().master("local[2]").getOrCreate();
         spark.conf().set("spark.sql.catalog.paimon", SparkCatalog.class.getName());
         spark.conf().set("spark.sql.catalog.paimon.warehouse", warehousePath.toString());
@@ -119,6 +119,17 @@ public class SparkWriteITCase {
         assertThat(rows.toString()).isEqualTo("[[2,22,222]]");
     }
 
+    @Test
+    public void testTruncateTable() {
+        spark.sql(
+                "CREATE TABLE T (a INT, b INT, c STRING) TBLPROPERTIES"
+                        + " ('primary-key'='a', 'file.format'='avro')");
+        spark.sql("INSERT INTO T VALUES (1, 11, '111'), (2, 22, '222')").collectAsList();
+        spark.sql("TRUNCATE TABLE T").collectAsList();
+        List<Row> rows = spark.sql("SELECT * FROM T").collectAsList();
+        assertThat(rows.toString()).isEqualTo("[]");
+    }
+
     @Test
     public void testWriteDynamicBucketPartitionedTable() {
         spark.sql(


[incubator-paimon] 02/02: [doc] Document Spark truncate table

Posted by lz...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git

commit c8b4772f3cb4b25b25537e1ab0775441c627bf1c
Author: Jingsong <ji...@gmail.com>
AuthorDate: Mon Aug 28 12:12:05 2023 +0800

    [doc] Document Spark truncate table
---
 docs/content/how-to/writing-tables.md | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/docs/content/how-to/writing-tables.md b/docs/content/how-to/writing-tables.md
index 12268e156..07c964261 100644
--- a/docs/content/how-to/writing-tables.md
+++ b/docs/content/how-to/writing-tables.md
@@ -224,20 +224,29 @@ INSERT OVERWRITE MyTable SELECT ...
 
 {{< /tabs >}}
 
-## Purging tables
+## Truncate tables
 
-You can use `INSERT OVERWRITE` to purge tables by inserting empty value.
-
-{{< tabs "purge-tables-syntax" >}}
+{{< tabs "truncate-tables-syntax" >}}
 
 {{< tab "Flink" >}}
 
+You can use `INSERT OVERWRITE` to purge tables by inserting empty value.
+
 ```sql
 INSERT OVERWRITE MyTable /*+ OPTIONS('dynamic-partition-overwrite'='false') */ SELECT * FROM MyTable WHERE false;
 ```
 
 {{< /tab >}}
 
+{{< tab "Spark" >}}
+
+```sql
+TRUNCATE TABLE MyTable;
+```
+
+{{< /tab >}}
+
+
 {{< /tabs >}}
 
 ## Purging Partitions