diff --git a/be/src/exec/operator/streaming_aggregation_operator.h b/be/src/exec/operator/streaming_aggregation_operator.h index 5ed6d1481d5fcc..18dcb4ca906036 100644 --- a/be/src/exec/operator/streaming_aggregation_operator.h +++ b/be/src/exec/operator/streaming_aggregation_operator.h @@ -220,7 +220,9 @@ class StreamingAggOperatorX MOCK_REMOVE(final) : public StatefulOperatorXenable_streaming_agg_hash_join_force_passthrough()) { return DataDistribution(ExchangeType::PASSTHROUGH); } - if (!_needs_finalize && !state->enable_local_exchange_before_agg()) { + // Keep streaming aggregation on its inherited distribution unless the dedicated switch + // explicitly enables a local hash exchange. + if (!state->enable_local_exchange_before_streaming_agg()) { return StatefulOperatorX::required_data_distribution(state); } if (_partition_exprs.empty()) { diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h index fc764085c8698a..688ae013a94faf 100644 --- a/be/src/runtime/runtime_state.h +++ b/be/src/runtime/runtime_state.h @@ -590,6 +590,11 @@ class RuntimeState { _query_options.enable_local_exchange_before_agg; } + bool enable_local_exchange_before_streaming_agg() const { + return _query_options.__isset.enable_local_exchange_before_streaming_agg && + _query_options.enable_local_exchange_before_streaming_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 f44098cbfd1a60..ac6e968d4f33fb 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 @@ -172,6 +172,8 @@ public class SessionVariable implements Serializable, Writable { "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 ENABLE_LOCAL_EXCHANGE_BEFORE_STREAMING_AGG = + "enable_local_exchange_before_streaming_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"; @@ -1377,6 +1379,9 @@ public void checkQuerySlotCount(String slotCnt) { @VariableMgr.VarAttr(name = ENABLE_LOCAL_EXCHANGE_BEFORE_AGG, fuzzy = true) public boolean enableLocalExchangeBeforeAgg = true; + @VariableMgr.VarAttr(name = ENABLE_LOCAL_EXCHANGE_BEFORE_STREAMING_AGG, fuzzy = true) + public boolean enableLocalExchangeBeforeStreamingAgg = false; + @VariableMgr.VarAttr(name = ENABLE_DISTINCT_STREAMING_AGG_FORCE_PASSTHROUGH, fuzzy = true) public boolean enableDistinctStreamingAggForcePassthrough = true; @@ -3698,6 +3703,7 @@ public void initFuzzyModeVariables() { this.disableStreamPreaggregations = random.nextBoolean(); this.enableStreamingAggHashJoinForcePassthrough = random.nextBoolean(); this.enableLocalExchangeBeforeAgg = random.nextBoolean(); + this.enableLocalExchangeBeforeStreamingAgg = random.nextBoolean(); this.enableDistinctStreamingAggForcePassthrough = random.nextBoolean(); this.enableBroadcastJoinForcePassthrough = random.nextBoolean(); this.enableShareHashTableForBroadcastJoin = random.nextBoolean(); @@ -5506,6 +5512,7 @@ public TQueryOptions toThrift() { tResult.setEnableDistinctStreamingAggregation(enableDistinctStreamingAggregation); tResult.setEnableStreamingAggHashJoinForcePassthrough(enableStreamingAggHashJoinForcePassthrough); tResult.setEnableLocalExchangeBeforeAgg(enableLocalExchangeBeforeAgg); + tResult.setEnableLocalExchangeBeforeStreamingAgg(enableLocalExchangeBeforeStreamingAgg); tResult.setEnableDistinctStreamingAggForcePassthrough(enableDistinctStreamingAggForcePassthrough); tResult.setEnableBroadcastJoinForcePassthrough(enableBroadcastJoinForcePassthrough); tResult.setPartitionTopnMaxPartitions(partitionTopNMaxPartitions); diff --git a/gensrc/thrift/PaloInternalService.thrift b/gensrc/thrift/PaloInternalService.thrift index 6add308255d921..05deef4efa5cb8 100644 --- a/gensrc/thrift/PaloInternalService.thrift +++ b/gensrc/thrift/PaloInternalService.thrift @@ -500,6 +500,7 @@ struct TQueryOptions { 224: optional bool enable_expr_zonemap_filter = true 225: optional i64 runtime_filter_tree_publish_max_send_bytes = 268435456 + 226: optional bool enable_local_exchange_before_streaming_agg = false // 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.