[Chore](rollup) check duplicate column name when create table with rollup (#34827)

check duplicate column name when create table with rollup
This commit is contained in:
Pxl
2024-05-15 10:25:22 +08:00
committed by yiguolei
parent 1e53a2a81d
commit 4a8df53553
4 changed files with 41 additions and 2 deletions

View File

@ -459,6 +459,10 @@ public class CreateTableInfo {
}
}
}
for (RollupDefinition rollup : rollups) {
rollup.validate();
}
} else {
// mysql, broker and hive do not need key desc
if (keysType != null) {

View File

@ -18,12 +18,15 @@
package org.apache.doris.nereids.trees.plans.commands.info;
import org.apache.doris.analysis.AddRollupClause;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.util.Utils;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* rollup definition
@ -41,7 +44,16 @@ public class RollupDefinition {
this.properties = Maps.newHashMap(properties);
}
public void validate() {
/**
* check rollup validity
*/
public void validate() throws AnalysisException {
Set<String> colSet = Sets.newHashSet();
for (String col : cols) {
if (!colSet.add(col)) {
throw new AnalysisException("rollup has duplicate column name " + col);
}
}
}
public AddRollupClause translateToCatalogStyle() {