Skip to content

Commit

Permalink
[Fix](ccr) Incorrectly generated sql with NONE aggregate type (#45452)
Browse files Browse the repository at this point in the history
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)
```
  • Loading branch information
wyxxxcat authored and w41ter committed Dec 23, 2024
1 parent 35bdd00 commit c479324
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public String toSql() {
sb.append("`").append(name).append("` ");
sb.append(typeDef.toSql()).append(" ");

if (aggregateType != null) {
if (aggregateType != null && aggregateType != AggregateType.NONE) {
sb.append(aggregateType.name()).append(" ");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class ColumnDefTest {
private TypeDef stringCol;
private TypeDef floatCol;
private TypeDef booleanCol;
private TypeDef bitmapCol;
private ConnectContext ctx;

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

ctx = new ConnectContext();
new MockUp<ConnectContext>() {
Expand Down Expand Up @@ -80,6 +82,12 @@ public void testNormal() throws AnalysisException {
Assert.assertEquals("10", column.getDefaultValue());
Assert.assertEquals(AggregateType.SUM, column.getAggregateType());
Assert.assertEquals("`col` float SUM NOT NULL DEFAULT \"10\" COMMENT \"\"", column.toSql());

// agg none
column = new ColumnDef("col", bitmapCol, false, AggregateType.NONE, false, DefaultValue.BITMAP_EMPTY_DEFAULT_VALUE, "");

Assert.assertEquals(AggregateType.NONE, column.getAggregateType());
Assert.assertEquals("`col` bitmap NOT NULL DEFAULT BITMAP_EMPTY COMMENT \"\"", column.toSql());
}

@Test
Expand Down

0 comments on commit c479324

Please sign in to comment.