morrySnow commented on code in PR #51928:
URL: https://github.com/apache/doris/pull/51928#discussion_r2166298453
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ScalarSubquery.java:
##########
@@ -122,13 +129,38 @@ public ScalarSubquery withSubquery(LogicalPlan subquery) {
}
/**
- * for correlated subquery, we define top level scalar agg as if it meets
the both 2 conditions:
- * 1. The agg or its child contains correlated slots
+ * get query plan output slot, adjust it to
+ * 1. true(no adjust), when it has top agg, and the agg function is
NotNullableAggregateFunction
+ * for example: `t1.a = (select count(t2.x) from t2)`, count(t2.x) is
always not null, even if t2 contain 0 row
+ * 2. false, otherwise.
+ * for example: `t1.a = (select t2.y from t2 limit 1)`, even if t2.y
is not nullable, but if t2 contain 0 row,
+ * the sub query t2 output is still null.
+ */
+ public Slot getOutputSlotAdjustNullable() {
+ Slot output = queryPlan.getOutput().get(0);
+ boolean nullable = true;
+ Optional<NamedExpression> aggOpt = getTopLevelScalarAggFunction();
Review Comment:
could this be lazy memorize to avoid compute multi times?
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ScalarSubquery.java:
##########
@@ -122,13 +129,38 @@ public ScalarSubquery withSubquery(LogicalPlan subquery) {
}
/**
- * for correlated subquery, we define top level scalar agg as if it meets
the both 2 conditions:
- * 1. The agg or its child contains correlated slots
+ * get query plan output slot, adjust it to
+ * 1. true(no adjust), when it has top agg, and the agg function is
NotNullableAggregateFunction
+ * for example: `t1.a = (select count(t2.x) from t2)`, count(t2.x) is
always not null, even if t2 contain 0 row
+ * 2. false, otherwise.
+ * for example: `t1.a = (select t2.y from t2 limit 1)`, even if t2.y
is not nullable, but if t2 contain 0 row,
+ * the sub query t2 output is still null.
+ */
+ public Slot getOutputSlotAdjustNullable() {
Review Comment:
add some fe ut to cover these functions
--
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]