You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/12/27 14:37:00 UTC

[doris] branch master updated: [fix](nereids) sender in union's child fragment has no destination (#15402)

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

morrysnow 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 03aef7a8ac [fix](nereids) sender in union's child  fragment has no destination (#15402)
03aef7a8ac is described below

commit 03aef7a8ac67519c999c279c8ddc182c3c050396
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Tue Dec 27 22:36:54 2022 +0800

    [fix](nereids) sender in union's child  fragment has no destination (#15402)
    
    1. always create an exchange node for set operation node's children
    2. fix cast expr's nullability bug.
---
 .../glue/translator/PhysicalPlanTranslator.java    |  5 +++--
 .../doris/nereids/trees/expressions/Cast.java      |  9 +++++++-
 .../org/apache/doris/nereids/types/DataType.java   |  2 +-
 .../data/nereids_syntax_p0/set_operation.out       | 25 ++++++++++++++++++++++
 regression-test/data/query_p0/union/test_union.out |  3 +++
 .../suites/nereids_syntax_p0/set_operation.groovy  |  1 +
 .../suites/query_p0/union/test_union.groovy        |  5 +++++
 7 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
index 6867c4227d..69e3829dd4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
@@ -1276,8 +1276,9 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor<PlanFragment, Pla
             // Absorb the plan trees of all childFragments into unionNode
             // and fix up the fragment tree in the process.
             for (int i = 0; i < childrenFragments.size(); ++i) {
-                setOperationFragment.setFragmentInPlanTree(setOperationNode.getChild(i));
-                setOperationFragment.addChildren(childrenFragments.get(i).getChildren());
+                connectChildFragmentNotCheckExchangeNode(setOperationNode, i, setOperationFragment,
+                         childrenFragments.get(i),
+                         context);
             }
         } else {
             setOperationFragment = new PlanFragment(context.nextFragmentId(), setOperationNode,
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java
index 7228807e14..6cf587a820 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java
@@ -51,7 +51,14 @@ public class Cast extends Expression implements UnaryExpression {
 
     @Override
     public boolean nullable() {
-        return child().nullable();
+        DataType childDataType = child().getDataType();
+        if (childDataType.isStringType() && !targetType.isStringType()) {
+            return true;
+        } else if (!childDataType.isDateType() && targetType.isDateType()) {
+            return true;
+        } else {
+            return child().nullable();
+        }
     }
 
     @Override
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 6abe61d9f7..8c4be55c86 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
@@ -449,7 +449,7 @@ public abstract class DataType implements AbstractDataType {
     }
 
     public boolean isDateType() {
-        return isDate() || isDateTime();
+        return isDate() || isDateTime() || isDateV2() || isDateTimeV2();
     }
 
     public boolean isNullType() {
diff --git a/regression-test/data/nereids_syntax_p0/set_operation.out b/regression-test/data/nereids_syntax_p0/set_operation.out
index a5f9e478d0..8e83e3adc5 100644
--- a/regression-test/data/nereids_syntax_p0/set_operation.out
+++ b/regression-test/data/nereids_syntax_p0/set_operation.out
@@ -439,3 +439,28 @@ hell0
 -- !union36 --
 1	2
 
+-- !union39 --
+1
+1
+1
+1
+1
+1
+1
+1
+2
+2
+2
+2
+2
+2
+2
+2
+3
+3
+3
+3
+3
+3
+3
+3
diff --git a/regression-test/data/query_p0/union/test_union.out b/regression-test/data/query_p0/union/test_union.out
index 302eb78140..fc99e71054 100644
--- a/regression-test/data/query_p0/union/test_union.out
+++ b/regression-test/data/query_p0/union/test_union.out
@@ -360,3 +360,6 @@ hell0
 11011903
 11011905
 
+-- !union35 --
+2016-07-01
+2016-07-02
diff --git a/regression-test/suites/nereids_syntax_p0/set_operation.groovy b/regression-test/suites/nereids_syntax_p0/set_operation.groovy
index 8edfaa33cb..ee1915b9b0 100644
--- a/regression-test/suites/nereids_syntax_p0/set_operation.groovy
+++ b/regression-test/suites/nereids_syntax_p0/set_operation.groovy
@@ -213,4 +213,5 @@ suite("test_nereids_set_operation") {
             logger.info(exception.message)
         }
     }
+    qt_union39 """(select  k1 from setOperationTable order by k1) union all (select k1 from setOperationTableNotNullable order by k1) order by k1;"""
 }
diff --git a/regression-test/suites/query_p0/union/test_union.groovy b/regression-test/suites/query_p0/union/test_union.groovy
index ff856245f0..d859259672 100644
--- a/regression-test/suites/query_p0/union/test_union.groovy
+++ b/regression-test/suites/query_p0/union/test_union.groovy
@@ -273,4 +273,9 @@ suite("test_union") {
         qt_union40 """(select k1 from ${new_union_table}) union (select k${idx} from ${tbName1}) order by k1"""
     }
     sql"""drop table ${new_union_table}"""
+
+    sql 'set enable_vectorized_engine=true;'
+    sql 'set enable_fallback_to_original_planner=false'
+    sql 'set enable_nereids_planner=true'
+    qt_union35 """select cast("2016-07-01" as date) union (select cast("2016-07-02 1:10:0" as date)) order by 1"""
 }


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