Skip to content

Commit 6055c7e

Browse files
Fix ASCII function and groom UT for text functions. (#301) (#1895)
* Fix `ASCII` function and groom UT for text functions. * Code cleanup. --------- Signed-off-by: Yury-Fridlyand <[email protected]>
1 parent 2201509 commit 6055c7e

File tree

2 files changed

+95
-212
lines changed

2 files changed

+95
-212
lines changed

core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ private static ExprValue exprLeft(ExprValue expr, ExprValue length) {
416416
}
417417

418418
private static ExprValue exprAscii(ExprValue expr) {
419-
return new ExprIntegerValue((int) expr.stringValue().charAt(0));
419+
return new ExprIntegerValue(
420+
expr.stringValue().length() == 0 ? 0 : (int) expr.stringValue().charAt(0));
420421
}
421422

422423
private static ExprValue exprLocate(ExprValue subStr, ExprValue str) {

0 commit comments

Comments
 (0)