Skip to content

Commit

Permalink
Fix the result mismatch for right expression (oap-project#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
JkSelf authored and zhejiangxiaomai committed Mar 27, 2023
1 parent a490c77 commit 8b6ba5a
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 @@ -349,6 +349,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 8b6ba5a

Please sign in to comment.