This is an automated email from the ASF dual-hosted git repository.
panxiaolei 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 9ebe73176ab [fix](core) Fix count_true_with_notnull failing to
correctly handle Const (Nullable) cases. (#58692)
9ebe73176ab is described below
commit 9ebe73176ab580dd3914c02ad3c70b67aa68019d
Author: Mryange <[email protected]>
AuthorDate: Thu Dec 4 11:25:11 2025 +0800
[fix](core) Fix count_true_with_notnull failing to correctly handle Const
(Nullable) cases. (#58692)
https://github.com/apache/doris/issues/58125
```
F20251203 19:47:55.046221 2067836 status.h:467] Bad cast from
type:doris::vectorized::ColumnConst* to
doris::vectorized::ColumnVector<(doris::PrimitiveType)2> const*
*** Check failure stack trace: ***
@ 0x55d7d5bc798f google::LogMessage::SendToLog()
@ 0x55d7d5bbdfa0 google::LogMessage::Flush()
@ 0x55d7d5bc1699 google::LogMessageFatal::~LogMessageFatal()
@ 0x55d7a87a211b doris::Status::FatalError<>()
@ 0x55d7c8732ed6
_ZZ11assert_castIPKN5doris10vectorized12ColumnVectorILNS0_13PrimitiveTypeE2EEEL18TypeCheckOnRelease1EPKNS1_7IColumnEET_OT1_ENKUlOSB_E_clISA_EES6_SE_
@ 0x55d7c87322e4 assert_cast<>()
@ 0x55d7c96b4334
doris::vectorized::VConditionExpr::count_true_with_notnull()
@ 0x55d7c96c2edb
doris::vectorized::VectorizedIfExpr::execute_column()
@ 0x55d7b02f867d doris::vectorized::VExpr::execute()
@ 0x55d7c94e1a4b doris::vectorized::VExpr::get_const_col()
@ 0x55d7c94e0cfe doris::vectorized::VExpr::open()
@ 0x55d7c96b246e doris::vectorized::VConditionExpr::open()
@ 0x55d7c9881761 doris::vectorized::VExprContext::open()
@ 0x55d7c94eaeac doris::vectorized::VExpr::open()
```
---
be/src/vec/exprs/vcondition_expr.cpp | 7 +++++-
.../conditional_functions/test_if.out | 19 ++++++++++++++
.../conditional_functions/test_if.groovy | 29 ++++++++++++++++++++++
3 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/be/src/vec/exprs/vcondition_expr.cpp
b/be/src/vec/exprs/vcondition_expr.cpp
index 5104f766814..630c968b8e0 100644
--- a/be/src/vec/exprs/vcondition_expr.cpp
+++ b/be/src/vec/exprs/vcondition_expr.cpp
@@ -22,6 +22,7 @@
#include "udf/udf.h"
#include "util/simd/bits.h"
#include "vec/columns/column.h"
+#include "vec/columns/column_const.h"
namespace doris::vectorized {
@@ -62,7 +63,11 @@ size_t VConditionExpr::count_true_with_notnull(const
ColumnPtr& col) {
return 0;
}
- if (const auto* const_col =
check_and_get_column_const<ColumnUInt8>(col.get())) {
+ if (const auto* const_col = check_and_get_column<ColumnConst>(col.get())) {
+ // if is null , get_bool will return false
+ // bool get_bool(size_t n) const override {
+ // return is_null_at(n) ? false : _nested_column->get_bool(n);
+ // }
bool is_true = const_col->get_bool(0);
return is_true ? col->size() : 0;
}
diff --git
a/regression-test/data/nereids_p0/sql_functions/conditional_functions/test_if.out
b/regression-test/data/nereids_p0/sql_functions/conditional_functions/test_if.out
new file mode 100644
index 00000000000..f2a46f6fc8c
--- /dev/null
+++
b/regression-test/data/nereids_p0/sql_functions/conditional_functions/test_if.out
@@ -0,0 +1,19 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql --
+NOT_EXISTS
+
+-- !sql --
+EXISTS
+
+-- !sql --
+NOT_EXISTS
+
+-- !sql --
+0
+
+-- !sql --
+EXISTS
+
+-- !sql --
+0
+
diff --git
a/regression-test/suites/nereids_p0/sql_functions/conditional_functions/test_if.groovy
b/regression-test/suites/nereids_p0/sql_functions/conditional_functions/test_if.groovy
index 81cb109f64b..da11db6147a 100644
---
a/regression-test/suites/nereids_p0/sql_functions/conditional_functions/test_if.groovy
+++
b/regression-test/suites/nereids_p0/sql_functions/conditional_functions/test_if.groovy
@@ -19,4 +19,33 @@ suite("test_if") {
sql "SET enable_nereids_planner=true"
sql "SET enable_fallback_to_original_planner=false"
sql "select if(id=1,count,hll_empty()) from (select 1 as id, hll_hash(1)
as count) t"
+
+
+ sql "set debug_skip_fold_constant = true"
+
+ qt_sql """
+ select if(jsonb_exists_path(CAST('{"a":1}' AS json), '\$.b'), 'EXISTS',
'NOT_EXISTS')
+"""
+
+ qt_sql """
+select if(jsonb_exists_path(CAST(' {"a":1}' AS json), '\$.b'), 'NOT_EXISTS',
'EXISTS');
+"""
+
+ qt_sql """
+select if('EXISTS', jsonb_exists_path(CAST(' {"a":1}' AS json), '\$.b'),
'NOT_EXISTS');
+"""
+
+ qt_sql """
+select if('EXISTS', 'NOT_EXISTS', jsonb_exists_path(CAST(' {"a":1}' AS json),
'\$.b'));
+"""
+
+ qt_sql """
+select if('NOT_EXISTS', jsonb_exists_path(CAST(' {"a":1}' AS json), '\$.b'),
'EXISTS');
+"""
+
+ qt_sql """
+select if('NOT_EXISTS', 'EXISTS', jsonb_exists_path(CAST(' {"a":1}' AS json),
'\$.b'));
+"""
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]