[Fix](nereids) Add semantic check that the hash bucket column must be a key column when creating table for aggregate and unique models (#31951)

This commit is contained in:
feiniaofeiafei
2024-03-08 16:32:32 +08:00
committed by yiguolei
parent cae80cfa15
commit 5909237ab1
6 changed files with 79 additions and 6 deletions

View File

@ -82,6 +82,13 @@ public class DistributionDescriptor {
throw new AnalysisException(String.format("Distribution column(%s) doesn't exist", c));
}
});
for (String columnName : cols) {
ColumnDefinition columnDefinition = columnMap.get(columnName);
if (!columnDefinition.isKey()
&& (keysType == KeysType.UNIQUE_KEYS || keysType == KeysType.AGG_KEYS)) {
throw new AnalysisException("Distribution column[" + columnName + "] is not key column");
}
}
} else {
if (keysType.equals(KeysType.UNIQUE_KEYS)) {
throw new AnalysisException("Create unique keys table should not contain random distribution desc");