[fix](cluster key) forbid cluster key and remove case (#39679)

branch-2.1 does not support mow cluster key
This commit is contained in:
meiyi
2024-08-21 14:31:54 +08:00
committed by GitHub
parent ba3b56d269
commit 1460878bdf
143 changed files with 23 additions and 5157 deletions

View File

@ -412,9 +412,8 @@ public class CreateTableStmt extends DdlStmt {
}
keysDesc.analyze(columnDefs);
if (!CollectionUtils.isEmpty(keysDesc.getClusterKeysColumnNames()) && !enableUniqueKeyMergeOnWrite) {
throw new AnalysisException("Cluster keys only support unique keys table which enabled "
+ PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE);
if (!CollectionUtils.isEmpty(keysDesc.getClusterKeysColumnNames())) {
throw new AnalysisException("Cluster key is not supported");
}
for (int i = 0; i < keysDesc.keysColumnSize(); ++i) {
columnDefs.get(i).setIsKey(true);

View File

@ -90,11 +90,7 @@ public class KeysDesc implements Writable {
}
if (clusterKeysColumnNames != null) {
if (type != KeysType.UNIQUE_KEYS) {
throw new AnalysisException("Cluster keys only support unique keys table.");
}
clusterKeysColumnIds = Lists.newArrayList();
analyzeClusterKeys(cols);
throw new AnalysisException("Cluster key is not supported");
}
for (int i = 0; i < keysColumnNames.size(); ++i) {

View File

@ -393,10 +393,8 @@ public class CreateTableInfo {
}
validateKeyColumns();
if (!clusterKeysColumnNames.isEmpty() && !isEnableMergeOnWrite) {
throw new AnalysisException(
"Cluster keys only support unique keys table which enabled "
+ PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE);
if (!clusterKeysColumnNames.isEmpty()) {
throw new AnalysisException("Cluster key is not supported");
}
for (int i = 0; i < keys.size(); ++i) {
columns.get(i).setIsKey(true);
@ -690,44 +688,7 @@ public class CreateTableInfo {
}
if (!clusterKeysColumnNames.isEmpty()) {
if (keysType != KeysType.UNIQUE_KEYS) {
throw new AnalysisException("Cluster keys only support unique keys table.");
}
clusterKeysColumnIds = Lists.newArrayList();
for (int i = 0; i < clusterKeysColumnNames.size(); ++i) {
String name = clusterKeysColumnNames.get(i);
// check if key is duplicate
for (int j = 0; j < i; j++) {
if (clusterKeysColumnNames.get(j).equalsIgnoreCase(name)) {
throw new AnalysisException("Duplicate cluster key column[" + name + "].");
}
}
// check if key exists and generate key column ids
for (int j = 0; j < columns.size(); j++) {
if (columns.get(j).getName().equalsIgnoreCase(name)) {
columns.get(j).setClusterKeyId(clusterKeysColumnIds.size());
clusterKeysColumnIds.add(j);
break;
}
if (j == columns.size() - 1) {
throw new AnalysisException(
"Key cluster column[" + name + "] doesn't exist.");
}
}
}
int minKeySize = keys.size() < clusterKeysColumnNames.size() ? keys.size()
: clusterKeysColumnNames.size();
boolean sameKey = true;
for (int i = 0; i < minKeySize; ++i) {
if (!keys.get(i).equalsIgnoreCase(clusterKeysColumnNames.get(i))) {
sameKey = false;
break;
}
}
if (sameKey) {
throw new AnalysisException("Unique keys and cluster keys should be different.");
}
throw new AnalysisException("Cluster key is not supported");
}
for (int i = 0; i < keys.size(); ++i) {