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

starocean999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new a8a4da9b9e [fix](nereids)dphyper join reorder may cache wrong project 
list for project node (#20209)
a8a4da9b9e is described below

commit a8a4da9b9e4772f0337cc1407a22373cb812678d
Author: starocean999 <[email protected]>
AuthorDate: Fri Jun 2 09:35:28 2023 +0800

    [fix](nereids)dphyper join reorder may cache wrong project list for project 
node (#20209)
    
    * [fix](nereids)dphyper join reorder may cache wrong project list for 
project node
---
 .../jobs/joinorder/hypergraph/HyperGraph.java      |   5 +
 .../hypergraph/receiver/PlanReceiver.java          | 147 ++++++++++++---------
 .../doris/nereids/trees/plans/algebra/Project.java |  24 +---
 .../org/apache/doris/nereids/types/DataType.java   |  37 ++++--
 .../org/apache/doris/nereids/util/PlanUtils.java   |  29 ++++
 .../doris/nereids/parser/NereidsParserTest.java    |  13 +-
 .../apache/doris/nereids/types/DataTypeTest.java   |   4 +-
 regression-test/data/cte_reuse/q23.out             |   2 +-
 regression-test/data/cte_reuse/q24.out             |   2 +-
 regression-test/data/cte_reuse/q31.out             |   4 +-
 .../nereids_p0/lateral_view/test_issue_8850.out    |  11 ++
 .../nereids_tpcds_shape_sf100_p0/shape/query75.out |   2 +-
 .../nereids_p0/lateral_view/test_issue_8850.sql    |   7 +
 13 files changed, 185 insertions(+), 102 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/HyperGraph.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/HyperGraph.java
index e906ab30e0..190b7a0d08 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/HyperGraph.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/HyperGraph.java
@@ -24,12 +24,15 @@ import org.apache.doris.nereids.trees.expressions.Alias;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.NamedExpression;
 import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
 import org.apache.doris.nereids.trees.plans.JoinHint;
 import org.apache.doris.nereids.trees.plans.JoinType;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+import org.apache.doris.nereids.util.PlanUtils;
 
 import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -96,6 +99,8 @@ public class HyperGraph {
         slotToNodeMap.put(aliasSlot, bitmap);
         if (!complexProject.containsKey(bitmap)) {
             complexProject.put(bitmap, new ArrayList<>());
+        } else if (!(alias.child() instanceof SlotReference)) {
+            alias = (Alias) 
PlanUtils.mergeProjections(complexProject.get(bitmap), 
Lists.newArrayList(alias)).get(0);
         }
         complexProject.get(bitmap).add(alias);
         return true;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/receiver/PlanReceiver.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/receiver/PlanReceiver.java
index 5f36971fd2..9436c10977 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/receiver/PlanReceiver.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/joinorder/hypergraph/receiver/PlanReceiver.java
@@ -47,6 +47,7 @@ import 
org.apache.doris.nereids.trees.plans.physical.PhysicalNestedLoopJoin;
 import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;
 import org.apache.doris.nereids.util.ExpressionUtils;
 import org.apache.doris.nereids.util.JoinUtils;
+import org.apache.doris.nereids.util.PlanUtils;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
@@ -67,7 +68,6 @@ public class PlanReceiver implements AbstractReceiver {
     // limit define the max number of csg-cmp pair in this Receiver
     HashMap<Long, Group> planTable = new HashMap<>();
     HashMap<Long, BitSet> usdEdges = new HashMap<>();
-    HashMap<Long, List<NamedExpression>> projectsOnSubgraph = new HashMap<>();
     HashMap<Long, List<NamedExpression>> complexProjectMap = new HashMap<>();
     int limit;
     int emitCount = 0;
@@ -138,27 +138,36 @@ public class PlanReceiver implements AbstractReceiver {
         return true;
     }
 
+    // be aware that the requiredOutputSlots is a superset of the actual 
output of current node
+    // check proposeProject method to get how to create a project node for the 
outputs of current node.
     private Set<Slot> calculateRequiredSlots(long left, long right, List<Edge> 
edges) {
-        Set<Slot> outputSlots = new HashSet<>(this.finalOutputs);
+        // required output slots = final outputs + slot of unused edges + 
complex project exprs(if there is any)
+        // 1. add finalOutputs to requiredOutputSlots
+        Set<Slot> requiredOutputSlots = new HashSet<>(this.finalOutputs);
         BitSet usedEdgesBitmap = new BitSet();
         usedEdgesBitmap.or(usdEdges.get(left));
         usedEdgesBitmap.or(usdEdges.get(right));
         for (Edge edge : edges) {
             usedEdgesBitmap.set(edge.getIndex());
         }
-        // required output slots = final outputs + slot of unused edges
+
+        // 2. add unused edges' input slots to requiredOutputSlots
         usdEdges.put(LongBitmap.newBitmapUnion(left, right), usedEdgesBitmap);
         for (Edge edge : hyperGraph.getEdges()) {
             if (!usedEdgesBitmap.get(edge.getIndex())) {
-                outputSlots.addAll(edge.getInputSlots());
+                requiredOutputSlots.addAll(edge.getInputSlots());
             }
         }
-        hyperGraph.getComplexProject()
-                .values()
-                .stream()
-                .flatMap(l -> l.stream())
-                .forEach(expr -> outputSlots.addAll(expr.getInputSlots()));
-        return outputSlots;
+
+        // 3. add input slots of all complex projects which should be done by 
all upper level (parents) nodes
+        // dphyper enumerate subsets before supersets, so all subsets' complex 
projects should be excluded here
+        // because it's been processed by subsets already
+        long fullKey = LongBitmap.newBitmapUnion(left, right);
+        hyperGraph.getComplexProject().entrySet().stream()
+                .filter(l -> !LongBitmap.isSubset(l.getKey(), fullKey))
+                .flatMap(l -> l.getValue().stream())
+                .forEach(expr -> 
requiredOutputSlots.addAll(expr.getInputSlots()));
+        return requiredOutputSlots;
     }
 
     // add any missed edge into edges to connect left and right
@@ -184,14 +193,6 @@ public class PlanReceiver implements AbstractReceiver {
         }
     }
 
-    private long getAllReferenceNodes(BitSet edgesBitmap) {
-        long nodes = LongBitmap.newBitmap();
-        for (int i = edgesBitmap.nextSetBit(0); i >= 0; i = 
edgesBitmap.nextSetBit(i + 1)) {
-            nodes = LongBitmap.or(nodes, 
hyperGraph.getEdge(i).getReferenceNodes());
-        }
-        return nodes;
-    }
-
     private void proposeAllDistributedPlans(GroupExpression groupExpression) {
         jobContext.getCascadesContext().pushJob(new 
CostAndEnforcerJob(groupExpression,
                 new JobContext(jobContext.getCascadesContext(), 
PhysicalProperties.ANY, Double.MAX_VALUE)));
@@ -275,12 +276,10 @@ public class PlanReceiver implements AbstractReceiver {
 
     @Override
     public void reset() {
-        Preconditions.checkArgument(complexProjectMap.isEmpty(),
-                "complexProjectMap should be empty when call reset()");
+        emitCount = 0;
         planTable.clear();
-        projectsOnSubgraph.clear();
         usdEdges.clear();
-        emitCount = 0;
+        complexProjectMap.clear();
         complexProjectMap.putAll(hyperGraph.getComplexProject());
     }
 
@@ -339,54 +338,80 @@ public class PlanReceiver implements AbstractReceiver {
         long fullKey = LongBitmap.newBitmapUnion(left, right);
         List<Slot> outputs = allChild.get(0).getOutput();
         Set<Slot> outputSet = allChild.get(0).getOutputSet();
-        if (!projectsOnSubgraph.containsKey(fullKey)) {
-            List<NamedExpression> projects = new ArrayList<>();
-            // Calculate complex expression
-            List<Long> bitmaps = complexProjectMap.keySet().stream()
-                    .filter(bitmap -> LongBitmap.isSubset(bitmap, 
fullKey)).collect(Collectors.toList());
-
-            for (long bitmap : bitmaps) {
-                projects.addAll(complexProjectMap.get(bitmap));
-                complexProjectMap.remove(bitmap);
+        List<NamedExpression> allProjects = Lists.newArrayList();
+
+        List<NamedExpression> complexProjects = new ArrayList<>();
+        // Calculate complex expression should be done by current(fullKey) node
+        // the complex projects includes final output of current node(the 
complex project of fullKey)
+        // and any complex projects don't belong to subsets of fullKey except 
that fullKey is not a join node
+        List<Long> bitmaps = complexProjectMap.keySet().stream().filter(bitmap 
-> LongBitmap
+                        .isSubset(bitmap, fullKey)
+                        && ((!LongBitmap.isSubset(bitmap, left) && 
!LongBitmap.isSubset(bitmap, right))
+                        || left == right))
+                .collect(Collectors.toList());
+
+        // complexProjectMap is created by a bottom up traverse of join tree, 
so child node is put before parent node
+        // in the bitmaps
+        for (long bitmap : bitmaps) {
+            if (complexProjects.isEmpty()) {
+                complexProjects = complexProjectMap.get(bitmap);
+            } else {
+                // The top project of (T1, T2, T3) is different after reorder
+                // we need merge Project1 and Project2 as Project4 after 
reorder
+                // T1 join T2 join T3:
+                //    Project1(a, e + f)
+                //        join(a = e)
+                //            Project2(a, b + d as e)
+                //                join(a = c)
+                //                    T1(a, b)
+                //                    T2(c, d)
+                //        T3(e, f)
+                //
+                // after reorder:
+                // T1 join T3 join T2:
+                //    Project4(a, b + d + f)
+                //        join(a = c)
+                //            Project3(a, b, f)
+                //                join(a = e)
+                //                    T1(a, b)
+                //                    T3(e, f)
+                //        T2(c, d)
+                //
+                complexProjects =
+                        PlanUtils.mergeProjections(complexProjects, 
complexProjectMap.get(bitmap));
             }
+        }
+        allProjects.addAll(complexProjects);
 
-            // calculate required columns
-            Set<Slot> requireSlots = calculateRequiredSlots(left, right, 
edges);
-            outputs.stream()
-                    .filter(e -> requireSlots.contains(e))
-                    .forEach(e -> projects.add(e));
+        // calculate required columns by all parents
+        Set<Slot> requireSlots = calculateRequiredSlots(left, right, edges);
 
-            // propose physical project
-            if (projects.isEmpty()) {
-                projects.add(ExpressionUtils.selectMinimumColumn(outputs));
-            }
-            projectsOnSubgraph.put(fullKey, projects);
+        // add output slots belong to required slots to project list
+        allProjects.addAll(outputs.stream().filter(e -> 
requireSlots.contains(e))
+                .collect(Collectors.toList()));
+
+        // propose physical project
+        if (allProjects.isEmpty()) {
+            allProjects.add(ExpressionUtils.selectMinimumColumn(outputs));
         }
-        List<NamedExpression> allProjects = projectsOnSubgraph.get(fullKey);
         if (outputSet.equals(new HashSet<>(allProjects))) {
             return allChild;
         }
-        while (true) {
-            Set<Slot> childOutputSet = allChild.get(0).getOutputSet();
-            List<NamedExpression> projects = allProjects.stream()
-                    .filter(expr ->
-                            childOutputSet.containsAll(expr.getInputSlots()) 
|| childOutputSet.contains(expr.toSlot()))
+
+        Set<Slot> childOutputSet = allChild.get(0).getOutputSet();
+        List<NamedExpression> projects = allProjects.stream()
+                .filter(expr ->
+                        childOutputSet.containsAll(expr.getInputSlots()))
+                .collect(Collectors.toList());
+        if (!outputSet.equals(new HashSet<>(projects))) {
+            LogicalProperties projectProperties = new LogicalProperties(
+                    () -> projects.stream().map(p -> 
p.toSlot()).collect(Collectors.toList()));
+            allChild = allChild.stream()
+                    .map(c -> new PhysicalProject<>(projects, 
projectProperties, c))
                     .collect(Collectors.toList());
-            if (!outputSet.equals(new HashSet<>(projects))) {
-                LogicalProperties projectProperties = new LogicalProperties(
-                        () -> projects.stream().map(p -> 
p.toSlot()).collect(Collectors.toList()));
-                allChild = allChild.stream()
-                        .map(c -> new PhysicalProject<>(projects, 
projectProperties, c))
-                        .collect(Collectors.toList());
-            }
-            if (projects.size() == 0) {
-                throw new RuntimeException("dphyer fail process project");
-            }
-            if (projects.size() == allProjects.size()) {
-                break;
-            }
         }
+        Preconditions.checkState(!projects.isEmpty() && projects.size() == 
allProjects.size());
+
         return allChild;
     }
 }
-
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/algebra/Project.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/algebra/Project.java
index e4f52c5608..5b214ad090 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/algebra/Project.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/algebra/Project.java
@@ -23,6 +23,7 @@ import org.apache.doris.nereids.trees.expressions.ExprId;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.NamedExpression;
 import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.util.PlanUtils;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
@@ -71,28 +72,7 @@ public interface Project {
      * @return project list for merged project
      */
     default List<NamedExpression> mergeProjections(Project childProject) {
-        Map<Expression, Alias> replaceMap = childProject.getProjects().stream()
-                .filter(e -> e instanceof Alias)
-                .collect(Collectors.toMap(
-                        NamedExpression::toSlot,
-                        e -> (Alias) e,
-                        (v1, v2) -> v1));
-        return getProjects().stream()
-                .map(expr -> {
-                    if (expr instanceof Alias) {
-                        Alias alias = (Alias) expr;
-                        Expression insideExpr = alias.child();
-                        Expression newInsideExpr = insideExpr.rewriteUp(e -> {
-                            Alias getAlias = replaceMap.get(e);
-                            return getAlias == null ? e : getAlias.child();
-                        });
-                        return newInsideExpr == insideExpr ? expr : 
alias.withChildren(ImmutableList.of(newInsideExpr));
-                    } else {
-                        Alias getAlias = replaceMap.get(expr);
-                        return getAlias == null ? expr : getAlias;
-                    }
-                })
-                .collect(ImmutableList.toImmutableList());
+        return PlanUtils.mergeProjections(childProject.getProjects(), 
getProjects());
     }
 
     /**
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java
index 2bdde01ced..17cb0ed9a5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java
@@ -19,6 +19,7 @@ package org.apache.doris.nereids.types;
 
 import org.apache.doris.catalog.ScalarType;
 import org.apache.doris.catalog.Type;
+import org.apache.doris.common.Config;
 import org.apache.doris.nereids.annotation.Developing;
 import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.parser.NereidsParser;
@@ -132,16 +133,32 @@ public abstract class DataType implements 
AbstractDataType {
             case "double":
                 return DoubleType.INSTANCE;
             case "decimal":
-                switch (types.size()) {
-                    case 1:
-                        return DecimalV2Type.SYSTEM_DEFAULT;
-                    case 2:
-                        return 
DecimalV2Type.createDecimalV2Type(Integer.parseInt(types.get(1)), 0);
-                    case 3:
-                        return DecimalV2Type.createDecimalV2Type(
-                                Integer.parseInt(types.get(1)), 
Integer.parseInt(types.get(2)));
-                    default:
-                        throw new AnalysisException("Nereids do not support 
type: " + type);
+                if (Config.enable_decimal_conversion) {
+                    switch (types.size()) {
+                        case 1:
+                            return DecimalV3Type.SYSTEM_DEFAULT;
+                        case 2:
+                            return DecimalV3Type
+                                    
.createDecimalV3Type(Integer.parseInt(types.get(1)));
+                        case 3:
+                            return 
DecimalV3Type.createDecimalV3Type(Integer.parseInt(types.get(1)),
+                                    Integer.parseInt(types.get(2)));
+                        default:
+                            throw new AnalysisException("Nereids do not 
support type: " + type);
+                    }
+                } else {
+                    switch (types.size()) {
+                        case 1:
+                            return DecimalV2Type.SYSTEM_DEFAULT;
+                        case 2:
+                            return 
DecimalV2Type.createDecimalV2Type(Integer.parseInt(types.get(1)),
+                                    0);
+                        case 3:
+                            return 
DecimalV2Type.createDecimalV2Type(Integer.parseInt(types.get(1)),
+                                    Integer.parseInt(types.get(2)));
+                        default:
+                            throw new AnalysisException("Nereids do not 
support type: " + type);
+                    }
                 }
             case "decimalv3":
                 switch (types.size()) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/PlanUtils.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/PlanUtils.java
index 500abc433a..5ded1dab5e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/PlanUtils.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/PlanUtils.java
@@ -17,6 +17,7 @@
 
 package org.apache.doris.nereids.util;
 
+import org.apache.doris.nereids.trees.expressions.Alias;
 import org.apache.doris.nereids.trees.expressions.ComparisonPredicate;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.NamedExpression;
@@ -25,11 +26,14 @@ import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalFilter;
 import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
 
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Sets;
 
 import java.util.List;
+import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * Util for plan
@@ -67,4 +71,29 @@ public class PlanUtils {
     public static Plan projectOrSelf(List<NamedExpression> projects, Plan 
plan) {
         return project(projects, plan).map(Plan.class::cast).orElse(plan);
     }
+
+    /**
+     * merge childProjects with parentProjects
+     */
+    public static List<NamedExpression> mergeProjections(List<NamedExpression> 
childProjects,
+            List<NamedExpression> parentProjects) {
+        Map<Expression, Alias> replaceMap =
+                childProjects.stream().filter(e -> e instanceof Alias).collect(
+                        Collectors.toMap(NamedExpression::toSlot, e -> (Alias) 
e, (v1, v2) -> v1));
+        return parentProjects.stream().map(expr -> {
+            if (expr instanceof Alias) {
+                Alias alias = (Alias) expr;
+                Expression insideExpr = alias.child();
+                Expression newInsideExpr = insideExpr.rewriteUp(e -> {
+                    Alias getAlias = replaceMap.get(e);
+                    return getAlias == null ? e : getAlias.child();
+                });
+                return newInsideExpr == insideExpr ? expr
+                        : alias.withChildren(ImmutableList.of(newInsideExpr));
+            } else {
+                Alias getAlias = replaceMap.get(expr);
+                return getAlias == null ? expr : getAlias;
+            }
+        }).collect(ImmutableList.toImmutableList());
+    }
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
index 54c59b35cc..63da2752fb 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
@@ -37,6 +37,7 @@ import 
org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
 import org.apache.doris.nereids.types.DecimalV2Type;
+import org.apache.doris.nereids.types.DecimalV3Type;
 
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
@@ -335,8 +336,14 @@ public class NereidsParserTest extends ParserTestBase {
         NereidsParser nereidsParser = new NereidsParser();
         LogicalPlan logicalPlan = nereidsParser.parseSingle(sql);
         Cast cast = (Cast) logicalPlan.getExpressions().get(0).child(0);
-        DecimalV2Type decimalV2Type = (DecimalV2Type) cast.getDataType();
-        Assertions.assertEquals(20, decimalV2Type.getPrecision());
-        Assertions.assertEquals(6, decimalV2Type.getScale());
+        if (Config.enable_decimal_conversion) {
+            DecimalV3Type decimalV3Type = (DecimalV3Type) cast.getDataType();
+            Assertions.assertEquals(20, decimalV3Type.getPrecision());
+            Assertions.assertEquals(6, decimalV3Type.getScale());
+        } else {
+            DecimalV2Type decimalV2Type = (DecimalV2Type) cast.getDataType();
+            Assertions.assertEquals(20, decimalV2Type.getPrecision());
+            Assertions.assertEquals(6, decimalV2Type.getScale());
+        }
     }
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/types/DataTypeTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/types/DataTypeTest.java
index 51e625c4df..03f399e114 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/nereids/types/DataTypeTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/types/DataTypeTest.java
@@ -79,7 +79,9 @@ public class DataTypeTest {
         // double
         Assertions.assertEquals(DoubleType.INSTANCE, 
DataType.convertFromString("double"));
         // decimalv2
-        Assertions.assertEquals(DecimalV2Type.createDecimalV2Type(13, 9),
+        Assertions.assertEquals(
+                Config.enable_decimal_conversion ? 
DecimalV3Type.createDecimalV3Type(13, 9)
+                        : DecimalV2Type.createDecimalV2Type(13, 9),
                 DataType.convertFromString("decimal(13, 9)"));
         // decimalv3
         Assertions.assertEquals(DecimalV3Type.createDecimalV3Type(13, 9),
diff --git a/regression-test/data/cte_reuse/q23.out 
b/regression-test/data/cte_reuse/q23.out
index 85ac596890..63f621b681 100644
--- a/regression-test/data/cte_reuse/q23.out
+++ b/regression-test/data/cte_reuse/q23.out
@@ -22,7 +22,7 @@ CteAnchor[cteId= ( CTEId#1=] )
 --CteAnchor[cteId= ( CTEId#4=] )
 ----CteProducer[cteId= ( CTEId#4=] )
 ------PhysicalProject
---------NestedLoopJoin[INNER_JOIN](cast(ssales as DOUBLE) > 
cast((cast((cast(50 as DECIMAL(27, 9)) / cast(cast('100.0' as DECIMAL(5, 2)) as 
DECIMAL(27, 9))) as DECIMALV3(27, 9)) * tpcds_cmax) as DOUBLE))
+--------NestedLoopJoin[INNER_JOIN](cast(ssales as DOUBLE) > cast(((cast(50 as 
DECIMALV3(9, 6)) / cast('100.0' as DECIMALV3(5, 2))) * tpcds_cmax) as DOUBLE))
 ----------hashAgg[GLOBAL]
 ------------PhysicalDistribute
 --------------hashAgg[LOCAL]
diff --git a/regression-test/data/cte_reuse/q24.out 
b/regression-test/data/cte_reuse/q24.out
index 941cea5f9b..fa0d4e45a6 100644
--- a/regression-test/data/cte_reuse/q24.out
+++ b/regression-test/data/cte_reuse/q24.out
@@ -36,7 +36,7 @@ CteAnchor[cteId= ( CTEId#0=] )
 ----PhysicalDistribute
 ------PhysicalQuickSort
 --------PhysicalProject
-----------NestedLoopJoin[INNER_JOIN](cast(paid as DOUBLE) > cast((cast('0.05' 
as DECIMAL(5, 2)) * avg(netpaid)) as DOUBLE))
+----------NestedLoopJoin[INNER_JOIN](cast(paid as DOUBLE) > cast((cast('0.05' 
as DECIMALV3(5, 2)) * avg(netpaid)) as DOUBLE))
 ------------hashAgg[GLOBAL]
 --------------PhysicalDistribute
 ----------------hashAgg[LOCAL]
diff --git a/regression-test/data/cte_reuse/q31.out 
b/regression-test/data/cte_reuse/q31.out
index 5b05b4d1b3..b767d12c63 100644
--- a/regression-test/data/cte_reuse/q31.out
+++ b/regression-test/data/cte_reuse/q31.out
@@ -42,7 +42,7 @@ CteAnchor[cteId= ( CTEId#6=] )
 ------PhysicalDistribute
 --------PhysicalQuickSort
 ----------PhysicalProject
-------------hashJoin[INNER_JOIN](ws1.ca_county = ws3.ca_county)(CASE WHEN 
(web_sales > 0.00) THEN (cast(cast(web_sales as DECIMAL(21, 3)) as 
DECIMALV3(27, 9)) / web_sales) ELSE NULL END > CASE WHEN (store_sales > 0.00) 
THEN (cast(cast(store_sales as DECIMAL(21, 3)) as DECIMALV3(27, 9)) / 
store_sales) ELSE NULL END)
+------------hashJoin[INNER_JOIN](ws1.ca_county = ws3.ca_county)(CASE WHEN 
(web_sales > 0.00) THEN (cast(cast(web_sales as DECIMALV3(21, 3)) as 
DECIMALV3(27, 9)) / web_sales) ELSE NULL END > CASE WHEN (store_sales > 0.00) 
THEN (cast(cast(store_sales as DECIMALV3(21, 3)) as DECIMALV3(27, 9)) / 
store_sales) ELSE NULL END)
 --------------PhysicalProject
 ----------------filter((ws3.d_year = 2000)(ws3.d_qoy = 3))
 ------------------CteConsumer[cteId= ( CTEId#7=] )
@@ -53,7 +53,7 @@ CteAnchor[cteId= ( CTEId#6=] )
 ----------------------filter((ss3.d_year = 2000)(ss3.d_qoy = 3))
 ------------------------CteConsumer[cteId= ( CTEId#6=] )
 --------------------PhysicalDistribute
-----------------------hashJoin[INNER_JOIN](ss1.ca_county = ss2.ca_county)(CASE 
WHEN (web_sales > 0.00) THEN (cast(cast(web_sales as DECIMAL(21, 3)) as 
DECIMALV3(27, 9)) / web_sales) ELSE NULL END > CASE WHEN (store_sales > 0.00) 
THEN (cast(cast(store_sales as DECIMAL(21, 3)) as DECIMALV3(27, 9)) / 
store_sales) ELSE NULL END)
+----------------------hashJoin[INNER_JOIN](ss1.ca_county = ss2.ca_county)(CASE 
WHEN (web_sales > 0.00) THEN (cast(cast(web_sales as DECIMALV3(21, 3)) as 
DECIMALV3(27, 9)) / web_sales) ELSE NULL END > CASE WHEN (store_sales > 0.00) 
THEN (cast(cast(store_sales as DECIMALV3(21, 3)) as DECIMALV3(27, 9)) / 
store_sales) ELSE NULL END)
 ------------------------PhysicalProject
 --------------------------filter((ss2.d_year = 2000)(ss2.d_qoy = 2))
 ----------------------------CteConsumer[cteId= ( CTEId#6=] )
diff --git a/regression-test/data/nereids_p0/lateral_view/test_issue_8850.out 
b/regression-test/data/nereids_p0/lateral_view/test_issue_8850.out
index 4027cbd256..19912c5b1c 100644
--- a/regression-test/data/nereids_p0/lateral_view/test_issue_8850.out
+++ b/regression-test/data/nereids_p0/lateral_view/test_issue_8850.out
@@ -6,7 +6,18 @@
 0
 
 -- !test_issue_8850_3 --
+0
 
 -- !test_issue_8850_4 --
 0
 
+-- !test_issue_8850_5 --
+
+-- !test_issue_8850_6 --
+0
+
+-- !test_issue_8850_7 --
+
+-- !test_issue_8850_8 --
+0
+
diff --git 
a/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query75.out 
b/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query75.out
index 4ae66ee6d4..319e8a5922 100644
--- a/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query75.out
+++ b/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query75.out
@@ -70,7 +70,7 @@ CteAnchor[cteId= ( CTEId#3=] )
 ----PhysicalDistribute
 ------PhysicalTopN
 --------PhysicalProject
-----------hashJoin[INNER_JOIN](curr_yr.i_brand_id = 
prev_yr.i_brand_id)(curr_yr.i_class_id = 
prev_yr.i_class_id)(curr_yr.i_category_id = 
prev_yr.i_category_id)(curr_yr.i_manufact_id = 
prev_yr.i_manufact_id)(cast((cast(cast(sales_cnt as DECIMAL(17, 2)) as 
DECIMAL(27, 9)) / cast(cast(sales_cnt as DECIMAL(17, 2)) as DECIMAL(27, 9))) as 
DECIMALV3(27, 9)) < 0.900000000)
+----------hashJoin[INNER_JOIN](curr_yr.i_brand_id = 
prev_yr.i_brand_id)(curr_yr.i_class_id = 
prev_yr.i_class_id)(curr_yr.i_category_id = 
prev_yr.i_category_id)(curr_yr.i_manufact_id = 
prev_yr.i_manufact_id)((cast(cast(sales_cnt as DECIMALV3(17, 2)) as 
DECIMALV3(23, 8)) / cast(sales_cnt as DECIMALV3(17, 2))) < 0.900000)
 ------------PhysicalDistribute
 --------------filter((curr_yr.d_year = 1999))
 ----------------CteConsumer[cteId= ( CTEId#3=] )
diff --git a/regression-test/suites/nereids_p0/lateral_view/test_issue_8850.sql 
b/regression-test/suites/nereids_p0/lateral_view/test_issue_8850.sql
index d81f7b7e9d..9253641f0e 100644
--- a/regression-test/suites/nereids_p0/lateral_view/test_issue_8850.sql
+++ b/regression-test/suites/nereids_p0/lateral_view/test_issue_8850.sql
@@ -1,7 +1,14 @@
+set enable_nereids_planner=true;
+set enable_fallback_to_original_planner=false;
+
 DROP TABLE IF EXISTS tag_map;
 
 CREATE TABLE IF NOT EXISTS `tag_map` ( `tag_group` bigint(20) NULL COMMENT 
"标签组", `tag_value_id` varchar(64) NULL COMMENT "标签值", `tag_range` int(11) NOT 
NULL DEFAULT "0" COMMENT "", `partition_sign` varchar(32) NOT NULL COMMENT 
"分区标识", `bucket` int(11) NOT NULL COMMENT "分桶字段", `confidence` tinyint(4) NULL 
DEFAULT "100" COMMENT "置信度", `members` bitmap BITMAP_UNION NULL COMMENT "人群") 
ENGINE=OLAP AGGREGATE KEY(`tag_group`, `tag_value_id`, `tag_range`, 
`partition_sign`, `bucket`, `confidence [...]
 
 with d as (select f1.bucket, bitmap_and(f1.members, f2.members) as members 
from (select f1.bucket, bitmap_and(f1.members, f2.members) as members from 
(select bucket, bitmap_union(members) as members from tag_map where 
partition_sign='2022-03-31-1' and tag_group=810004  and tag_value_id in 
(5524627,5524628,5524629) group by bucket) f1,(select bucket, 
bitmap_union(members) as members from tag_map where 
partition_sign='2022-03-31-1' and tag_group=810007 and tag_value_id in 
('5525013_1735712 [...]
 
+set enable_dphyp_optimizer=true;
+
+with d as (select f1.bucket, bitmap_and(f1.members, f2.members) as members 
from (select f1.bucket, bitmap_and(f1.members, f2.members) as members from 
(select bucket, bitmap_union(members) as members from tag_map where 
partition_sign='2022-03-31-1' and tag_group=810004  and tag_value_id in 
(5524627,5524628,5524629) group by bucket) f1,(select bucket, 
bitmap_union(members) as members from tag_map where 
partition_sign='2022-03-31-1' and tag_group=810007 and tag_value_id in 
('5525013_1735712 [...]
+
 DROP TABLE tag_map;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to