This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.2 by this push:
new 368131f862d branch-4.2: [fix](runtime-filter) Skip unnecessary
local-only merge metadata #70305 (#70845)
368131f862d is described below
commit 368131f862d18579026e52014fdf4e1e6be490cd
Author: Jerry Hu <[email protected]>
AuthorDate: Wed Nov 25 11:39:34 2026 +0800
branch-4.2: [fix](runtime-filter) Skip unnecessary local-only merge
metadata #70305 (#70845)
### What problem does this PR solve?
Issue Number: None
Cherry-picked from #70305 to `branch-4.2`.
Local-only runtime filters can unnecessarily populate global merge
metadata, retaining the merge backend's `QueryContext` and delaying its
final profile report even though no global merge RPC is expected.
This change computes eligibility across the complete distributed plan
and omits global merge maps for eligible non-recursive queries without
remote runtime-filter targets. Remote or mixed filters, recursive CTEs,
incomplete plans, and distinct workers sharing a BRPC endpoint retain
the existing metadata. Merge addresses, TopN descriptors, and plan-node
local runtime filters are preserved. There are no BE lifecycle or Thrift
protocol changes; remote-filter context retention is unchanged.
#### Backport adaptations
- Preserve existing `branch-4.2` FE tests and use Java 8-compatible
`ImmutableList` factories in the added coverage.
- Disable runtime-filter pruning only in the profile regression so its
small fixture actually generates runtime filters. Keep the RF/Exchange
assertions, expected results, and original 10-second profile completion
deadline.
### Release note
Avoid unnecessary query-context retention and delayed final profile
reporting for eligible local-only runtime-filter queries.
### Check List (For Author)
- Test:
- [x] Unit Test
- [x] Regression test
- Behavior changed:
- [x] Yes. Omit unnecessary global RF merge maps only when the complete
query plan is eligible.
- Does this need documentation?
- [x] No.
#### Validation
- `./run-fe-ut.sh --run
org.apache.doris.qe.runtime.ThriftPlansBuilderTest,org.apache.doris.qe.runtime.RuntimeFiltersThriftBuilderTest`:
10 tests passed (7 + 3); no failures, errors, or skips.
- `cd fe && mvn -pl fe-common,fe-core -am checkstyle:check
-Dcheckstyle.skip=false`: passed.
- `./build.sh --be --fe -j 48`: passed.
- `./run-regression-test.sh --conf <isolated-conf> --run -d
query_profile,recursive_cte -s
rf_merge_context_profile,rf_merge_context_reuse -parallel 1`: 2 suites
passed; no failures or skips. `<isolated-conf>` denotes the
worktree-specific configuration.
- Final diff whitespace and backport completeness checks passed.
SQL/Profile validation used a single BE with native internal-table
execution and Java extension support disabled. Multi-BE, mixed-version,
and full CI validation have not been run.
---
.../doris/qe/runtime/ThriftPlansBuilder.java | 37 +++++-
.../doris/qe/runtime/ThriftPlansBuilderTest.java | 140 +++++++++++++++++++++
.../query_profile/rf_merge_context_profile.out | 8 ++
.../data/recursive_cte/rf_merge_context_reuse.out | 6 +
.../query_profile/rf_merge_context_profile.groovy | 59 +++++++++
.../recursive_cte/rf_merge_context_reuse.groovy | 42 +++++++
6 files changed, 289 insertions(+), 3 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/qe/runtime/ThriftPlansBuilder.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/runtime/ThriftPlansBuilder.java
index 01401934586..d02369a14af 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/qe/runtime/ThriftPlansBuilder.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/qe/runtime/ThriftPlansBuilder.java
@@ -108,6 +108,7 @@ public class ThriftPlansBuilder {
List<PipelineDistributedPlan> distributedPlans =
coordinatorContext.distributedPlans;
Set<Integer> fragmentToNotifyClose =
setParamsForRecursiveCteNode(distributedPlans,
coordinatorContext.runtimeFilters);
+ boolean omitRfMergeParams = canOmitRfMergeParams(distributedPlans,
coordinatorContext.runtimeFilters);
// Determine whether this query is assigned to a single backend and
propagate it to
// TQueryOptions so that BE can apply more appropriate optimization
strategies (e.g.
@@ -155,7 +156,7 @@ public class ThriftPlansBuilder {
for (Entry<DistributedPlanWorker, TPipelineFragmentParams> kv :
workerToCurrentFragment.entrySet()) {
TPipelineFragmentParamsList fragments =
fragmentsGroupByWorker.computeIfAbsent(
kv.getKey(), w -> beToThrift(kv.getKey(),
runtimeFiltersThriftBuilder,
- topNFilterThriftSupplier));
+ topNFilterThriftSupplier, omitRfMergeParams));
fragments.addToParamsList(kv.getValue());
}
}
@@ -403,17 +404,47 @@ public class ThriftPlansBuilder {
return destination;
}
+ static boolean canOmitRfMergeParams(
+ List<PipelineDistributedPlan> distributedPlans,
List<RuntimeFilter> runtimeFilters) {
+ // Local RFs are registered from plan nodes, not the global merge
metadata. Omitting this
+ // metadata avoids retaining a QueryContext solely for local RFs that
never send merge RPCs.
+ if (distributedPlans.isEmpty() ||
runtimeFilters.stream().anyMatch(RuntimeFilter::hasRemoteTargets)) {
+ return false;
+ }
+ Map<String, DistributedPlanWorker> endpointOwners = Maps.newHashMap();
+ for (PipelineDistributedPlan plan : distributedPlans) {
+ for (AssignedJob job : plan.getInstanceJobs()) {
+ DistributedPlanWorker worker = job.getAssignedWorker();
+ DistributedPlanWorker owner =
endpointOwners.putIfAbsent(worker.brpcAddress(), worker);
+ // Different catalog workers can share a BE but receive
separate query-wide start RPCs.
+ // The first start may finish the query before the second
start reaches that BE.
+ if (owner != null && !owner.equals(worker)) {
+ return false;
+ }
+ }
+ PlanNode root = plan.getFragmentJob().getFragment().getPlanRoot();
+ // Even an empty recursive reset RPC looks up the merge BE's
QueryContext. Preserve
+ // the original metadata and its ownership for recursive queries
on any BE.
+ if (root == null || !root.collectInCurrentFragment(
+ node -> node instanceof RecursiveCteNode || node
instanceof RecursiveCteScanNode).isEmpty()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
private static TPipelineFragmentParamsList beToThrift(
DistributedPlanWorker worker,
RuntimeFiltersThriftBuilder runtimeFiltersThriftBuilder,
- Supplier<List<TTopnFilterDesc>> topNFilterThriftSupplier) {
+ Supplier<List<TTopnFilterDesc>> topNFilterThriftSupplier,
+ boolean omitRfMergeParams) {
TPipelineFragmentParamsList beParam = new
TPipelineFragmentParamsList();
TRuntimeFilterInfo runtimeFilterInfo = new TRuntimeFilterInfo();
runtimeFilterInfo.setTopnFilterDescs(topNFilterThriftSupplier.get());
TRuntimeFilterParams runtimeFilterParams = new TRuntimeFilterParams();
runtimeFilterParams.setRuntimeFilterMergeAddr(runtimeFiltersThriftBuilder.mergeAddress);
- if
(worker.host().equals(runtimeFiltersThriftBuilder.mergeAddress.getHostname())
+ if (!omitRfMergeParams &&
worker.host().equals(runtimeFiltersThriftBuilder.mergeAddress.getHostname())
&& worker.brpcPort() ==
runtimeFiltersThriftBuilder.mergeAddress.getPort()) {
// only set following information for merge BE node
runtimeFiltersThriftBuilder.populateRuntimeFilterParams(runtimeFilterParams);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/qe/runtime/ThriftPlansBuilderTest.java
b/fe/fe-core/src/test/java/org/apache/doris/qe/runtime/ThriftPlansBuilderTest.java
index 62a83172f94..7f485122b37 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/qe/runtime/ThriftPlansBuilderTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/qe/runtime/ThriftPlansBuilderTest.java
@@ -19,18 +19,37 @@ package org.apache.doris.qe.runtime;
import org.apache.doris.analysis.TupleDescriptor;
import org.apache.doris.analysis.TupleId;
+import org.apache.doris.common.IdGenerator;
+import org.apache.doris.common.jmockit.Deencapsulation;
+import org.apache.doris.nereids.trees.plans.distribute.PipelineDistributedPlan;
+import org.apache.doris.nereids.trees.plans.distribute.worker.BackendWorker;
import
org.apache.doris.nereids.trees.plans.distribute.worker.DistributedPlanWorker;
import org.apache.doris.nereids.trees.plans.distribute.worker.job.AssignedJob;
import
org.apache.doris.nereids.trees.plans.distribute.worker.job.DefaultScanSource;
import
org.apache.doris.nereids.trees.plans.distribute.worker.job.LocalShuffleAssignedJob;
import
org.apache.doris.nereids.trees.plans.distribute.worker.job.UnassignedJob;
+import org.apache.doris.planner.PlanFragmentId;
+import org.apache.doris.planner.PlanNode;
import org.apache.doris.planner.PlanNodeId;
+import org.apache.doris.planner.RecursiveCteNode;
import org.apache.doris.planner.RecursiveCteScanNode;
+import org.apache.doris.planner.RuntimeFilter;
+import org.apache.doris.planner.RuntimeFilterId;
import org.apache.doris.planner.ScanNode;
import org.apache.doris.planner.SortNode;
+import org.apache.doris.system.Backend;
+import org.apache.doris.thrift.TExpr;
+import org.apache.doris.thrift.TPipelineFragmentParamsList;
import org.apache.doris.thrift.TRecCTETarget;
+import org.apache.doris.thrift.TRuntimeFilterDesc;
+import org.apache.doris.thrift.TRuntimeFilterParams;
+import org.apache.doris.thrift.TRuntimeFilterType;
+import org.apache.doris.thrift.TTopnFilterDesc;
import org.apache.doris.thrift.TUniqueId;
+import com.google.common.collect.ImmutableList;
+import org.apache.thrift.TDeserializer;
+import org.apache.thrift.TSerializer;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -38,8 +57,129 @@ import org.mockito.Mockito;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
public class ThriftPlansBuilderTest {
+ private final IdGenerator<RuntimeFilterId> runtimeFilterIds =
RuntimeFilterId.createGenerator();
+
+ @Test
+ public void testLocalOnlyRfsOmitMergeParamsOnWire() throws Exception {
+ BackendWorker worker = newBackendWorker(0, 1, "127.0.0.1");
+ PipelineDistributedPlan plan =
mockPlanWithRoot(Mockito.mock(PlanNode.class), worker);
+ assertRfMergeParams(ImmutableList.of(plan),
ImmutableList.of(newRuntimeFilter(false)), true);
+ assertRfMergeParams(ImmutableList.of(plan), Collections.emptyList(),
true);
+ }
+
+ @Test
+ public void testRemoteAndMixedRfsKeepMergeParamsOnWire() throws Exception {
+ BackendWorker worker = newBackendWorker(0, 1, "127.0.0.1");
+ PipelineDistributedPlan plan =
mockPlanWithRoot(Mockito.mock(PlanNode.class), worker);
+ RuntimeFilter remote = newRuntimeFilter(true);
+ assertRfMergeParams(ImmutableList.of(plan), ImmutableList.of(remote),
false);
+ assertRfMergeParams(ImmutableList.of(plan),
ImmutableList.of(newRuntimeFilter(false), remote), false);
+ }
+
+ @Test
+ public void testRecursiveAndIncompletePlansKeepMergeParamsOnWire() throws
Exception {
+ BackendWorker worker = newBackendWorker(0, 1, "127.0.0.1");
+ List<RuntimeFilter> filters =
ImmutableList.of(newRuntimeFilter(false));
+
Assertions.assertFalse(ThriftPlansBuilder.canOmitRfMergeParams(Collections.emptyList(),
filters));
+ PipelineDistributedPlan mergePlan =
mockPlanWithRoot(Mockito.mock(PlanNode.class), worker);
+ // A recursive node on another fragment can still send an empty
global-reset RPC.
+ for (PlanNode root :
ImmutableList.of(Mockito.mock(RecursiveCteNode.class),
Mockito.mock(RecursiveCteScanNode.class))) {
+ PipelineDistributedPlan recursivePlan = mockPlanWithRoot(root,
worker);
+ assertRfMergeParams(ImmutableList.of(mergePlan, recursivePlan),
filters, false);
+ }
+
Mockito.when(mergePlan.getFragmentJob().getFragment().getPlanRoot()).thenReturn(null);
+ assertRfMergeParams(ImmutableList.of(mergePlan), filters, false);
+ }
+
+ private PipelineDistributedPlan mockPlanWithRoot(PlanNode root,
BackendWorker worker) {
+ PipelineDistributedPlan plan =
Mockito.mock(PipelineDistributedPlan.class, Mockito.RETURNS_DEEP_STUBS);
+
Mockito.when(plan.getFragmentJob().getFragment().getPlanRoot()).thenReturn(root);
+ AssignedJob job = newAssignedJob(worker, new TUniqueId());
+ Mockito.when(plan.getInstanceJobs()).thenReturn(ImmutableList.of(job));
+
Mockito.when(root.collectInCurrentFragment(Mockito.any())).thenAnswer(invocation
-> {
+ Predicate<PlanNode> predicate = invocation.getArgument(0);
+ return predicate.test(root) ? ImmutableList.of(root) :
Collections.emptyList();
+ });
+ return plan;
+ }
+
+ @Test
+ public void testDistinctWorkersAtSameEndpointKeepMergeParamsOnWire()
throws Exception {
+ BackendWorker internalWorker = newBackendWorker(0, 1, "127.0.0.1");
+ BackendWorker catalogWorker = newBackendWorker(1, 1, "127.0.0.1");
+ BackendWorker remoteWorker = newBackendWorker(0, 2, "127.0.0.2");
+ AssignedJob catalogJob = newAssignedJob(catalogWorker, new
TUniqueId(2, 2));
+ AssignedJob sameWorkerJob = newAssignedJob(internalWorker, new
TUniqueId(2, 2));
+ AssignedJob remoteJob = newAssignedJob(remoteWorker, new TUniqueId(2,
2));
+
+ PipelineDistributedPlan firstPlan =
mockPlanWithRoot(Mockito.mock(PlanNode.class), internalWorker);
+ PipelineDistributedPlan secondPlan =
mockPlanWithRoot(Mockito.mock(PlanNode.class), catalogWorker);
+
Mockito.when(secondPlan.getInstanceJobs()).thenReturn(ImmutableList.of(catalogJob));
+ Assertions.assertEquals(internalWorker.brpcAddress(),
catalogWorker.brpcAddress());
+ Assertions.assertNotEquals(internalWorker, catalogWorker);
+ List<RuntimeFilter> filters =
ImmutableList.of(newRuntimeFilter(false));
+ assertRfMergeParams(ImmutableList.of(firstPlan, secondPlan), filters,
false);
+
+
Mockito.when(secondPlan.getInstanceJobs()).thenReturn(ImmutableList.of(sameWorkerJob));
+ assertRfMergeParams(ImmutableList.of(firstPlan, secondPlan), filters,
true);
+
+
Mockito.when(secondPlan.getInstanceJobs()).thenReturn(ImmutableList.of(remoteJob));
+ assertRfMergeParams(ImmutableList.of(firstPlan, secondPlan), filters,
true);
+ }
+
+ private BackendWorker newBackendWorker(long catalogId, long backendId,
String host) {
+ Backend backend = new Backend(backendId, host, 9050);
+ backend.setBrpcPort(8060);
+ return new BackendWorker(catalogId, backend);
+ }
+
+ private RuntimeFilter newRuntimeFilter(boolean remote) {
+ RuntimeFilterId id = runtimeFilterIds.getNextId();
+ TRuntimeFilterDesc desc = new TRuntimeFilterDesc()
+ .setFilterId(id.asInt()).setSrcExpr(new
TExpr(Collections.emptyList())).setExprOrder(0)
+
.setPlanIdToTargetExpr(Collections.emptyMap()).setIsBroadcastJoin(false)
+
.setHasLocalTargets(!remote).setHasRemoteTargets(remote).setType(TRuntimeFilterType.BLOOM);
+ RuntimeFilter filter = Mockito.mock(RuntimeFilter.class);
+ Mockito.when(filter.getFilterId()).thenReturn(id);
+ Mockito.when(filter.hasRemoteTargets()).thenReturn(remote);
+ Mockito.when(filter.toThrift()).thenReturn(desc);
+ return filter;
+ }
+
+ private void assertRfMergeParams(List<PipelineDistributedPlan> plans,
List<RuntimeFilter> filters,
+ boolean omitted) throws Exception {
+ Set<RuntimeFilterId> ids =
filters.stream().map(RuntimeFilter::getFilterId).collect(Collectors.toSet());
+ for (int i = 0; i < plans.size(); i++) {
+
Mockito.when(plans.get(i).getFragmentJob().getFragment().getFragmentId()).thenReturn(new
PlanFragmentId(i));
+
Mockito.when(plans.get(i).getFragmentJob().getFragment().getBuilderRuntimeFilterIds()).thenReturn(ids);
+
Mockito.when(plans.get(i).getFragmentJob().getFragment().getTargetRuntimeFilterIds()).thenReturn(ids);
+ }
+ RuntimeFiltersThriftBuilder builder =
RuntimeFiltersThriftBuilder.compute(filters, plans);
+ DistributedPlanWorker worker = plans.get(plans.size() -
1).getInstanceJobs().get(0).getAssignedWorker();
+ boolean omitRfMergeParams =
ThriftPlansBuilder.canOmitRfMergeParams(plans, filters);
+ Assertions.assertEquals(omitted, omitRfMergeParams);
+ TTopnFilterDesc topn = new TTopnFilterDesc(9, true, false,
Collections.emptyMap());
+ Supplier<List<TTopnFilterDesc>> topnFilters = () ->
ImmutableList.of(topn);
+ TPipelineFragmentParamsList params = Deencapsulation.invoke(
+ ThriftPlansBuilder.class, "beToThrift", worker, builder,
topnFilters, omitRfMergeParams);
+ TPipelineFragmentParamsList decoded = new
TPipelineFragmentParamsList();
+ new TDeserializer().deserialize(decoded, new
TSerializer().serialize(params));
+
+ TRuntimeFilterParams expected = new
TRuntimeFilterParams().setRuntimeFilterMergeAddr(builder.mergeAddress);
+ if (!omitted) {
+ // Compare all merge metadata with the original builder, including
mixed local/remote RFs.
+ builder.populateRuntimeFilterParams(expected);
+ }
+ Assertions.assertEquals(expected,
decoded.getRuntimeFilterInfo().getRuntimeFilterParams());
+ Assertions.assertEquals(ImmutableList.of(topn),
decoded.getRuntimeFilterInfo().getTopnFilterDescs());
+ }
+
@Test
public void testSetRuntimePredicateForNonOlapScanNode() {
ScanNode scanNode = Mockito.mock(ScanNode.class);
diff --git a/regression-test/data/query_profile/rf_merge_context_profile.out
b/regression-test/data/query_profile/rf_merge_context_profile.out
new file mode 100644
index 00000000000..36ab0fcde89
--- /dev/null
+++ b/regression-test/data/query_profile/rf_merge_context_profile.out
@@ -0,0 +1,8 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !join --
+2 20
+4 40
+
+-- !remote --
+2 20
+4 40
diff --git a/regression-test/data/recursive_cte/rf_merge_context_reuse.out
b/regression-test/data/recursive_cte/rf_merge_context_reuse.out
new file mode 100644
index 00000000000..1d2d81f8316
--- /dev/null
+++ b/regression-test/data/recursive_cte/rf_merge_context_reuse.out
@@ -0,0 +1,6 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !recursive --
+1
+2
+3
+4
diff --git
a/regression-test/suites/query_profile/rf_merge_context_profile.groovy
b/regression-test/suites/query_profile/rf_merge_context_profile.groovy
new file mode 100644
index 00000000000..70ad5940491
--- /dev/null
+++ b/regression-test/suites/query_profile/rf_merge_context_profile.groovy
@@ -0,0 +1,59 @@
+// 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.
+
+import org.apache.doris.regression.action.ProfileAction
+
+suite('rf_merge_context_profile', 'nonConcurrent') {
+ sql 'drop table if exists rf_merge_profile_probe'
+ sql 'drop table if exists rf_merge_profile_build'
+ sql '''create table rf_merge_profile_probe (k int, v int) duplicate key(k)
+ distributed by hash(k) buckets 4 properties ("replication_num" =
"1")'''
+ sql '''create table rf_merge_profile_build (k int) duplicate key(k)
+ distributed by hash(k) buckets 4 properties ("replication_num" =
"1")'''
+ sql 'insert into rf_merge_profile_probe values (1, 10), (2, 20), (3, 30),
(4, 40)'
+ sql 'insert into rf_merge_profile_build values (2), (4)'
+
+ sql 'set enable_profile=true'
+ // Keep the tiny test tables from pruning the runtime filters under test.
+ sql 'set enable_runtime_filter_prune=false'
+ sql "set runtime_filter_mode='LOCAL'"
+ String localPlan = sql('''explain select p.k, p.v from
rf_merge_profile_probe p
+ join [broadcast] rf_merge_profile_build b on p.k
= b.k order by p.k''').toString()
+ assertTrue(localPlan.contains('runtime filters: RF'))
+ order_qt_join '''select p.k, p.v from rf_merge_profile_probe p
+ join [broadcast] rf_merge_profile_build b on p.k = b.k
order by p.k'''
+
+ // The profile check is tied to this query text, not to an unrelated
latest profile.
+ // Ten seconds is the FE's normal completion window; the helper's
30-second default
+ // would hide a delayed final report.
+ String token = UUID.randomUUID().toString()
+ sql """select '${token}' as profile_marker, p.k, p.v from
rf_merge_profile_probe p
+ join [broadcast] rf_merge_profile_build b on p.k = b.k
+ where p.k > 0 order by p.k"""
+ new ProfileAction(context).getProfileBySql(token, ['Fragment'], 10000, 200)
+
+ // The shuffle hint puts the probe scan across an Exchange from the join,
so
+ // these RFs exercise remote merge/publish even on a one-BE test cluster.
Only query
+ // correctness is checked: remote RF contexts keep their original delayed
lifetime.
+ sql "set runtime_filter_mode='GLOBAL'"
+ String remotePlan = sql('''explain select p.k, p.v from
rf_merge_profile_probe p
+ join [shuffle] rf_merge_profile_build b on p.k
= b.k order by p.k''').toString()
+ assertTrue(remotePlan.contains('INNER JOIN('), remotePlan)
+ assertTrue(remotePlan.contains('VEXCHANGE'), remotePlan)
+ assertTrue(remotePlan.contains('runtime filters: RF'), remotePlan)
+ order_qt_remote '''select p.k, p.v from rf_merge_profile_probe p
+ join [shuffle] rf_merge_profile_build b on p.k = b.k
order by p.k'''
+}
diff --git a/regression-test/suites/recursive_cte/rf_merge_context_reuse.groovy
b/regression-test/suites/recursive_cte/rf_merge_context_reuse.groovy
new file mode 100644
index 00000000000..05fec4b26a4
--- /dev/null
+++ b/regression-test/suites/recursive_cte/rf_merge_context_reuse.groovy
@@ -0,0 +1,42 @@
+// 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('rf_merge_context_reuse') {
+ sql 'drop table if exists rf_merge_reuse_edges'
+ sql '''create table rf_merge_reuse_edges (src int, dst int) duplicate
key(src)
+ distributed by hash(src) buckets 4 properties ("replication_num" =
"1")'''
+ sql 'insert into rf_merge_reuse_edges values (1, 2), (2, 3), (3, 4)'
+
+ String plan = sql('''explain with recursive numbers(n) as (
+ select cast(1 as int)
+ union all
+ select cast(e.dst as int) from
rf_merge_reuse_edges e
+ inner join [shuffle] numbers r on e.src = r.n
where r.n < 4
+ ) select n from numbers order by n''').toString()
+ // The recursive join must publish RFs across an Exchange on every round;
+ // a constants-only recursive query never exercises the merge-context
reset.
+ assertTrue(plan.contains('INNER JOIN('), plan)
+ assertTrue(plan.contains('runtime filters: RF'), plan)
+ assertTrue(plan.contains('-> src'), plan)
+ assertTrue(plan.contains('VEXCHANGE'), plan)
+
+ order_qt_recursive '''with recursive numbers(n) as (
+ select cast(1 as int)
+ union all
+ select cast(e.dst as int) from
rf_merge_reuse_edges e
+ inner join [shuffle] numbers r on e.src = r.n
where r.n < 4
+ ) select n from numbers order by n'''
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]