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 c6585e3f088 [fix](nullable) set SlotRef's nullable to right value for 
nestloop join (#59310)
c6585e3f088 is described below

commit c6585e3f0880ed1cb44ff553e47d09fcc1e48dac
Author: starocean999 <[email protected]>
AuthorDate: Thu Dec 25 11:33:29 2025 +0800

    [fix](nullable) set SlotRef's nullable to right value for nestloop join 
(#59310)
    
    this is follow up of https://github.com/apache/doris/pull/59092, we need
    change nestloop join's nullable info too.
    
    Related PR: https://github.com/apache/doris/pull/59092
---
 .../glue/translator/PhysicalPlanTranslator.java    |  32 ++--
 .../nereids_p0/test_nestloop_join_nullable.out     | 192 +++++++++++++++++++++
 .../nereids_p0/test_nestloop_join_nullable.groovy  | 114 ++++++++++++
 3 files changed, 322 insertions(+), 16 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 b86872897e9..84e7c400269 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
@@ -1862,24 +1862,14 @@ public class PhysicalPlanTranslator extends 
DefaultPlanVisitor<PlanFragment, Pla
         // in the intermediate tuple, so fe have to do the same, if be fix the 
problem, we can change it back.
         for (SlotDescriptor leftSlotDescriptor : leftSlotDescriptors) {
             SlotReference sf = 
leftChildOutputMap.get(context.findExprId(leftSlotDescriptor.getId()));
-            SlotDescriptor sd;
-            if (sf == null && 
leftSlotDescriptor.getColumn().getName().equals(Column.ROWID_COL)) {
-                // TODO: temporary code for two phase read, should remove it 
after refactor
-                sd = 
context.getDescTable().copySlotDescriptor(intermediateDescriptor, 
leftSlotDescriptor);
-            } else {
-                sd = context.createSlotDesc(intermediateDescriptor, sf, 
leftSlotDescriptor.getParent().getTable());
-            }
+            SlotDescriptor sd = context.createSlotDesc(intermediateDescriptor, 
sf,
+                    leftSlotDescriptor.getParent().getTable());
             leftIntermediateSlotDescriptor.add(sd);
         }
         for (SlotDescriptor rightSlotDescriptor : rightSlotDescriptors) {
             SlotReference sf = 
rightChildOutputMap.get(context.findExprId(rightSlotDescriptor.getId()));
-            SlotDescriptor sd;
-            if (sf == null && 
rightSlotDescriptor.getColumn().getName().equals(Column.ROWID_COL)) {
-                // TODO: temporary code for two phase read, should remove it 
after refactor
-                sd = 
context.getDescTable().copySlotDescriptor(intermediateDescriptor, 
rightSlotDescriptor);
-            } else {
-                sd = context.createSlotDesc(intermediateDescriptor, sf, 
rightSlotDescriptor.getParent().getTable());
-            }
+            SlotDescriptor sd = context.createSlotDesc(intermediateDescriptor, 
sf,
+                    rightSlotDescriptor.getParent().getTable());
             rightIntermediateSlotDescriptor.add(sd);
         }
 
@@ -1890,10 +1880,20 @@ public class PhysicalPlanTranslator extends 
DefaultPlanVisitor<PlanFragment, Pla
 
         // set slots as nullable for outer join
         if (joinType == JoinType.LEFT_OUTER_JOIN || joinType == 
JoinType.FULL_OUTER_JOIN) {
-            rightIntermediateSlotDescriptor.forEach(sd -> 
sd.setIsNullable(true));
+            for (SlotDescriptor sd : rightIntermediateSlotDescriptor) {
+                sd.setIsNullable(true);
+                SlotRef slotRef = new SlotRef(sd);
+                ExprId exprId = context.findExprId(sd.getId());
+                context.addExprIdSlotRefPair(exprId, slotRef);
+            }
         }
         if (joinType == JoinType.RIGHT_OUTER_JOIN || joinType == 
JoinType.FULL_OUTER_JOIN) {
-            leftIntermediateSlotDescriptor.forEach(sd -> 
sd.setIsNullable(true));
+            for (SlotDescriptor sd : leftIntermediateSlotDescriptor) {
+                sd.setIsNullable(true);
+                SlotRef slotRef = new SlotRef(sd);
+                ExprId exprId = context.findExprId(sd.getId());
+                context.addExprIdSlotRefPair(exprId, slotRef);
+            }
         }
 
         
nestedLoopJoinNode.setvIntermediateTupleDescList(Lists.newArrayList(intermediateDescriptor));
diff --git a/regression-test/data/nereids_p0/test_nestloop_join_nullable.out 
b/regression-test/data/nereids_p0/test_nestloop_join_nullable.out
new file mode 100644
index 00000000000..c376ae61905
--- /dev/null
+++ b/regression-test/data/nereids_p0/test_nestloop_join_nullable.out
@@ -0,0 +1,192 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+-11824.0       \N      1       \N      \N
+-11824.0       \N      1       \N      \N
+-11824.0       \N      1       \N      \N
+-11824.0       \N      1       \N      \N
+-11824.0       \N      1       \N      \N
+-11824.0       \N      1       \N      \N
+-11824.0       \N      1       \N      \N
+-11824.0       \N      1       \N      \N
+-11824.0       \N      1       \N      \N
+-11824.0       \N      1       \N      \N
+-11824.0       \N      1       \N      \N
+-11824.0       \N      1       \N      \N
+-11824.0       \N      2       \N      \N
+-11824.0       \N      3       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      4       \N      \N
+-11824.0       \N      6       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      8       \N      \N
+-11824.0       \N      9       \N      \N
+-11824.0       \N      10      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      13      \N      \N
+-11824.0       \N      19      \N      \N
+-11824.0       \N      20      \N      \N
+-11824.0       \N      32      \N      \N
+-11824.0       \N      33      \N      \N
+-11824.0       -2355558        1       \N      \N
+-11824.0       -1471873        3       -9832223        9832223
+-11824.0       -1471873        3       -5047939        5047939
+-11824.0       -1471873        3       -4396782        4396782
+-11824.0       -1471873        3       -1471984        1471984
+-11824.0       -1471873        3       -1471927        1471927
+-11824.0       -1471873        3       -1471885        1471885
+-11824.0       -1471873        3       -1471868        1471868
+-11824.0       -1471873        3       -1471830        1471830
+-11824.0       -1471873        3       -1456420        1456420
+-11824.0       -1471873        3       -1454151        1454151
+-11824.0       -1471873        3       -1453445        1453445
+-11824.0       -1471873        3       -1442796        1442796
+-11824.0       -1471873        7       \N      \N
+-11824.0       -1471873        8       \N      \N
+-11824.0       -6163   11      \N      \N
+-11824.0       -126    7       -8360476        8360476
+-11824.0       -126    7       -3576192        3576192
+-11824.0       -126    7       -2925035        2925035
+-11824.0       -126    7       -237    237
+-11824.0       -126    7       -180    180
+-11824.0       -126    7       -138    138
+-11824.0       -126    7       -121    121
+-11824.0       -126    7       -83     83
+-11824.0       -126    7       15327   -15327
+-11824.0       -126    7       17596   -17596
+-11824.0       -126    7       18302   -18302
+-11824.0       -126    7       28951   -28951
+-11824.0       -126    17      \N      \N
+-11824.0       -126    18      \N      \N
+-11824.0       -48     11      -8360398        8360398
+-11824.0       -48     11      -3576114        3576114
+-11824.0       -48     11      -2924957        2924957
+-11824.0       -48     11      -159    159
+-11824.0       -48     11      -102    102
+-11824.0       -48     11      -60     60
+-11824.0       -48     11      -43     43
+-11824.0       -48     11      -5      5
+-11824.0       -48     11      15405   -15405
+-11824.0       -48     11      17674   -17674
+-11824.0       -48     11      18380   -18380
+-11824.0       -48     11      29029   -29029
+-11824.0       -48     26      \N      \N
+-11824.0       -48     27      \N      \N
+-11824.0       -39     28      \N      \N
+-11824.0       43      23      \N      \N
+-11824.0       44      10      -8360306        8360306
+-11824.0       44      10      -3576022        3576022
+-11824.0       44      10      -2924865        2924865
+-11824.0       44      10      -67     67
+-11824.0       44      10      -10     10
+-11824.0       44      10      32      -32
+-11824.0       44      10      49      -49
+-11824.0       44      10      87      -87
+-11824.0       44      10      15497   -15497
+-11824.0       44      10      17766   -17766
+-11824.0       44      10      18472   -18472
+-11824.0       44      10      29121   -29121
+-11824.0       44      24      \N      \N
+-11824.0       44      25      \N      \N
+-11824.0       79      5       -8360271        8360271
+-11824.0       79      5       -3575987        3575987
+-11824.0       79      5       -2924830        2924830
+-11824.0       79      5       -32     32
+-11824.0       79      5       25      -25
+-11824.0       79      5       67      -67
+-11824.0       79      5       84      -84
+-11824.0       79      5       122     -122
+-11824.0       79      5       15532   -15532
+-11824.0       79      5       17801   -17801
+-11824.0       79      5       18507   -18507
+-11824.0       79      5       29156   -29156
+-11824.0       79      12      \N      \N
+-11824.0       79      13      \N      \N
+-11824.0       92      6       -8360258        8360258
+-11824.0       92      6       -3575974        3575974
+-11824.0       92      6       -2924817        2924817
+-11824.0       92      6       -19     19
+-11824.0       92      6       38      -38
+-11824.0       92      6       80      -80
+-11824.0       92      6       97      -97
+-11824.0       92      6       135     -135
+-11824.0       92      6       15545   -15545
+-11824.0       92      6       17814   -17814
+-11824.0       92      6       18520   -18520
+-11824.0       92      6       29169   -29169
+-11824.0       92      15      \N      \N
+-11824.0       92      16      \N      \N
+-11824.0       121     29      \N      \N
+-11824.0       7695    12      -8352655        8352655
+-11824.0       7695    12      -3568371        3568371
+-11824.0       7695    12      -2917214        2917214
+-11824.0       7695    12      7584    -7584
+-11824.0       7695    12      7641    -7641
+-11824.0       7695    12      7683    -7683
+-11824.0       7695    12      7700    -7700
+-11824.0       7695    12      7738    -7738
+-11824.0       7695    12      23148   -23148
+-11824.0       7695    12      25417   -25417
+-11824.0       7695    12      26123   -26123
+-11824.0       7695    12      36772   -36772
+-11824.0       7695    30      \N      \N
+-11824.0       7695    31      \N      \N
+-11824.0       9832    14      \N      \N
+-11824.0       473442  2       -7886908        7886908
+-11824.0       473442  2       -3102624        3102624
+-11824.0       473442  2       -2451467        2451467
+-11824.0       473442  2       473331  -473331
+-11824.0       473442  2       473388  -473388
+-11824.0       473442  2       473430  -473430
+-11824.0       473442  2       473447  -473447
+-11824.0       473442  2       473485  -473485
+-11824.0       473442  2       488895  -488895
+-11824.0       473442  2       491164  -491164
+-11824.0       473442  2       491870  -491870
+-11824.0       473442  2       502519  -502519
+-11824.0       473442  4       \N      \N
+-11824.0       473442  5       \N      \N
+-11824.0       1527847 9       -6832503        6832503
+-11824.0       1527847 9       -2048219        2048219
+-11824.0       1527847 9       -1397062        1397062
+-11824.0       1527847 9       1527736 -1527736
+-11824.0       1527847 9       1527793 -1527793
+-11824.0       1527847 9       1527835 -1527835
+-11824.0       1527847 9       1527852 -1527852
+-11824.0       1527847 9       1527890 -1527890
+-11824.0       1527847 9       1543300 -1543300
+-11824.0       1527847 9       1545569 -1545569
+-11824.0       1527847 9       1546275 -1546275
+-11824.0       1527847 9       1556924 -1556924
+-11824.0       1527847 21      \N      \N
+-11824.0       1527847 22      \N      \N
+
diff --git 
a/regression-test/suites/nereids_p0/test_nestloop_join_nullable.groovy 
b/regression-test/suites/nereids_p0/test_nestloop_join_nullable.groovy
new file mode 100644
index 00000000000..cd96bd85c9c
--- /dev/null
+++ b/regression-test/suites/nereids_p0/test_nestloop_join_nullable.groovy
@@ -0,0 +1,114 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_nestloop_join_nullable") {
+    multi_sql '''
+    drop table if exists 
table_20_undef_partitions2_keys3_properties4_distributed_by510;
+    drop table if exists 
table_20_undef_partitions2_keys3_properties4_distributed_by512;
+
+    create table 
table_20_undef_partitions2_keys3_properties4_distributed_by510 (
+    col_int_undef_signed int/*agg_type_placeholder*/    ,
+    col_int_undef_signed2 int/*agg_type_placeholder*/    ,
+    col_float_undef_signed float/*agg_type_placeholder*/    ,
+    col_int_undef_signed3 int/*agg_type_placeholder*/    ,
+    col_int_undef_signed4 int/*agg_type_placeholder*/    ,
+    col_int_undef_signed5 int/*agg_type_placeholder*/    ,
+    pk int/*agg_type_placeholder*/
+    ) engine=olap
+    distributed by hash(pk) buckets 10
+    properties("replication_num" = "1");
+    insert into 
table_20_undef_partitions2_keys3_properties4_distributed_by510(pk,col_int_undef_signed,col_int_undef_signed2,col_float_undef_signed,col_int_undef_signed3,col_int_undef_signed4,col_int_undef_signed5)
 values 
(19,-538797,111,-2357243,88,null,null),(18,11035,null,-7629271,null,2400941,-12250),(17,119,8360350,null,-101,-57,-2825979),(16,93,-5,101,81,-57,null),(15,24421,3576066,null,-8351025,3094515,null),(14,-32,-53,-117,null,408662,69),(13,-28788,null,-3424,58,-16,5885342),(1
 [...]
+
+    create table 
table_20_undef_partitions2_keys3_properties4_distributed_by512 (
+    pk int,
+    col_int_undef_signed int    ,
+    col_int_undef_signed2 int    ,
+    col_float_undef_signed float    ,
+    col_int_undef_signed3 int    ,
+    col_int_undef_signed4 int    ,
+    col_int_undef_signed5 int    
+    ) engine=olap
+    DUPLICATE KEY(pk)
+    distributed by hash(pk) buckets 10
+    properties("replication_num" = "1");
+    insert into 
table_20_undef_partitions2_keys3_properties4_distributed_by512(pk,col_int_undef_signed,col_int_undef_signed2,col_float_undef_signed,col_int_undef_signed3,col_int_undef_signed4,col_int_undef_signed5)
 values 
(19,null,-122,-4279753,-7311927,89,null),(18,-35,8334250,1537805,-112,-21552,1527847),(17,24212,null,null,62,-26157,43),(16,-3845324,null,-11824,5033341,null,121),(15,-4642469,null,-35,null,5146485,9832),(14,7780660,null,-3021705,-29468,105,-6163),(13,null,46,null,104,-
 [...]
+    '''
+
+    qt_select '''
+        SELECT
+        FIRST_VALUE(t2.col_float_undef_signed) OVER (
+            ORDER BY
+                t1.col_int_undef_signed4,
+                (
+                    t2.col_int_undef_signed4 + t1.col_int_undef_signed4
+                ),
+                t2.col_int_undef_signed4,
+                t1.col_int_undef_signed3,
+                t1.col_int_undef_signed5,
+                abs(t1.col_int_undef_signed),
+                t1.col_float_undef_signed,
+                t2.col_int_undef_signed
+        ),
+        LAST_VALUE(t2.col_int_undef_signed5) OVER (
+            ORDER BY
+                (
+                    t2.col_float_undef_signed * t2.col_int_undef_signed
+                ),
+                t2.col_int_undef_signed5,
+                1,
+                t2.col_float_undef_signed,
+                atan2(
+                    t2.col_int_undef_signed3,
+                    t1.col_int_undef_signed3
+                ),
+                t2.col_int_undef_signed,
+                t1.col_float_undef_signed,
+                t2.col_float_undef_signed
+        ),
+        RANK() OVER (
+            PARTITION BY (t1.col_int_undef_signed2 * 80954088951981892)
+            ORDER BY
+                6,
+                ln(t2.col_int_undef_signed3),
+                t2.col_float_undef_signed,
+                t2.col_int_undef_signed,
+                (
+                    t1.col_int_undef_signed4 - t2.col_int_undef_signed4
+                ),
+                t2.col_float_undef_signed,
+                t1.col_int_undef_signed5,
+                t2.col_int_undef_signed
+        ),
+        (
+            t2.col_int_undef_signed5 - t1.col_int_undef_signed2
+        ),
+        (
+            t1.col_int_undef_signed2 - t2.col_int_undef_signed5
+        )
+    from
+        table_20_undef_partitions2_keys3_properties4_distributed_by510 t1
+        RIGHT JOIN 
table_20_undef_partitions2_keys3_properties4_distributed_by512 t2 ON 
t1.col_int_undef_signed5 = t2.col_int_undef_signed3
+        OR t1.col_int_undef_signed3 = t1.col_int_undef_signed3
+        AND t2.col_int_undef_signed2 = t2.col_int_undef_signed2
+    order by
+        1,
+        2,
+        3,
+        4,
+        5;
+    '''
+}
\ No newline at end of file


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

Reply via email to