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

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


The following commit(s) were added to refs/heads/master by this push:
     new 5214e6b4bc8 [fix](Variant) check enable light_schema_change when 
create table with variant type (#40908)
5214e6b4bc8 is described below

commit 5214e6b4bc85d888e2de7ae1a290510f67961bfa
Author: lihangyu <[email protected]>
AuthorDate: Mon Sep 23 10:19:19 2024 +0800

    [fix](Variant) check enable light_schema_change when create table with 
variant type (#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 c3d7c74a615..36ea8ff80f9 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
@@ -2526,6 +2526,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 65a5a838c50..8f4b9a3cee5 100644
--- a/regression-test/suites/variant_p0/load.groovy
+++ b/regression-test/suites/variant_p0/load.groovy
@@ -446,6 +446,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