[fix](unique key) agg_function is NONE when properties is null (#21337)

This commit is contained in:
zhannngchen
2023-06-29 20:47:13 +08:00
committed by GitHub
parent 6259a91d12
commit c7286c620b
2 changed files with 22 additions and 1 deletions

View File

@ -411,7 +411,7 @@ public class CreateTableStmt extends DdlStmt {
PropertyAnalyzer.ENABLE_UNIQUE_KEY_MERGE_ON_WRITE + " property only support unique key table");
}
if (keysDesc.getKeysType() == KeysType.UNIQUE_KEYS) {
enableUniqueKeyMergeOnWrite = true;
enableUniqueKeyMergeOnWrite = false;
if (properties != null) {
// `analyzeXXX` would modify `properties`, which will be used later,
// so we just clone a properties map here.

View File

@ -147,6 +147,27 @@ public class CreateTableStmtTest {
cols.remove(col4);
}
@Test
public void testCreateTableUniqueKeyNoProperties() throws UserException {
// setup
ColumnDef col3 = new ColumnDef("col3", new TypeDef(ScalarType.createType(PrimitiveType.BIGINT)));
col3.setIsKey(false);
cols.add(col3);
ColumnDef col4 = new ColumnDef("col4", new TypeDef(ScalarType.createType(PrimitiveType.STRING)));
col4.setIsKey(false);
cols.add(col4);
// test normal case
CreateTableStmt stmt = new CreateTableStmt(false, false, tblName, cols, "olap",
new KeysDesc(KeysType.UNIQUE_KEYS, colsName), null,
new HashDistributionDesc(10, Lists.newArrayList("col1")), null, null, "");
stmt.analyze(analyzer);
Assert.assertEquals(col3.getAggregateType(), AggregateType.REPLACE);
Assert.assertEquals(col4.getAggregateType(), AggregateType.REPLACE);
// clear
cols.remove(col3);
cols.remove(col4);
}
@Test
public void testCreateTableUniqueKeyMoW() throws UserException {
// setup