diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java index ee34ff743f1e9a..e1d45d490eeb97 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java @@ -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(" "); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/ColumnDefTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/ColumnDefTest.java index 9649b8523d69ca..5ef11dc6a4f057 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/analysis/ColumnDefTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/ColumnDefTest.java @@ -38,6 +38,7 @@ public class ColumnDefTest { private TypeDef stringCol; private TypeDef floatCol; private TypeDef booleanCol; + private TypeDef bitmapCol; private ConnectContext ctx; @Before @@ -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() { @@ -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