From c941e3c151b36a999e6dc3e9a32fd870e1123b4e Mon Sep 17 00:00:00 2001 From: morrySnow Date: Tue, 16 Dec 2025 19:08:35 +0800 Subject: [PATCH 1/2] [fix](nullable) set SlotRef's nullable to right value (cherry picked from commit b1ba0b445c32d84bf2f86715a671f8830a7fe95e) --- .../translator/PhysicalPlanTranslator.java | 190 ++++-------------- .../load/NereidsLoadPlanInfoCollector.java | 11 - .../doris/planner/AssertNumRowsNode.java | 7 +- 3 files changed, 46 insertions(+), 162 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 9c95aaa5ad0470..37d10ce4d31d24 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 @@ -19,6 +19,7 @@ import org.apache.doris.analysis.AggregateInfo; import org.apache.doris.analysis.AnalyticWindow; +import org.apache.doris.analysis.AssertNumRowsElement; import org.apache.doris.analysis.BinaryPredicate; import org.apache.doris.analysis.BoolLiteral; import org.apache.doris.analysis.CompoundPredicate; @@ -572,16 +573,6 @@ public PlanFragment visitPhysicalHiveTableSink(PhysicalHiveTableSink targetTableColumns = hiveTableSink.getTargetTable().getFullSchema(); - for (Column column : targetTableColumns) { - SlotDescriptor slotDesc = context.addSlotDesc(hiveTuple); - slotDesc.setType(column.getType()); - slotDesc.setColumn(column); - slotDesc.setIsNullable(column.isAllowNull()); - slotDesc.setAutoInc(column.isAutoInc()); - } HiveTableSink sink = new HiveTableSink((HMSExternalTable) hiveTableSink.getTargetTable()); rootFragment.setSink(sink); return rootFragment; @@ -592,16 +583,6 @@ public PlanFragment visitPhysicalIcebergTableSink(PhysicalIcebergTableSink targetTableColumns = icebergTableSink.getTargetTable().getFullSchema(); - for (Column column : targetTableColumns) { - SlotDescriptor slotDesc = context.addSlotDesc(hiveTuple); - slotDesc.setType(column.getType()); - slotDesc.setColumn(column); - slotDesc.setIsNullable(column.isAllowNull()); - slotDesc.setAutoInc(column.isAutoInc()); - } List outputExprs = Lists.newArrayList(); icebergTableSink.getOutput().stream().map(Slot::getExprId) .forEach(exprId -> outputExprs.add(context.findSlotRef(exprId))); @@ -1135,31 +1116,21 @@ private void translateRuntimeFilter(PhysicalRelation physicalRelation, ScanNode @Override public PlanFragment visitPhysicalOneRowRelation(PhysicalOneRowRelation oneRowRelation, PlanTranslatorContext context) { - List slots = oneRowRelation.getLogicalProperties().getOutput(); + List slots = oneRowRelation.getOutput(); TupleDescriptor oneRowTuple = generateTupleDesc(slots, null, context); List legacyExprs = Lists.newArrayList(); - List expressionList = Lists.newArrayList(); for (NamedExpression namedExpression : oneRowRelation.getProjects()) { legacyExprs.add(ExpressionTranslator.translate(namedExpression, context)); - expressionList.add(namedExpression); - } - - for (int i = 0; i < legacyExprs.size(); i++) { - SlotDescriptor slotDescriptor = oneRowTuple.getSlots().get(i); - Expr expr = legacyExprs.get(i); - slotDescriptor.setSourceExpr(expr); - slotDescriptor.setIsNullable(slots.get(i).nullable()); } + List> materializedConstExprLists = Lists.newArrayList(); + materializedConstExprLists.add(legacyExprs); UnionNode unionNode = new UnionNode(context.nextPlanNodeId(), oneRowTuple.getId()); unionNode.setNereidsId(oneRowRelation.getId()); context.getNereidsIdToPlanNodeIdMap().put(oneRowRelation.getId(), unionNode.getId()); unionNode.setCardinality(1L); - List> constExpressionList = Lists.newArrayList(); - constExpressionList.add(expressionList); - finalizeForSetOperationNode(unionNode, oneRowTuple.getSlots(), new ArrayList<>(), - constExpressionList, new ArrayList<>(), context); + unionNode.setMaterializedConstExprLists(materializedConstExprLists); PlanFragment planFragment = createPlanFragment(unionNode, DataPartition.UNPARTITIONED, oneRowRelation); context.addPlanFragment(planFragment); @@ -1482,37 +1453,16 @@ public PlanFragment visitPhysicalAssertNumRows(PhysicalAssertNumRows childTuples = context.getTupleDesc(currentFragment.getPlanRoot()); - List childSlotDescriptors = childTuples.stream() - .map(TupleDescriptor::getSlots) - .flatMap(Collection::stream) - .collect(Collectors.toList()); - - // create output slot based on child output - Map childOutputMap = Maps.newHashMap(); - assertNumRows.child().getOutput().stream() - .map(SlotReference.class::cast) - .forEach(s -> childOutputMap.put(s.getExprId(), s)); - List slotDescriptors = Lists.newArrayList(); - for (SlotDescriptor slot : childSlotDescriptors) { - SlotReference sf = childOutputMap.get(context.findExprId(slot.getId())); - SlotDescriptor sd = context.createSlotDesc(tupleDescriptor, sf, slot.getParent().getTable()); - slotDescriptors.add(sd); - } - - // set all output slot nullable - slotDescriptors.forEach(sd -> sd.setIsNullable(true)); - addPlanRoot(currentFragment, assertNumRowsNode, assertNumRows); return currentFragment; } @@ -1874,15 +1824,10 @@ public PlanFragment visitPhysicalHashJoin( 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()); - if (hashOutputSlotReferenceMap.get(sf.getExprId()) != null) { - hashJoinNode.addSlotIdToHashOutputSlotIds(leftSlotDescriptor.getId()); - hashJoinNode.getHashOutputExprSlotIdMap().put(sf.getExprId(), leftSlotDescriptor.getId()); - } + sd = context.createSlotDesc(intermediateDescriptor, sf, leftSlotDescriptor.getParent().getTable()); + if (hashOutputSlotReferenceMap.get(sf.getExprId()) != null) { + hashJoinNode.addSlotIdToHashOutputSlotIds(leftSlotDescriptor.getId()); + hashJoinNode.getHashOutputExprSlotIdMap().put(sf.getExprId(), leftSlotDescriptor.getId()); } leftIntermediateSlotDescriptor.add(sd); } @@ -1891,15 +1836,10 @@ public PlanFragment visitPhysicalHashJoin( 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()); - if (hashOutputSlotReferenceMap.get(sf.getExprId()) != null) { - hashJoinNode.addSlotIdToHashOutputSlotIds(rightSlotDescriptor.getId()); - hashJoinNode.getHashOutputExprSlotIdMap().put(sf.getExprId(), rightSlotDescriptor.getId()); - } + sd = context.createSlotDesc(intermediateDescriptor, sf, rightSlotDescriptor.getParent().getTable()); + if (hashOutputSlotReferenceMap.get(sf.getExprId()) != null) { + hashJoinNode.addSlotIdToHashOutputSlotIds(rightSlotDescriptor.getId()); + hashJoinNode.getHashOutputExprSlotIdMap().put(sf.getExprId(), rightSlotDescriptor.getId()); } rightIntermediateSlotDescriptor.add(sd); } @@ -1907,31 +1847,20 @@ public PlanFragment visitPhysicalHashJoin( 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()); - // sd = context.createSlotDesc(intermediateDescriptor, sf); - if (hashOutputSlotReferenceMap.get(sf.getExprId()) != null) { - hashJoinNode.addSlotIdToHashOutputSlotIds(leftSlotDescriptor.getId()); - hashJoinNode.getHashOutputExprSlotIdMap().put(sf.getExprId(), leftSlotDescriptor.getId()); - } + sd = context.createSlotDesc(intermediateDescriptor, sf, leftSlotDescriptor.getParent().getTable()); + if (hashOutputSlotReferenceMap.get(sf.getExprId()) != null) { + hashJoinNode.addSlotIdToHashOutputSlotIds(leftSlotDescriptor.getId()); + hashJoinNode.getHashOutputExprSlotIdMap().put(sf.getExprId(), leftSlotDescriptor.getId()); } 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()); - if (hashOutputSlotReferenceMap.get(sf.getExprId()) != null) { - hashJoinNode.addSlotIdToHashOutputSlotIds(rightSlotDescriptor.getId()); - hashJoinNode.getHashOutputExprSlotIdMap().put(sf.getExprId(), rightSlotDescriptor.getId()); - } + sd = context.createSlotDesc(intermediateDescriptor, sf, rightSlotDescriptor.getParent().getTable()); + if (hashOutputSlotReferenceMap.get(sf.getExprId()) != null) { + hashJoinNode.addSlotIdToHashOutputSlotIds(rightSlotDescriptor.getId()); + hashJoinNode.getHashOutputExprSlotIdMap().put(sf.getExprId(), rightSlotDescriptor.getId()); } rightIntermediateSlotDescriptor.add(sd); } @@ -2508,7 +2437,6 @@ public PlanFragment visitPhysicalSetOperation( } List> distributeExprLists = getDistributeExprs(setOperation.children().toArray(new Plan[0])); TupleDescriptor setTuple = generateTupleDesc(setOperation.getOutput(), null, context); - List outputSlotDescs = new ArrayList<>(setTuple.getSlots()); SetOperationNode setOperationNode; // create setOperationNode @@ -2523,24 +2451,33 @@ public PlanFragment visitPhysicalSetOperation( } setOperationNode.setChildrenDistributeExprLists(distributeExprLists); setOperationNode.setNereidsId(setOperation.getId()); - List> resultExpressionLists = Lists.newArrayList(); context.getNereidsIdToPlanNodeIdMap().put(setOperation.getId(), setOperationNode.getId()); - for (List regularChildrenOutput : setOperation.getRegularChildrenOutputs()) { - resultExpressionLists.add(new ArrayList<>(regularChildrenOutput)); + for (PlanFragment childFragment : childrenFragments) { + setOperationNode.addChild(childFragment.getPlanRoot()); } - List> constExpressionLists = Lists.newArrayList(); if (setOperation instanceof PhysicalUnion) { - for (List unionConsts : ((PhysicalUnion) setOperation).getConstantExprsList()) { - constExpressionLists.add(new ArrayList<>(unionConsts)); + List> materializedConstExprLists = Lists.newArrayList(); + for (List constExpressionList : ((PhysicalUnion) setOperation).getConstantExprsList()) { + List exprList = Lists.newArrayList(); + for (NamedExpression expression : constExpressionList) { + exprList.add(ExpressionTranslator.translate(expression, context)); + } + materializedConstExprLists.add(exprList); } + setOperationNode.setMaterializedConstExprLists(materializedConstExprLists); } - for (PlanFragment childFragment : childrenFragments) { - setOperationNode.addChild(childFragment.getPlanRoot()); + List> materializedResultExprLists = Lists.newArrayList(); + for (int i = 0; i < setOperation.getRegularChildrenOutputs().size(); ++i) { + List resultExpressionList = setOperation.getRegularChildrenOutputs().get(i); + List exprList = Lists.newArrayList(); + for (int j = 0; j < resultExpressionList.size(); ++j) { + exprList.add(ExpressionTranslator.translate(resultExpressionList.get(j), context)); + } + materializedResultExprLists.add(exprList); } - finalizeForSetOperationNode(setOperationNode, outputSlotDescs, outputSlotDescs, - constExpressionLists, resultExpressionLists, context); + setOperationNode.setMaterializedResultExprLists(materializedResultExprLists); PlanFragment setOperationFragment; if (childrenFragments.isEmpty()) { @@ -3529,45 +3466,6 @@ private List getDistributeExpr(List childOutputIds, DistributionSp return Lists.newArrayList(); } - private void finalizeForSetOperationNode(SetOperationNode node, - List constExprSlots, - List resultExprSlots, - List> constExpressionLists, - List> resultExpressionLists, - PlanTranslatorContext context) { - if (node == null || constExprSlots == null || resultExprSlots == null - || constExpressionLists == null || resultExpressionLists == null || context == null) { - return; - } - - List> materializedConstExprLists = Lists.newArrayList(); - for (List constExpressionList : constExpressionLists) { - Preconditions.checkState(constExpressionList.size() == constExprSlots.size()); - List exprList = Lists.newArrayList(); - for (Expression expression : constExpressionList) { - exprList.add(ExpressionTranslator.translate(expression, context)); - } - materializedConstExprLists.add(exprList); - } - node.setMaterializedConstExprLists(materializedConstExprLists); - - List> materializedResultExprLists = Lists.newArrayList(); - for (int i = 0; i < resultExpressionLists.size(); ++i) { - List resultExpressionList = resultExpressionLists.get(i); - List exprList = Lists.newArrayList(); - Preconditions.checkState(resultExpressionList.size() == resultExprSlots.size()); - for (int j = 0; j < resultExpressionList.size(); ++j) { - exprList.add(ExpressionTranslator.translate(resultExpressionList.get(j), context)); - // TODO: reconsider this, we may change nullable info in previous nereids rules not here. - resultExprSlots.get(j) - .setIsNullable(resultExprSlots.get(j).getIsNullable() || exprList.get(j).isNullable()); - } - materializedResultExprLists.add(exprList); - } - node.setMaterializedResultExprLists(materializedResultExprLists); - Preconditions.checkState(node.getMaterializedResultExprLists().size() == node.getChildren().size()); - } - // matching the simple query: // 1. select xxx from tbl // 2. select xxx from tbl where xxx=yyy diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/load/NereidsLoadPlanInfoCollector.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/load/NereidsLoadPlanInfoCollector.java index 6cc6ca60cf07f7..303ab13547d143 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/load/NereidsLoadPlanInfoCollector.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/load/NereidsLoadPlanInfoCollector.java @@ -423,17 +423,6 @@ public Void visitLogicalOneRowRelation(LogicalOneRowRelation oneRowRelation, List slots = oneRowRelation.getLogicalProperties().getOutput(); TupleDescriptor oneRowTuple = generateTupleDesc(slots, null, context); - List legacyExprs = oneRowRelation.getProjects() - .stream() - .map(expr -> ExpressionTranslator.translate(expr, context)) - .collect(Collectors.toList()); - - for (int i = 0; i < legacyExprs.size(); i++) { - SlotDescriptor slotDescriptor = oneRowTuple.getSlots().get(i); - Expr expr = legacyExprs.get(i); - slotDescriptor.setSourceExpr(expr); - slotDescriptor.setIsNullable(slots.get(i).nullable()); - } loadPlanInfo.srcTupleId = oneRowTuple.getId(); loadPlanInfo.srcSlotIds = new ArrayList<>(oneRowTuple.getAllSlotIds()); loadPlanInfo.srcSlotIdToDefaultValueMap = Maps.newHashMap(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/AssertNumRowsNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/AssertNumRowsNode.java index 210743b94011d9..e5e8748e7f7bcc 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/AssertNumRowsNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/AssertNumRowsNode.java @@ -37,10 +37,8 @@ public class AssertNumRowsNode extends PlanNode { private String subqueryString; private AssertNumRowsElement.Assertion assertion; - private boolean shouldConvertOutputToNullable = false; - public AssertNumRowsNode(PlanNodeId id, PlanNode input, AssertNumRowsElement assertNumRowsElement, - boolean convertToNullable, TupleDescriptor tupleDescriptor) { + TupleDescriptor tupleDescriptor) { super(id, "ASSERT NUMBER OF ROWS", StatisticalType.ASSERT_NUM_ROWS_NODE); this.desiredNumOfRows = assertNumRowsElement.getDesiredNumOfRows(); this.subqueryString = assertNumRowsElement.getSubqueryString(); @@ -54,7 +52,6 @@ public AssertNumRowsNode(PlanNodeId id, PlanNode input, AssertNumRowsElement ass this.tblRefIds.addAll(input.getTblRefIds()); this.nullableTupleIds.addAll(input.getNullableTupleIds()); - this.shouldConvertOutputToNullable = convertToNullable; } @Override @@ -80,7 +77,7 @@ protected void toThrift(TPlanNode msg) { msg.assert_num_rows_node.setDesiredNumRows(desiredNumOfRows); msg.assert_num_rows_node.setSubqueryString(subqueryString); msg.assert_num_rows_node.setAssertion(assertion.toThrift()); - msg.assert_num_rows_node.setShouldConvertOutputToNullable(shouldConvertOutputToNullable); + msg.assert_num_rows_node.setShouldConvertOutputToNullable(true); } @Override From 135a807d3a538ad7cbbb1896100370110afc703b Mon Sep 17 00:00:00 2001 From: lichi Date: Wed, 24 Dec 2025 11:04:27 +0800 Subject: [PATCH 2/2] [fix](nullable) set SlotRef's nullable to right value for nestloop join (cherry picked from commit 33a47b648c226548ffdebcc4202015924c3e9613) --- .../translator/PhysicalPlanTranslator.java | 18 +- .../test_nestloop_join_nullable.out | 191 ++++++++++++++++++ .../test_nestloop_join_nullable.groovy | 114 +++++++++++ 3 files changed, 309 insertions(+), 14 deletions(-) create mode 100644 regression-test/data/nereids_p0/test_nestloop_join_nullable.out create mode 100644 regression-test/suites/nereids_p0/test_nestloop_join_nullable.groovy 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 37d10ce4d31d24..59508d1779311a 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 @@ -2038,24 +2038,14 @@ public PlanFragment visitPhysicalNestedLoopJoin( // 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); } 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 00000000000000..fe00b63ec9461f --- /dev/null +++ b/regression-test/data/nereids_p0/test_nestloop_join_nullable.out @@ -0,0 +1,191 @@ +-- 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 00000000000000..44618ce411f73f --- /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),(12,4378160,54,-14810,17886,-30200,-10060),(11,77,-43,null,-35,null,23),(10,-2333750,-18428,58,1504,-6105795,31),(9,30258,-158232,8149676,null,null,-1923047),(8,-30473,-29077,null,-9975,-60,null),(7,1447364,-17722,-5366279,-4911,3433200,null),(6,8,21708,-61,null,null,null),(5,-7131891,-15453,13205,4832507,-4572942,-57),(4,-61,2924909,-3996268,-63,-8108590,11731),(3,-902463,12,null,-6,8136,23281),(2,null,null,null,4533188,-26763,85),(1,-27575,null,null,null,-9,-42),(0,17583,-121,null,null,-79,-22443); + + 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,-20633,44),(12,7629243,null,-107,3637456,82,-39),(11,106,37,25249,null,2622107,null),(10,null,-13728,10270,-26,13731,92),(9,19752,58,null,-4083,1569134,473442),(8,null,-14922,-22053,null,1953,79),(7,-18243,null,null,-62,-87,-2355558),(6,-120,518201,null,null,-50,null),(5,5201336,5855553,-5913148,-8576,35,-1471873),(4,null,-30894,-24418,31495,null,-48),(3,-860330,7609530,73,6729250,-91,7695),(2,3009668,null,null,-26,2992,null),(1,-38,28,14143,null,-13643,-126),(0,-1141940,-50,null,7458207,66,null); + ''' + + 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; + ''' +}