From ce2e84e9a6c45633f484d7ca8ab30cf8feb6750e Mon Sep 17 00:00:00 2001 From: starocean999 <40539150+starocean999@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:37:30 +0800 Subject: [PATCH] [fix](nereids)need validate auto partition columns in DDL (#29985) --- .../plans/commands/info/CreateTableInfo.java | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java index f47a693d25..a1a5dd9836 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java @@ -139,7 +139,6 @@ public class CreateTableInfo { this.autoPartitionExprs = autoPartitionExprs; this.partitionType = partitionType; this.partitionColumns = partitionColumns; - appendColumnFromExprs(); this.partitions = partitions; this.distribution = distribution; this.rollups = Utils.copyRequiredList(rollups); @@ -175,7 +174,6 @@ public class CreateTableInfo { this.autoPartitionExprs = autoPartitionExprs; this.partitionType = partitionType; this.partitionColumns = partitionColumns; - appendColumnFromExprs(); this.partitions = partitions; this.distribution = distribution; this.rollups = Utils.copyRequiredList(rollups); @@ -459,6 +457,12 @@ public class CreateTableInfo { } }); + if (isAutoPartition) { + partitionColumns = ExpressionUtils + .collectAll(autoPartitionExprs, UnboundSlot.class::isInstance).stream() + .map(slot -> ((UnboundSlot) slot).getName()).collect(Collectors.toList()); + } + if (partitionColumns != null) { partitionColumns.forEach(p -> { if (!columnMap.containsKey(p)) { @@ -636,7 +640,7 @@ public class CreateTableInfo { throw new AnalysisException("odbc, mysql and broker table is no longer supported." + " For odbc and mysql external table, use jdbc table or jdbc catalog instead." + " For broker table, use table valued function instead." - + ". Or you can temporarily set 'disable_odbc_mysql_broker_table=false'" + + ". Or you can temporarily set 'enable_odbc_mysql_broker_table=true'" + " in fe.conf to reopen this feature."); } } @@ -796,11 +800,6 @@ public class CreateTableInfo { * translate to catalog create table stmt */ public CreateTableStmt translateToLegacyStmt() { - if (isAutoPartition) { - partitionColumns = ExpressionUtils - .collectAll(autoPartitionExprs, UnboundSlot.class::isInstance).stream() - .map(slot -> ((UnboundSlot) slot).getName()).collect(Collectors.toList()); - } PartitionDesc partitionDesc = null; if (partitionColumns != null || isAutoPartition) { List partitionDescs = @@ -894,14 +893,4 @@ public class CreateTableInfo { } }).collect(Collectors.toList()); } - - private void appendColumnFromExprs() { - for (Expression autoExpr : autoPartitionExprs) { - for (Expression child : autoExpr.children()) { - if (child instanceof UnboundSlot) { - partitionColumns.add(((UnboundSlot) child).getName()); - } - } - } - } }