diff --git a/ppl-spark-integration/src/main/antlr4/OpenSearchPPLParser.g4 b/ppl-spark-integration/src/main/antlr4/OpenSearchPPLParser.g4 index 4b4e64c1a..f6cd0d4ee 100644 --- a/ppl-spark-integration/src/main/antlr4/OpenSearchPPLParser.g4 +++ b/ppl-spark-integration/src/main/antlr4/OpenSearchPPLParser.g4 @@ -27,8 +27,6 @@ queryStatement // commands pplCommands : searchCommand - | describeCommand - | showDataSourcesCommand ; commands @@ -37,18 +35,8 @@ commands | fieldsCommand | renameCommand | statsCommand - | dedupCommand | sortCommand - | evalCommand | headCommand - | topCommand - | rareCommand - | grokCommand - | parseCommand - | patternsCommand - | kmeansCommand - | adCommand - | mlCommand ; searchCommand @@ -190,8 +178,6 @@ mlArg fromClause : SOURCE EQUAL tableSourceClause | INDEX EQUAL tableSourceClause - | SOURCE EQUAL tableFunction - | INDEX EQUAL tableFunction ; tableSourceClause @@ -248,10 +234,6 @@ statsFunctionName | SUM | MIN | MAX - | VAR_SAMP - | VAR_POP - | STDDEV_SAMP - | STDDEV_POP ; takeAggFunction @@ -281,24 +263,17 @@ logicalExpression comparisonExpression : left = valueExpression comparisonOperator right = valueExpression # compareExpr - | valueExpression IN valueList # inExpr ; valueExpression : left = valueExpression binaryOperator = (STAR | DIVIDE | MODULE) right = valueExpression # binaryArithmetic | left = valueExpression binaryOperator = (PLUS | MINUS) right = valueExpression # binaryArithmetic | primaryExpression # valueExpressionDefault - | positionFunction # positionFunctionCall - | extractFunction # extractFunctionCall - | getFormatFunction # getFormatFunctionCall - | timestampFunction # timestampFunctionCall | LT_PRTHS valueExpression RT_PRTHS # parentheticValueExpr ; primaryExpression - : evalFunctionCall - | dataTypeFunctionCall - | fieldExpression + : fieldExpression | literalValue ; @@ -700,8 +675,7 @@ multiFieldRelevanceFunctionName // literals and values literalValue - : intervalLiteral - | stringLiteral + : stringLiteral | integerLiteral | decimalLiteral | booleanLiteral diff --git a/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/parser/AstBuilder.java b/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/parser/AstBuilder.java index a810ea180..ce9eea769 100644 --- a/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/parser/AstBuilder.java +++ b/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/parser/AstBuilder.java @@ -287,11 +287,7 @@ public UnresolvedPlan visitTopCommand(OpenSearchPPLParser.TopCommandContext ctx) /** From clause. */ @Override public UnresolvedPlan visitFromClause(OpenSearchPPLParser.FromClauseContext ctx) { - if (ctx.tableFunction() != null) { - return visitTableFunction(ctx.tableFunction()); - } else { - return visitTableSourceClause(ctx.tableSourceClause()); - } + return visitTableSourceClause(ctx.tableSourceClause()); } @Override diff --git a/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java b/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java index 3344cd7c2..8cfbc15d5 100644 --- a/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java +++ b/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java @@ -243,55 +243,6 @@ public UnresolvedExpression visitPositionFunction( Arrays.asList(visitFunctionArg(ctx.functionArg(0)), visitFunctionArg(ctx.functionArg(1)))); } - @Override - public UnresolvedExpression visitExtractFunctionCall( - OpenSearchPPLParser.ExtractFunctionCallContext ctx) { - return new Function( - ctx.extractFunction().EXTRACT().toString(), getExtractFunctionArguments(ctx)); - } - - private List getExtractFunctionArguments( - OpenSearchPPLParser.ExtractFunctionCallContext ctx) { - List args = - Arrays.asList( - new Literal(ctx.extractFunction().datetimePart().getText(), DataType.STRING), - visitFunctionArg(ctx.extractFunction().functionArg())); - return args; - } - - @Override - public UnresolvedExpression visitGetFormatFunctionCall( - OpenSearchPPLParser.GetFormatFunctionCallContext ctx) { - return new Function( - ctx.getFormatFunction().GET_FORMAT().toString(), getFormatFunctionArguments(ctx)); - } - - private List getFormatFunctionArguments( - OpenSearchPPLParser.GetFormatFunctionCallContext ctx) { - List args = - Arrays.asList( - new Literal(ctx.getFormatFunction().getFormatType().getText(), DataType.STRING), - visitFunctionArg(ctx.getFormatFunction().functionArg())); - return args; - } - - @Override - public UnresolvedExpression visitTimestampFunctionCall( - OpenSearchPPLParser.TimestampFunctionCallContext ctx) { - return new Function( - ctx.timestampFunction().timestampFunctionName().getText(), timestampFunctionArguments(ctx)); - } - - private List timestampFunctionArguments( - OpenSearchPPLParser.TimestampFunctionCallContext ctx) { - List args = - Arrays.asList( - new Literal(ctx.timestampFunction().simpleDateTimePart().getText(), DataType.STRING), - visitFunctionArg(ctx.timestampFunction().firstArg), - visitFunctionArg(ctx.timestampFunction().secondArg)); - return args; - } - /** * Literal and value. */