starocean999 commented on code in PR #57022:
URL: https://github.com/apache/doris/pull/57022#discussion_r2458429540
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/SubqueryToApply.java:
##########
@@ -398,76 +395,63 @@ private static boolean hasTopLevelScalarAgg(Plan plan) {
return false;
}
- private Pair<LogicalPlan, Optional<Expression>> addApply(SubqueryExpr
subquery,
- LogicalPlan childPlan,
+ private Pair<LogicalPlan, Optional<Expression>> addApply(SubqueryExpr
subquery, LogicalPlan childPlan,
Map<SubqueryExpr, Optional<MarkJoinSlotReference>>
subqueryToMarkJoinSlot,
- CascadesContext ctx, Optional<Expression> conjunct, boolean
isProject,
- boolean singleSubquery, boolean isMarkJoinSlotNotNull) {
+ CascadesContext ctx, Optional<Expression> correlatedOuterExpr,
boolean isMarkJoinSlotNotNull) {
ctx.setSubqueryExprIsAnalyzed(subquery, true);
Optional<MarkJoinSlotReference> markJoinSlot =
subqueryToMarkJoinSlot.get(subquery);
- boolean needAddScalarSubqueryOutputToProjects =
isConjunctContainsScalarSubqueryOutput(
- subquery, conjunct, isProject, singleSubquery);
+
+ boolean needAddScalarSubqueryOutputToProjects =
isScalarSubqueryOutputUsedInOuterScope(
+ subquery, correlatedOuterExpr);
boolean needRuntimeAssertCount = false;
- NamedExpression oldSubqueryOutput =
subquery.getQueryPlan().getOutput().get(0);
+ // In #50256, needRuntimeAssertCount has been replaced by
needRuntimeAnyValue
+ // for scalar subquery, we need ensure it output at most 1 row
+ // by doing that, we add an aggregate function any_value() to the
project list
+ // we use needRuntimeAnyValue to indicate if any_value() is needed
+ // if needRuntimeAnyValue is true, we will add it to the project list
+ // boolean needRuntimeAnyValue = false;
+ NamedExpression subqueryOutput =
subquery.getQueryPlan().getOutput().get(0);
+ // if (subquery instanceof ScalarSubquery) { // #51928
Review Comment:
remove these comment, and please check if need to pick
https://github.com/apache/doris/pull/51928 after this one is merged
--
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]