This is an automated email from the ASF dual-hosted git repository.
gabriellee 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 7ec32b4ac59 [Improvement](agg) Add a knob to control local exchange
(#62438)
7ec32b4ac59 is described below
commit 7ec32b4ac591047ef8c5c9c7093581180231905b
Author: Gabriel <[email protected]>
AuthorDate: Tue Apr 14 09:53:54 2026 +0800
[Improvement](agg) Add a knob to control local exchange (#62438)
Add a knob to control local exchange before agg
---
be/src/exec/operator/aggregation_sink_operator.h | 3 +++
be/src/exec/operator/distinct_streaming_aggregation_operator.h | 4 ++++
be/src/exec/operator/streaming_aggregation_operator.h | 3 +--
be/src/runtime/query_context.h | 6 ------
be/src/runtime/runtime_state.h | 5 +++++
fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java | 6 ++++++
gensrc/thrift/PaloInternalService.thrift | 1 +
7 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/be/src/exec/operator/aggregation_sink_operator.h
b/be/src/exec/operator/aggregation_sink_operator.h
index 6c720803c08..f0cc6b70d4e 100644
--- a/be/src/exec/operator/aggregation_sink_operator.h
+++ b/be/src/exec/operator/aggregation_sink_operator.h
@@ -163,6 +163,9 @@ public:
:
DataSinkOperatorX<AggSinkLocalState>::required_data_distribution(
state);
}
+ if (!_needs_finalize && !state->enable_local_exchange_before_agg()) {
+ return
DataSinkOperatorX<AggSinkLocalState>::required_data_distribution(state);
+ }
return _is_colocate && _require_bucket_distribution
? DataDistribution(ExchangeType::BUCKET_HASH_SHUFFLE,
_partition_exprs)
: DataDistribution(ExchangeType::HASH_SHUFFLE,
_partition_exprs);
diff --git a/be/src/exec/operator/distinct_streaming_aggregation_operator.h
b/be/src/exec/operator/distinct_streaming_aggregation_operator.h
index 9f9ee3a266a..abf42eb50cc 100644
--- a/be/src/exec/operator/distinct_streaming_aggregation_operator.h
+++ b/be/src/exec/operator/distinct_streaming_aggregation_operator.h
@@ -118,6 +118,10 @@ public:
if (_needs_finalize && _probe_expr_ctxs.empty()) {
return {ExchangeType::NOOP};
}
+ if (!_needs_finalize && !state->enable_local_exchange_before_agg()) {
+ return
StatefulOperatorX<DistinctStreamingAggLocalState>::required_data_distribution(
+ state);
+ }
if (_needs_finalize || (!_probe_expr_ctxs.empty() &&
!_is_streaming_preagg)) {
return _is_colocate && _require_bucket_distribution
?
DataDistribution(ExchangeType::BUCKET_HASH_SHUFFLE, _partition_exprs)
diff --git a/be/src/exec/operator/streaming_aggregation_operator.h
b/be/src/exec/operator/streaming_aggregation_operator.h
index 1fe545e3a0c..40a8de28244 100644
--- a/be/src/exec/operator/streaming_aggregation_operator.h
+++ b/be/src/exec/operator/streaming_aggregation_operator.h
@@ -226,8 +226,7 @@ public:
state->enable_streaming_agg_hash_join_force_passthrough()) {
return DataDistribution(ExchangeType::PASSTHROUGH);
}
- if (!state->get_query_ctx()->should_be_shuffled_agg(
- StatefulOperatorX<StreamingAggLocalState>::node_id())) {
+ if (!_needs_finalize && !state->enable_local_exchange_before_agg()) {
return
StatefulOperatorX<StreamingAggLocalState>::required_data_distribution(state);
}
if (_partition_exprs.empty()) {
diff --git a/be/src/runtime/query_context.h b/be/src/runtime/query_context.h
index 7f58e20ce30..16a19afa489 100644
--- a/be/src/runtime/query_context.h
+++ b/be/src/runtime/query_context.h
@@ -190,12 +190,6 @@ public:
return _query_options.__isset.enable_force_spill &&
_query_options.enable_force_spill;
}
const TQueryOptions& query_options() const { return _query_options; }
- bool should_be_shuffled_agg(int node_id) const {
- return _query_options.__isset.shuffled_agg_ids &&
- std::any_of(_query_options.shuffled_agg_ids.begin(),
- _query_options.shuffled_agg_ids.end(),
- [&](const int id) -> bool { return id == node_id;
});
- }
// global runtime filter mgr, the runtime filter have remote target or
// need local merge should regist here. before publish() or
push_to_remote()
diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h
index e3fc0132e20..d241a5b076e 100644
--- a/be/src/runtime/runtime_state.h
+++ b/be/src/runtime/runtime_state.h
@@ -558,6 +558,11 @@ public:
_query_options.enable_streaming_agg_hash_join_force_passthrough;
}
+ bool enable_local_exchange_before_agg() const {
+ return _query_options.__isset.enable_local_exchange_before_agg &&
+ _query_options.enable_local_exchange_before_agg;
+ }
+
bool enable_distinct_streaming_agg_force_passthrough() const {
return
_query_options.__isset.enable_distinct_streaming_agg_force_passthrough &&
_query_options.enable_distinct_streaming_agg_force_passthrough;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index 4bba3ad35f9..78fc4367b66 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -171,6 +171,7 @@ public class SessionVariable implements Serializable,
Writable {
public static final String ENABLE_DISTINCT_STREAMING_AGG_FORCE_PASSTHROUGH
=
"enable_distinct_streaming_agg_force_passthrough";
public static final String ENABLE_BROADCAST_JOIN_FORCE_PASSTHROUGH =
"enable_broadcast_join_force_passthrough";
+ public static final String ENABLE_LOCAL_EXCHANGE_BEFORE_AGG =
"enable_local_exchange_before_agg";
public static final String DISABLE_COLOCATE_PLAN = "disable_colocate_plan";
public static final String COLOCATE_MAX_PARALLEL_NUM =
"colocate_max_parallel_num";
public static final String ENABLE_BUCKET_SHUFFLE_JOIN =
"enable_bucket_shuffle_join";
@@ -1300,6 +1301,9 @@ public class SessionVariable implements Serializable,
Writable {
@VarAttrDef.VarAttr(name =
ENABLE_STREAMING_AGG_HASH_JOIN_FORCE_PASSTHROUGH, fuzzy = true)
public boolean enableStreamingAggHashJoinForcePassthrough = true;
+ @VarAttrDef.VarAttr(name = ENABLE_LOCAL_EXCHANGE_BEFORE_AGG, fuzzy = true)
+ public boolean enableLocalExchangeBeforeAgg = true;
+
@VarAttrDef.VarAttr(name =
ENABLE_DISTINCT_STREAMING_AGG_FORCE_PASSTHROUGH, fuzzy = true)
public boolean enableDistinctStreamingAggForcePassthrough = true;
@@ -3615,6 +3619,7 @@ public class SessionVariable implements Serializable,
Writable {
this.enableCommonExpPushDownForInvertedIndex = random.nextBoolean();
this.disableStreamPreaggregations = random.nextBoolean();
this.enableStreamingAggHashJoinForcePassthrough = random.nextBoolean();
+ this.enableLocalExchangeBeforeAgg = random.nextBoolean();
this.enableDistinctStreamingAggForcePassthrough = random.nextBoolean();
this.enableBroadcastJoinForcePassthrough = random.nextBoolean();
this.enableShareHashTableForBroadcastJoin = random.nextBoolean();
@@ -5350,6 +5355,7 @@ public class SessionVariable implements Serializable,
Writable {
tResult.setDisableStreamPreaggregations(disableStreamPreaggregations);
tResult.setEnableDistinctStreamingAggregation(enableDistinctStreamingAggregation);
tResult.setEnableStreamingAggHashJoinForcePassthrough(enableStreamingAggHashJoinForcePassthrough);
+ tResult.setEnableLocalExchangeBeforeAgg(enableLocalExchangeBeforeAgg);
tResult.setEnableDistinctStreamingAggForcePassthrough(enableDistinctStreamingAggForcePassthrough);
tResult.setEnableBroadcastJoinForcePassthrough(enableBroadcastJoinForcePassthrough);
tResult.setPartitionTopnMaxPartitions(partitionTopNMaxPartitions);
diff --git a/gensrc/thrift/PaloInternalService.thrift
b/gensrc/thrift/PaloInternalService.thrift
index f50bf0c68da..65c567365b6 100644
--- a/gensrc/thrift/PaloInternalService.thrift
+++ b/gensrc/thrift/PaloInternalService.thrift
@@ -473,6 +473,7 @@ struct TQueryOptions {
210: optional double max_scan_mem_ratio = 0.3;
211: optional bool enable_adaptive_scan = false;
+ 212: optional bool enable_local_exchange_before_agg = true;
// For cloud, to control if the content would be written into file cache
// In write path, to control if the content would be written into file cache.
// In read path, read from file cache or remote storage when execute query.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]