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/05/29 05:51:26 UTC
[incubator-paimon] branch master updated: [docs] add docs: how to insert into a non-null column with nullable column (#1252)
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
The following commit(s) were added to refs/heads/master by this push:
new 8d5f5a7a8 [docs] add docs: how to insert into a non-null column with nullable column (#1252)
8d5f5a7a8 is described below
commit 8d5f5a7a8d65425f35644b0126b56416dbbde564
Author: YeJunHao <41...@users.noreply.github.com>
AuthorDate: Mon May 29 13:51:22 2023 +0800
[docs] add docs: how to insert into a non-null column with nullable column (#1252)
---
docs/content/how-to/writing-tables.md | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/docs/content/how-to/writing-tables.md b/docs/content/how-to/writing-tables.md
index 7262d2ca0..476d71b2e 100644
--- a/docs/content/how-to/writing-tables.md
+++ b/docs/content/how-to/writing-tables.md
@@ -86,6 +86,24 @@ commits of `OVERWRITE`, you can configure `streaming-read-overwrite`.
deletes the partitions appear in the overwrite data). You can configure `dynamic-partition-overwrite` to change it.
{{< /hint >}}
+{{< hint warning >}}
+Warning: We cannot insert into a non-null column of one table with a nullable column of another table. Assume that,
+we have a column key1 in table A which is primary key, primary key cannot be null. We have a column key2 in table B,
+which is nullable. If we run a sql like this:
+``` sql
+INSERT INTO A key1 SELECT key2 FROM B
+```
+We will catch a exception,
+- In spark: "Cannot write nullable values to non-null column 'key1'."
+- In flink: "Column 'key1' is NOT NULL, however, a null value is being written into it. "
+
+Other engines will throw respective exception to announce this. We can use function "NVL" or "COALESCE" to work around,
+turn a nullable column into a non-null column to escape exception:
+```sql
+INSERT INTO A key1 SELECT COALESCE(key2, <non-null expression>) FROM B
+```
+{{< /hint >}}
+
## Applying Records/Changes to Tables
{{< tabs "insert-into-example" >}}