This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new c055956599 [fix](planner)fix bug of push constant conjuncts through 
set operation node (#22696)
c055956599 is described below

commit c055956599fc65cd342aa2883e0c95f8a92c499e
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Tue Aug 8 11:02:43 2023 +0800

    [fix](planner)fix bug of push constant conjuncts through set operation node 
(#22696)
    
    pick from master #22695
    
    when pushing down constant conjunct into set operation node, we should 
assign the conjunct to agg node if there is one. This is consistant with 
pushing constant conjunct into inlineview. This prevent the lost of the 
constant conjuncts
---
 .../java/org/apache/doris/planner/SingleNodePlanner.java    | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
index 738b7fd823..5d59df3a8a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
@@ -2336,7 +2336,18 @@ public class SingleNodePlanner {
                 // Forbid to register Conjuncts with SelectStmt' tuple when 
Select is constant
                 if ((queryStmt instanceof SelectStmt) && selectHasTableRef) {
                     final SelectStmt select = (SelectStmt) queryStmt;
-                    op.getAnalyzer().registerConjuncts(opConjuncts, 
select.getTableRefIds());
+                    // if there is an agg node, we need register the constant 
conjuncts on agg node's tuple
+                    // this is consistent with migrateConstantConjuncts()
+                    if (select.getAggInfo() != null) {
+                        Map<Boolean, List<Expr>> splittedConjuncts = 
opConjuncts.stream()
+                                .collect(Collectors.partitioningBy(expr -> 
expr.isConstant()));
+                        
op.getAnalyzer().registerConjuncts(splittedConjuncts.get(true),
+                                
select.getAggInfo().getOutputTupleId().asList());
+                        
op.getAnalyzer().registerConjuncts(splittedConjuncts.get(false),
+                                select.getTableRefIds());
+                    } else {
+                        op.getAnalyzer().registerConjuncts(opConjuncts, 
select.getTableRefIds());
+                    }
                 } else if (queryStmt instanceof SetOperationStmt) {
                     final SetOperationStmt subSetOp = (SetOperationStmt) 
queryStmt;
                     op.getAnalyzer().registerConjuncts(opConjuncts, 
subSetOp.getTupleId().asList());


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to