This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new cd5eec5c98b branch-4.0: [fix](substring) Fix `substring_index` #60346
(#60373)
cd5eec5c98b is described below
commit cd5eec5c98b1137122707ce74bd7215a7d6553af
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Jan 30 09:19:03 2026 +0800
branch-4.0: [fix](substring) Fix `substring_index` #60346 (#60373)
Cherry-picked from #60346
Co-authored-by: Gabriel <[email protected]>
---
be/src/vec/functions/function_string.h | 2 +-
.../data/function_p0/test_substring_index.out | 4 ++++
.../suites/function_p0/test_substring_index.groovy | 22 ++++++++++++++++++++++
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/be/src/vec/functions/function_string.h
b/be/src/vec/functions/function_string.h
index fd020e13a4e..2cce9b2f4af 100644
--- a/be/src/vec/functions/function_string.h
+++ b/be/src/vec/functions/function_string.h
@@ -1897,7 +1897,7 @@ public:
}
for (size_t i = 0; i < input_rows_count; ++i) {
- auto str = str_col->get_data_at(i);
+ auto str = str_col->get_data_at(content_const ? 0 : i);
auto delimiter = delimiter_col->get_data_at(delimiter_const ? 0 :
i);
int32_t delimiter_size = delimiter.size;
diff --git a/regression-test/data/function_p0/test_substring_index.out
b/regression-test/data/function_p0/test_substring_index.out
index 480f2c2b482..aabc01e39c4 100644
--- a/regression-test/data/function_p0/test_substring_index.out
+++ b/regression-test/data/function_p0/test_substring_index.out
@@ -46,3 +46,7 @@
-- !sql --
test|test test|test
+-- !sql --
+
+
+
diff --git a/regression-test/suites/function_p0/test_substring_index.groovy
b/regression-test/suites/function_p0/test_substring_index.groovy
index 47df1208a00..cd094c396af 100644
--- a/regression-test/suites/function_p0/test_substring_index.groovy
+++ b/regression-test/suites/function_p0/test_substring_index.groovy
@@ -134,4 +134,26 @@ suite("test_substring_index") {
"""
sql "DROP TABLE IF EXISTS test_substring_index"
+
+ sql "DROP TABLE IF EXISTS test_substring_index2"
+ sql """
+ CREATE TABLE test_substring_index2 (
+ id INT,
+ str VARCHAR(100),
+ delimiter VARCHAR(10)
+ ) ENGINE=OLAP
+ DUPLICATE KEY(id)
+ DISTRIBUTED BY HASH(id) BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1"
+ )
+ """
+
+ sql """
+ INSERT INTO test_substring_index2 VALUES
+ (1, NULL, NULL),
+ (2, NULL, NULL)
+ """
+ qt_sql """ SELECT SUBSTRING_INDEX(IFNULL(a.str, ''), ',', a.id) from
test_substring_index2 a """
+ sql "DROP TABLE IF EXISTS test_substring_index2"
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]