Skip to content

Commit e55d22e

Browse files
authored
[fix](array) disable ALTER TABLE add ARRAY column into AGG table (#52567)
While create AGG table with ARRAY column, we return an error: ``` > CREATE TABLE `test_v3` ( -> `id` varchar(16), -> `v_array` array<string> REPLACE_IF_NOT_NULL NULL -> ) ENGINE=OLAP -> AGGREGATE KEY(`id`) -> DISTRIBUTED BY HASH(`id`) BUCKETS 16 -> PROPERTIES ( -> "replication_allocation" = "tag.location.default: 1" -> ); ERROR 1105 (HY000): errCode = 2, detailMessage = Array column can't be used in aggregate table ``` But we can use ALTER command to add an ARRAY Column, this pr disable this case: ``` ALTER TABLE test_v2 ADD COLUMN v2 ARRAY<string> REPLACE_IF_NOT_NULL; ```
1 parent 353cb94 commit e55d22e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

fe/fe-common/src/main/java/org/apache/doris/common/Config.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,15 +1386,13 @@ public class Config extends ConfigBase {
13861386
/**
13871387
* Set the maximum number of rows that can be cached
13881388
*/
1389-
@ConfField(mutable = true, masterOnly = false, description = {"SQL/Partition Cache可以缓存的最大行数。",
1390-
"Maximum number of rows that can be cached in SQL/Partition Cache, is 3000 by default."})
1389+
@ConfField(mutable = true, masterOnly = false)
13911390
public static int cache_result_max_row_count = 3000;
13921391

13931392
/**
13941393
* Set the maximum data size that can be cached
13951394
*/
1396-
@ConfField(mutable = true, masterOnly = false, description = {"SQL/Partition Cache可以缓存的最大数据大小。",
1397-
"Maximum data size of rows that can be cached in SQL/Partition Cache, is 3000 by default."})
1395+
@ConfField(mutable = true, masterOnly = false)
13981396
public static int cache_result_max_data_size = 31457280; // 30M
13991397

14001398
/**

fe/fe-core/src/main/java/org/apache/doris/analysis/AddColumnClause.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,15 @@ public void analyze(Analyzer analyzer) throws AnalysisException, DdlException {
7373
if (columnDef == null) {
7474
throw new AnalysisException("No column definition in add column clause.");
7575
}
76+
boolean isAggKey = false;
7677
if (tableName != null) {
7778
Table table = Env.getCurrentInternalCatalog().getDbOrDdlException(tableName.getDb())
7879
.getTableOrDdlException(tableName.getTbl());
79-
if (table instanceof OlapTable && ((OlapTable) table).getKeysType() == KeysType.AGG_KEYS
80-
&& columnDef.getAggregateType() == null) {
81-
columnDef.setIsKey(true);
80+
if (table instanceof OlapTable && ((OlapTable) table).getKeysType() == KeysType.AGG_KEYS) {
81+
isAggKey = true;
82+
if (columnDef.getAggregateType() == null) {
83+
columnDef.setIsKey(true);
84+
}
8285
}
8386
}
8487
columnDef.analyze(true);
@@ -94,6 +97,10 @@ public void analyze(Analyzer analyzer) throws AnalysisException, DdlException {
9497
throw new AnalysisException("Cannot add value column[" + columnDef.getName() + "] at first");
9598
}
9699

100+
if (isAggKey && columnDef.getType().isArrayType()) {
101+
throw new AnalysisException("Array column can't be used in aggregate table");
102+
}
103+
97104
if (Strings.isNullOrEmpty(rollupName)) {
98105
rollupName = null;
99106
}

0 commit comments

Comments
 (0)