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 ceccc895247ba1..8f37f73a82be5e 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 @@ private boolean createOlapTable(Database db, CreateTableStmt stmt) throws UserEx // 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 161b8ce0ca5645..0618785a70087e 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 }