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

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


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 76d62c42dba [pick](Variant) check enable light_schema_change when 
create table with variant type (#41102)
76d62c42dba is described below

commit 76d62c42dba793857c842abf152379ccd698cbb7
Author: lihangyu <[email protected]>
AuthorDate: Mon Sep 23 14:30:16 2024 +0800

    [pick](Variant) check enable light_schema_change when create table with 
variant type (#41102)
    
    #40908
---
 .../org/apache/doris/datasource/InternalCatalog.java     | 10 ++++++++++
 regression-test/suites/variant_p0/load.groovy            | 16 ++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
index ceccc895247..8f37f73a82b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
@@ -2358,6 +2358,16 @@ public class InternalCatalog implements 
CatalogIf<Database> {
         // use light schema change optimization
         olapTable.setEnableLightSchemaChange(enableLightSchemaChange);
 
+        // check if light schema change is disabled, variant type rely on 
light schema change
+        if (!enableLightSchemaChange) {
+            for (Column column : baseSchema) {
+                if (column.getType().isVariantType()) {
+                    throw new DdlException("Variant type rely on light schema 
change, "
+                            + " please use light_schema_change = true.");
+                }
+            }
+        }
+
         boolean disableAutoCompaction = false;
         try {
             disableAutoCompaction = 
PropertyAnalyzer.analyzeDisableAutoCompaction(properties);
diff --git a/regression-test/suites/variant_p0/load.groovy 
b/regression-test/suites/variant_p0/load.groovy
index 161b8ce0ca5..0618785a700 100644
--- a/regression-test/suites/variant_p0/load.groovy
+++ b/regression-test/suites/variant_p0/load.groovy
@@ -431,6 +431,22 @@ suite("regression_test_variant", "p0"){
             exception("Invalid type for variant column: 36")
         }
 
+         test {
+            sql """
+            create table var(
+                `key` int,
+                `content` variant
+            )
+            DUPLICATE KEY(`key`)
+            distributed by hash(`key`) buckets 8
+            properties(
+              "replication_allocation" = "tag.location.default: 1",
+              "light_schema_change" = "false"
+            );
+            """
+            exception("errCode = 2, detailMessage = Variant type rely on light 
schema change")
+        }
+
     } finally {
         // reset flags
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to