Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

branch-2.1: [Fix](ccr) Incorrectly generated sql with NONE aggregate type #45452 #45489

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading