Skip to content

Commit

Permalink
[fix](Variant) check enable light_schema_change when create table wit…
Browse files Browse the repository at this point in the history
…h variant type (apache#40908)
  • Loading branch information
eldenmoon authored Sep 23, 2024
1 parent 8140401 commit 5214e6b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2526,6 +2526,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);
Expand Down
16 changes: 16 additions & 0 deletions regression-test/suites/variant_p0/load.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 5214e6b

Please sign in to comment.