xiangfu0 commented on code in PR #19988:
URL: https://github.com/apache/pinot/pull/19988#discussion_r4406722820
##########
pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/rules/PinotRuleUtils.java:
##########
@@ -85,6 +89,47 @@ public static RelNode unboxRel(RelNode rel) {
}
}
+ /// Appends literal arguments in one project, retaining a union column as a
literal only when every branch projects
+ /// that same literal. Branch-specific constants remain input references.
+ public static RelNode appendAggregateLiterals(RelNode input, List<RexNode>
literals) {
+ RelNode rel = unboxRel(input);
+ if (rel instanceof Project) {
+ Project project = (Project) rel;
+ List<RexNode> projects = new ArrayList<>(project.getProjects());
+ projects.addAll(literals);
+ return LogicalProject.create(project.getInput(), project.getHints(),
projects, (List<String>) null, Set.of());
+ }
+ RexBuilder rexBuilder = input.getCluster().getRexBuilder();
+ List<RexNode> projects = new
ArrayList<>(input.getRowType().getFieldCount() + literals.size());
+ for (int i = 0; i < input.getRowType().getFieldCount(); i++) {
+ RexLiteral literal = rel instanceof Union ? commonLiteral(rel, i) : null;
Review Comment:
Fixed in 66ef0e0b78: removed commonLiteral substitution so UNION columns
remain input references; added constant-time FIRST_WITH_TIME and
constant-operand COVARPOP/MODE runtime regressions and narrowed tests that
relied on literal inlining. Runtime resource suite and all 657 plan cases pass.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
##########
pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java:
##########
@@ -1242,6 +1242,10 @@ private static Expression toExpression(SqlNode node) {
private static Expression compileFunctionExpression(SqlBasicCall
functionNode) {
SqlKind functionKind = functionNode.getKind();
+ if (functionKind == SqlKind.ARRAY_AGG &&
functionNode.getFunctionQuantifier() != null
+ && "DISTINCT".equals(functionNode.getFunctionQuantifier().toString()))
{
+ throw new SqlCompilationException("Function 'ARRAY_AGG' on DISTINCT is
not supported.");
Review Comment:
Fixed in 66ef0e0b78: SSE translates ARRAY_AGG DISTINCT into isDistinct=true,
appending or replacing the flag. Optimizer and optimized-query tests cover
inferred, explicit-type, true and false forms; star-tree tests pass.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
##########
pinot-query-runtime/src/test/resources/queries/UDFAggregates.json:
##########
@@ -45,6 +45,12 @@
}
},
"queries": [
+ {"sql": "SELECT CARDINALITY(ARRAY_AGG(x)), DISTINCTCOUNT(x), COVARPOP(x,
y) FROM (SELECT int_col x, 1.0 y FROM {tbl} UNION ALL SELECT int_col,
CAST(long_col AS DOUBLE) FROM {tbl})", "outputs": [[14, 6, 2339.918367346939]]},
+ {"sql": "SELECT MODE(CASE WHEN int_col > 3 THEN string_col END) FROM
{tbl}", "outputs": [["c"]]},
Review Comment:
Fixed in 66ef0e0b78: both MODE CASE queries now explicitly set
enableNullHandling=false and still return c in v1, v2 and lite mode.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]