Skip to content

Commit cb217f7

Browse files
LiBinfengYour Name
authored andcommitted
[fix](Nereids) fix split part with delim not exist in source string (#48895)
### What problem does this PR solve? Related PR: #40441 Problem Summary: if source string do not contains delim, split_part should return NULL
1 parent 5124dc8 commit cb217f7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/StringArithmetic.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,9 @@ public static Expression splitPart(StringLikeLiteral first, StringLikeLiteral ch
699699
return new NullLiteral(first.getDataType());
700700
}
701701
}
702+
if (!first.getValue().contains(chr.getValue())) {
703+
return new NullLiteral(first.getDataType());
704+
}
702705
String separator = chr.getValue();
703706
String[] parts;
704707
if (number.getValue() < 0) {

regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_string_arithmatic.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,9 @@ suite("fold_constant_string_arithmatic") {
592592
testFoldConst("SELECT split_part('a..b\$\$c||d((e))f[[g{{h^^i??j**k++l\\\\m','**', 2)")
593593
testFoldConst("SELECT split_part('a..b\$\$c||d((e))f[[g{{h^^i??j**k++l\\\\m','++', 2)")
594594
testFoldConst("SELECT split_part('a..b\$\$c||d((e))f[[g{{h^^i??j**k++l\\\\m','\\\\', 2)")
595+
testFoldConst("select split_part('abc', ':', -1)")
596+
testFoldConst("select split_part('abc', ':', 0)")
597+
testFoldConst("select split_part('abc', ':', 1)")
595598

596599
// starts_with
597600
testFoldConst("select starts_with('hello world','hello')")

0 commit comments

Comments
 (0)