Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ public void testIfWithLike() throws IOException {
actual, rows(0.0, "John"), rows(0.0, "Jane"), rows(0.0, "Jake"), rows(1.0, "Hello"));
}

@Test
public void testIfWithEquals() throws IOException {
JSONObject actual =
executeQuery(
String.format(
"source=%s | eval jake = if(name='Jake', 1, 0) | fields name, jake",
TEST_INDEX_STATE_COUNTRY));

verifySchema(actual, schema("name", "string"), schema("jake", "int"));

verifyDataRows(actual, rows("Jake", 1), rows("Hello", 0), rows("John", 0), rows("Jane", 0));
}

@Test
public void testIsPresent() throws IOException {
JSONObject actual =
Expand Down
11 changes: 9 additions & 2 deletions ppl/src/main/antlr/OpenSearchPPLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ tableSource
;

tableFunction
: qualifiedName LT_PRTHS functionArgs RT_PRTHS
: qualifiedName LT_PRTHS namedFunctionArgs RT_PRTHS
;

// fields
Expand Down Expand Up @@ -597,10 +597,17 @@ functionArgs
: (functionArg (COMMA functionArg)*)?
;

namedFunctionArgs
: (namedFunctionArg (COMMA namedFunctionArg)*)?
;

functionArg
: (ident EQUAL)? functionArgExpression
: functionArgExpression
;

namedFunctionArg
: (ident EQUAL)? functionArgExpression
;

functionArgExpression
: lambda
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ public UnresolvedPlan visitTableSourceClause(TableSourceClauseContext ctx) {
@Override
public UnresolvedPlan visitTableFunction(TableFunctionContext ctx) {
ImmutableList.Builder<UnresolvedExpression> builder = ImmutableList.builder();
ctx.functionArgs()
.functionArg()
ctx.namedFunctionArgs()
.namedFunctionArg()
.forEach(
arg -> {
String argName = (arg.ident() != null) ? arg.ident().getText() : null;
Expand Down
Loading