[fix](Nereids) explain graph insert-select NPE (#28007)

This commit is contained in:
minghong
2023-12-07 17:25:44 +08:00
committed by GitHub
parent 9c63dfd692
commit bc12a05915
2 changed files with 79 additions and 4 deletions

View File

@ -67,10 +67,16 @@ public class PlanTreeBuilder {
}
sb.append("\n[Fragment: ").append(fragment.getFragmentSequenceNum()).append("]");
sb.append("\n").append(sink.getExplainString("", TExplainLevel.BRIEF));
sinkNode = new PlanTreeNode(
sink instanceof MultiCastDataSink ? ((MultiCastDataSink) sink).getDataStreamSinks().stream()
.map(s -> s.getExchNodeId()).collect(Collectors.toList())
: ImmutableList.of(sink.getExchNodeId()), sb.toString());
List<PlanNodeId> exchangeIds;
if (sink instanceof MultiCastDataSink) {
exchangeIds = ((MultiCastDataSink) sink).getDataStreamSinks().stream()
.map(s -> s.getExchNodeId()).collect(Collectors.toList());
} else if (sink.getExchNodeId() != null) {
exchangeIds = ImmutableList.of(sink.getExchNodeId());
} else {
exchangeIds = ImmutableList.of();
}
sinkNode = new PlanTreeNode(exchangeIds, sb.toString());
if (i == 0) {
// sink of first fragment, set it as tree root
treeRoot = sinkNode;

View File

@ -0,0 +1,69 @@
// 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("explain_graph") {
// filter about invisible column "DORIS_DELETE_SIGN = 0" has no impaction on partition pruning
String db = context.config.getDbNameByFile(context.file)
sql "use ${db}"
sql "SET enable_nereids_planner=true"
sql "SET enable_fallback_to_original_planner=false"
sql "set partition_pruning_expand_threshold=10;"
sql "set ignore_shape_nodes='PhysicalDistribute,PhysicalProject'"
sql "drop table if exists T1;"
sql """
CREATE TABLE T1 (
a INT NULL,
b INT NULL,
c INT NULL
) ENGINE=OLAP
UNIQUE KEY(`a`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`a`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"min_load_replica_num" = "-1",
"is_being_synced" = "false",
"storage_format" = "V2",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false",
"group_commit_interval_ms" = "10000"
); """
sql "drop table if exists T2;"
sql """
CREATE TABLE T2 (
a INT NULL,
b INT NULL,
c INT NULL
) ENGINE=OLAP
UNIQUE KEY(`a`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`a`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"min_load_replica_num" = "-1",
"is_being_synced" = "false",
"storage_format" = "V2",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false",
"group_commit_interval_ms" = "10000"
); """
// make sure "explain graph" could work with "insert select"
sql "explain graph insert into T2 select * from T1"
}