This is an automated email from the ASF dual-hosted git repository.
BiteTheDDDDt 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 87023f54a80 [fix](be) Stabilize conjunct cost ordering (#64637)
87023f54a80 is described below
commit 87023f54a80f509e95f4824184a5a94f088eddf1
Author: Pxl <[email protected]>
AuthorDate: Sun Jun 21 18:53:36 2026 +0800
[fix](be) Stabilize conjunct cost ordering (#64637)
Problem Summary: When `enable_adjust_conjunct_order_by_cost` is enabled,
conjuncts are sorted by `execute_cost` with `std::ranges::sort`.
Equal-cost conjuncts may have their original relative order changed,
which can introduce unnecessary evaluation-order side effects. This
patch switches the cost ordering paths to `std::ranges::stable_sort` so
lower-cost conjuncts are still prioritized while equal-cost conjuncts
keep their original order.
---
be/src/exec/operator/operator.cpp | 4 +++-
be/src/exec/operator/scan_operator.cpp | 3 ++-
be/src/format/parquet/vparquet_group_reader.cpp | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/be/src/exec/operator/operator.cpp
b/be/src/exec/operator/operator.cpp
index 60f199b2b49..c45e712ab5d 100644
--- a/be/src/exec/operator/operator.cpp
+++ b/be/src/exec/operator/operator.cpp
@@ -17,6 +17,8 @@
#include "exec/operator/operator.h"
+#include <algorithm>
+
#include "common/status.h"
#include "exec/common/util.hpp"
#include "exec/exchange/local_exchange_sink_operator.h"
@@ -245,7 +247,7 @@ Status OperatorXBase::prepare(RuntimeState* state) {
RETURN_IF_ERROR(conjunct->prepare(state, intermediate_row_desc()));
}
if (state->enable_adjust_conjunct_order_by_cost()) {
- std::ranges::sort(_conjuncts, [](const auto& a, const auto& b) {
+ std::ranges::stable_sort(_conjuncts, [](const auto& a, const auto& b) {
return a->execute_cost() < b->execute_cost();
});
};
diff --git a/be/src/exec/operator/scan_operator.cpp
b/be/src/exec/operator/scan_operator.cpp
index f661244d39a..a9e92d08e08 100644
--- a/be/src/exec/operator/scan_operator.cpp
+++ b/be/src/exec/operator/scan_operator.cpp
@@ -21,6 +21,7 @@
#include <gen_cpp/Exprs_types.h>
#include <gen_cpp/Metrics_types.h>
+#include <algorithm>
#include <cstdint>
#include <memory>
@@ -78,7 +79,7 @@ Status
ScanLocalStateBase::update_late_arrival_runtime_filter(RuntimeState* stat
RETURN_IF_ERROR(_helper.try_append_late_arrival_runtime_filter(state,
_parent->row_descriptor(),
arrived_rf_num, _conjuncts));
if (state->enable_adjust_conjunct_order_by_cost()) {
- std::ranges::sort(_conjuncts, [](const auto& a, const auto& b) {
+ std::ranges::stable_sort(_conjuncts, [](const auto& a, const auto& b) {
return a->execute_cost() < b->execute_cost();
});
};
diff --git a/be/src/format/parquet/vparquet_group_reader.cpp
b/be/src/format/parquet/vparquet_group_reader.cpp
index ff1965c043c..63175c9de5c 100644
--- a/be/src/format/parquet/vparquet_group_reader.cpp
+++ b/be/src/format/parquet/vparquet_group_reader.cpp
@@ -208,7 +208,7 @@ Status RowGroupReader::init(
}
// _state is nullptr in some ut.
if (_state && _state->enable_adjust_conjunct_order_by_cost()) {
- std::ranges::sort(_filter_conjuncts, [](const auto& a, const auto& b) {
+ std::ranges::stable_sort(_filter_conjuncts, [](const auto& a, const
auto& b) {
return a->execute_cost() < b->execute_cost();
});
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]