You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by bl...@apache.org on 2022/12/16 20:34:37 UTC

[iceberg] branch master updated: Docs: Add an example of Spark SQL to set identifier fields (#6444)

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

blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new 6dc6308cc6 Docs: Add an example of Spark SQL to set identifier fields (#6444)
6dc6308cc6 is described below

commit 6dc6308cc6ba0f189b83cba889ee7134e56ec002
Author: Kunni <ku...@dtstack.com>
AuthorDate: Sat Dec 17 04:34:31 2022 +0800

    Docs: Add an example of Spark SQL to set identifier fields (#6444)
---
 docs/spark-ddl.md | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/docs/spark-ddl.md b/docs/spark-ddl.md
index d5e89b332b..6347ae5481 100644
--- a/docs/spark-ddl.md
+++ b/docs/spark-ddl.md
@@ -446,3 +446,29 @@ ALTER TABLE prod.db.sample WRITE DISTRIBUTED BY PARTITION
 ```sql
 ALTER TABLE prod.db.sample WRITE DISTRIBUTED BY PARTITION LOCALLY ORDERED BY category, id
 ```
+
+### `ALTER TABLE ... SET IDENTIFIER FIELDS`
+
+Iceberg supports setting identifier fields to a spec using `SET IDENTIFIER FIELDS`:
+
+```sql
+ALTER TABLE prod.db.sample SET IDENTIFIER FIELDS id
+-- single column
+ALTER TABLE prod.db.sample SET IDENTIFIER FIELDS id, data
+-- multiple columns
+```
+
+identifier fields must be `NOT NULL`, The later `ALTER` statement will overwrite the previous setting.
+
+### `ALTER TABLE ... DROP IDENTIFIER FIELDS`
+
+Identifier fields can be removed using `DROP IDENTIFIER FIELDS`:
+
+```sql
+ALTER TABLE prod.db.sample DROP IDENTIFIER FIELDS id
+-- single column
+ALTER TABLE prod.db.sample DROP IDENTIFIER FIELDS id, data
+-- multiple columns
+```
+
+Note that although the identifier is removed, the column will still exist in the table schema.
\ No newline at end of file