From f1760f9e5e5392285a2ee76a5148942a39aeb54e Mon Sep 17 00:00:00 2001 From: Lantao Jin Date: Mon, 17 Jun 2024 15:34:46 +0800 Subject: [PATCH] Boolean function in PPL should be case insensitive Signed-off-by: Lantao Jin --- .../org/opensearch/sql/ppl/parser/AstExpressionBuilder.java | 2 +- .../opensearch/sql/ppl/parser/AstExpressionBuilderTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java b/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java index 47db10c99b..f36765d3d7 100644 --- a/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java +++ b/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java @@ -187,7 +187,7 @@ public UnresolvedExpression visitTakeAggFunctionCall( /** Eval function. */ @Override public UnresolvedExpression visitBooleanFunctionCall(BooleanFunctionCallContext ctx) { - final String functionName = ctx.conditionFunctionBase().getText(); + final String functionName = ctx.conditionFunctionBase().getText().toLowerCase(); return buildFunction( FUNCTION_NAME_MAPPING.getOrDefault(functionName, functionName), ctx.functionArgs().functionArg()); diff --git a/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstExpressionBuilderTest.java b/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstExpressionBuilderTest.java index 7bcb87d193..de230a1fee 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstExpressionBuilderTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstExpressionBuilderTest.java @@ -107,12 +107,15 @@ public void testLogicalLikeExpr() { @Test public void testBooleanIsNullFunction() { assertEqual("source=t isnull(a)", filter(relation("t"), function("is null", field("a")))); + assertEqual("source=t ISNULL(a)", filter(relation("t"), function("is null", field("a")))); } @Test public void testBooleanIsNotNullFunction() { assertEqual( "source=t isnotnull(a)", filter(relation("t"), function("is not null", field("a")))); + assertEqual( + "source=t ISNOTNULL(a)", filter(relation("t"), function("is not null", field("a")))); } /** Todo. search operator should not include functionCall, need to change antlr. */