Skip to content

Commit 088d2fe

Browse files
authored
[Fix](ccr) Incorrectly generated sql with NONE aggregate type (#45452)
Execute: ``` alter table tbl enable feature "UPDATE_FLEXIBLE_COLUMNS"; ``` The generated SQL in binlog: ``` ALTER TABLE `t` ADD COLUMN `__DORIS_SKIP_BITMAP_COL__` bitmap NONE NOT NULL DEFAULT BITMAP_EMPTY COMMENT "doris skip bitmap hidden column" AFTER `__DORIS_VERSION_COL__` ``` The error message: ``` Error 1105 (HY000): errCode = 2, detailMessage = mismatched input 'NONE' expecting {<EOF>, ';'}(line 1, pos 62) ```
1 parent 4ef95fa commit 088d2fe

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ public String toSql() {
658658
sb.append("`").append(name).append("` ");
659659
sb.append(typeDef.toSql()).append(" ");
660660

661-
if (aggregateType != null) {
661+
if (aggregateType != null && aggregateType != AggregateType.NONE) {
662662
sb.append(aggregateType.name()).append(" ");
663663
}
664664

fe/fe-core/src/test/java/org/apache/doris/analysis/ColumnDefTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class ColumnDefTest {
3838
private TypeDef stringCol;
3939
private TypeDef floatCol;
4040
private TypeDef booleanCol;
41+
private TypeDef bitmapCol;
4142
private ConnectContext ctx;
4243

4344
@Before
@@ -46,6 +47,7 @@ public void setUp() {
4647
stringCol = new TypeDef(ScalarType.createChar(10));
4748
floatCol = new TypeDef(ScalarType.createType(PrimitiveType.FLOAT));
4849
booleanCol = new TypeDef(ScalarType.createType(PrimitiveType.BOOLEAN));
50+
bitmapCol = new TypeDef(ScalarType.createType(PrimitiveType.BITMAP));
4951

5052
ctx = new ConnectContext();
5153
new MockUp<ConnectContext>() {
@@ -80,6 +82,12 @@ public void testNormal() throws AnalysisException {
8082
Assert.assertEquals("10", column.getDefaultValue());
8183
Assert.assertEquals(AggregateType.SUM, column.getAggregateType());
8284
Assert.assertEquals("`col` float SUM NOT NULL DEFAULT \"10\" COMMENT \"\"", column.toSql());
85+
86+
// agg none
87+
column = new ColumnDef("col", bitmapCol, false, AggregateType.NONE, false, DefaultValue.BITMAP_EMPTY_DEFAULT_VALUE, "");
88+
89+
Assert.assertEquals(AggregateType.NONE, column.getAggregateType());
90+
Assert.assertEquals("`col` bitmap NOT NULL DEFAULT BITMAP_EMPTY COMMENT \"\"", column.toSql());
8391
}
8492

8593
@Test

0 commit comments

Comments
 (0)