Skip to content

Commit

Permalink
Fix ASCII function and groom UT for text functions.
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Jul 20, 2023
1 parent f4883c9 commit 994fb37
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import lombok.experimental.UtilityClass;
import org.apache.commons.lang3.tuple.Pair;
import org.opensearch.sql.data.model.ExprIntegerValue;
import org.opensearch.sql.data.model.ExprNullValue;
import org.opensearch.sql.data.model.ExprStringValue;
import org.opensearch.sql.data.model.ExprValue;
import org.opensearch.sql.data.model.ExprValueUtils;
Expand Down Expand Up @@ -359,7 +360,8 @@ private static ExprValue exprLeft(ExprValue expr, ExprValue length) {
}

private static ExprValue exprAscii(ExprValue expr) {
return new ExprIntegerValue((int) expr.stringValue().charAt(0));
return new ExprIntegerValue(expr.stringValue().length() == 0 ? 0
: (int) expr.stringValue().charAt(0));
}

private static ExprValue exprLocate(ExprValue subStr, ExprValue str) {
Expand Down
Loading

0 comments on commit 994fb37

Please sign in to comment.