[BugFix] Fix array type analyze (backport #63371) (#63506)

Signed-off-by: Seaven <seaven_7@qq.com>
Co-authored-by: Seaven <seaven_7@qq.com>
This commit is contained in:
mergify[bot] 2025-09-24 18:31:12 +08:00 committed by GitHub
parent 5ce9b16626
commit c5ebf3e063
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -127,6 +127,7 @@ import com.starrocks.server.LocalMetastore;
import com.starrocks.server.RunMode;
import com.starrocks.server.WarehouseManager;
import com.starrocks.service.FrontendOptions;
import com.starrocks.sql.analyzer.AnalyzerUtils;
import com.starrocks.sql.analyzer.DecimalV3FunctionAnalyzer;
import com.starrocks.sql.analyzer.SemanticException;
import com.starrocks.sql.ast.AssertNumRowsElement;
@ -2190,6 +2191,7 @@ public class PlanFragmentBuilder {
AggregateFunction aggrFn = (AggregateFunction) aggExpr.getFn();
Type intermediateType = aggrFn.getIntermediateType() != null ?
aggrFn.getIntermediateType() : aggrFn.getReturnType();
intermediateType = AnalyzerUtils.replaceNullType2Boolean(intermediateType);
intermediateSlotDesc.setType(intermediateType);
intermediateSlotDesc.setIsNullable(aggrFn.isNullable());
intermediateSlotDesc.setIsMaterialized(true);

View File

@ -850,4 +850,15 @@ public class ArrayTypeTest extends PlanTestBase {
assertThat(exception.getMessage(), containsString("Array function 'reverse' is not supported for" +
" DECIMAL256 type"));
}
@Test
public void testArrayNull() throws Exception {
String sql = "with test_cte as (\n"
+ " select array<varchar>[] as some_array\n"
+ ")\n"
+ "select array_agg(some_array)\n"
+ "from test_cte;";
String plan = getThriftPlan(sql);
assertContains(plan, "function_name:array_agg");
}
}