Skip to content

Commit

Permalink
Fix the result mismatch for right expression (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
JkSelf authored and zhejiangxiaomai committed Feb 22, 2023
1 parent 91ddb55 commit 7c73eb5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions velox/functions/prestosql/StringFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ struct SubstrFunction {
if (start < 0) {
start = numCharacters + start + 1;
}

// Following vanilla spark semantics. When the start is 0 after adjusing start,
// Keep the origin input.
if (start <= 0) {
start = 1;
length = numCharacters;
}

// Following Presto semantics
if (start <= 0 || start > numCharacters || length <= 0) {
Expand Down

0 comments on commit 7c73eb5

Please sign in to comment.