Skip to content

Commit

Permalink
Remove unimplemented syntax (#439)
Browse files Browse the repository at this point in the history
* Remove unimplemented syntax

Signed-off-by: Tomoyuki Morita <[email protected]>

* Fix keywordsCanBeId and statsFunctionName

Signed-off-by: Tomoyuki Morita <[email protected]>

* Remove describe and show datasources

Signed-off-by: Tomoyuki Morita <[email protected]>

* Fix indent

Signed-off-by: Tomoyuki Morita <[email protected]>

---------

Signed-off-by: Tomoyuki Morita <[email protected]>
(cherry picked from commit 3e964be)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Jul 29, 2024
1 parent 84dcceb commit 86a9caf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 82 deletions.
30 changes: 2 additions & 28 deletions ppl-spark-integration/src/main/antlr4/OpenSearchPPLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ queryStatement
// commands
pplCommands
: searchCommand
| describeCommand
| showDataSourcesCommand
;

commands
Expand All @@ -37,18 +35,8 @@ commands
| fieldsCommand
| renameCommand
| statsCommand
| dedupCommand
| sortCommand
| evalCommand
| headCommand
| topCommand
| rareCommand
| grokCommand
| parseCommand
| patternsCommand
| kmeansCommand
| adCommand
| mlCommand
;

searchCommand
Expand Down Expand Up @@ -190,8 +178,6 @@ mlArg
fromClause
: SOURCE EQUAL tableSourceClause
| INDEX EQUAL tableSourceClause
| SOURCE EQUAL tableFunction
| INDEX EQUAL tableFunction
;

tableSourceClause
Expand Down Expand Up @@ -248,10 +234,6 @@ statsFunctionName
| SUM
| MIN
| MAX
| VAR_SAMP
| VAR_POP
| STDDEV_SAMP
| STDDEV_POP
;

takeAggFunction
Expand Down Expand Up @@ -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
;

Expand Down Expand Up @@ -700,8 +675,7 @@ multiFieldRelevanceFunctionName

// literals and values
literalValue
: intervalLiteral
| stringLiteral
: stringLiteral
| integerLiteral
| decimalLiteral
| booleanLiteral
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<UnresolvedExpression> getExtractFunctionArguments(
OpenSearchPPLParser.ExtractFunctionCallContext ctx) {
List<UnresolvedExpression> 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<UnresolvedExpression> getFormatFunctionArguments(
OpenSearchPPLParser.GetFormatFunctionCallContext ctx) {
List<UnresolvedExpression> 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<UnresolvedExpression> timestampFunctionArguments(
OpenSearchPPLParser.TimestampFunctionCallContext ctx) {
List<UnresolvedExpression> args =
Arrays.asList(
new Literal(ctx.timestampFunction().simpleDateTimePart().getText(), DataType.STRING),
visitFunctionArg(ctx.timestampFunction().firstArg),
visitFunctionArg(ctx.timestampFunction().secondArg));
return args;
}

/**
* Literal and value.
*/
Expand Down

0 comments on commit 86a9caf

Please sign in to comment.