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

dataroaring pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new d9970be2c2a [Fix](Json type) forbit schema change adding JSON columns 
with none null default value (#33686) (#33805)
d9970be2c2a is described below

commit d9970be2c2aa8819f33084067daec9f35d176094
Author: lihangyu <15605149...@163.com>
AuthorDate: Thu Apr 18 09:50:35 2024 +0800

    [Fix](Json type) forbit schema change adding JSON columns with none null 
default value (#33686) (#33805)
---
 .../src/main/java/org/apache/doris/analysis/ColumnDef.java   | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
index fa18cd4c455..7457afe12ce 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
@@ -389,9 +389,15 @@ public class ColumnDef {
                     + "].");
         }
 
-        if (isKey() && type.getPrimitiveType() == PrimitiveType.JSONB) {
-            throw new AnalysisException("JSONB type should not be used in key 
column[" + getName()
-                    + "].");
+        if (type.getPrimitiveType() == PrimitiveType.JSONB
+                || type.getPrimitiveType() == PrimitiveType.VARIANT) {
+            if (isKey()) {
+                throw new AnalysisException("JSONB or VARIANT type should not 
be used in key column[" + getName()
+                        + "].");
+            }
+            if (defaultValue.isSet && defaultValue != 
DefaultValue.NULL_DEFAULT_VALUE) {
+                throw new AnalysisException("JSONB or VARIANT type column 
default value just support null");
+            }
         }
 
         if (type.getPrimitiveType() == PrimitiveType.MAP) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to