[fix](nereids)modify split_part function to fold to null literal with correct data type (#42100)

pick from master https://github.com/apache/doris/pull/41109

## Proposed changes

Issue Number: close #xxx

<!--Describe your changes.-->
This commit is contained in:
starocean999
2024-10-18 22:15:57 +08:00
committed by GitHub
parent c412de8db8
commit 4edfbb5c76
2 changed files with 6 additions and 1 deletions

View File

@ -619,7 +619,7 @@ public class StringArithmetic {
return castStringLikeLiteral(first, "");
}
}
return new NullLiteral();
return new NullLiteral(first.getDataType());
} else if (number.getValue() < 0) {
StringBuilder result = new StringBuilder(parts[Math.abs(number.getValue()) - 1]);
return castStringLikeLiteral(first, result.reverse().toString());

View File

@ -30,4 +30,9 @@ suite("test_split_part") {
}
qt_1 "select split_part(k8, '1', 1), k8, split_part(concat(k8, '12'), '1', 1) from nereids_test_query_db.test order by k8 limit 2;"
explain {
sql("""verbose select split_part(replace_empty('we', "", "u"), ":", 5 - 5);""")
notContains "null_type"
}
}