You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/04/13 03:11:06 UTC
[doris] branch master updated: [bugfix](topn) fix topn runtime predicate crash in short circuit evaluate for types like string decimal (#18409)
This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 726402b53b [bugfix](topn) fix topn runtime predicate crash in short circuit evaluate for types like string decimal (#18409)
726402b53b is described below
commit 726402b53b9939644a5f385ef00c36af5cd673a9
Author: Kang <kx...@gmail.com>
AuthorDate: Thu Apr 13 11:10:59 2023 +0800
[bugfix](topn) fix topn runtime predicate crash in short circuit evaluate for types like string decimal (#18409)
---
be/src/olap/accept_null_predicate.h | 41 +++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/be/src/olap/accept_null_predicate.h b/be/src/olap/accept_null_predicate.h
index 7242aee24e..d07e1a1031 100644
--- a/be/src/olap/accept_null_predicate.h
+++ b/be/src/olap/accept_null_predicate.h
@@ -52,8 +52,45 @@ public:
uint16_t evaluate(const vectorized::IColumn& column, uint16_t* sel,
uint16_t size) const override {
- LOG(FATAL) << "evaluate without flags not supported";
- // return _nested->evaluate(column, sel, size);
+ if (column.has_null()) {
+ // create selected_flags
+ uint16_t max_idx = *std::max_element(sel, sel + size);
+ auto selected_flags_ptr = std::make_unique<bool[]>(max_idx + 1);
+ auto selected_flags = selected_flags_ptr.get();
+ // init to 0 / false
+ memset(selected_flags, 0, (max_idx + 1) * sizeof(bool));
+ for (uint16_t i = 0; i < size; ++i) {
+ uint16_t row_idx = sel[i];
+ if (column.is_null_at(row_idx)) {
+ // set selected flag true for NULL value
+ selected_flags[row_idx] = true;
+ }
+ }
+
+ // call nested predicate evaluate
+ uint16_t new_size = _nested->evaluate(column, sel, size);
+
+ // process NULL values
+ if (new_size < size) {
+ // add rows selected by _nested->evaluate
+ for (uint16_t i = 0; i < new_size; ++i) {
+ uint16_t row_idx = sel[i];
+ selected_flags[row_idx] = true;
+ }
+
+ // recaculate new_size and sel array
+ new_size = 0;
+ for (uint16_t row_idx = 0; row_idx < max_idx + 1; ++row_idx) {
+ if (selected_flags[row_idx]) {
+ sel[new_size++] = row_idx;
+ }
+ }
+ }
+
+ return new_size;
+ } else {
+ return _nested->evaluate(column, sel, size);
+ }
}
void evaluate_and(const vectorized::IColumn& column, const uint16_t* sel, uint16_t size,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org