Skip to content

Commit

Permalink
Remove unimplemented syntax
Browse files Browse the repository at this point in the history
Signed-off-by: Tomoyuki Morita <moritato@amazon.com>
  • Loading branch information
ykmr1224 committed Jul 23, 2024
1 parent 26759b9 commit 3b4a57e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 81 deletions.
29 changes: 2 additions & 27 deletions ppl-spark-integration/src/main/antlr4/OpenSearchPPLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,8 @@ commands
| fieldsCommand
| renameCommand
| statsCommand
| dedupCommand
| sortCommand
| evalCommand
| headCommand
| topCommand
| rareCommand
| grokCommand
| parseCommand
| patternsCommand
| kmeansCommand
| adCommand
| mlCommand
;

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

tableSourceClause
Expand Down Expand Up @@ -281,24 +269,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 +681,7 @@ multiFieldRelevanceFunctionName

// literals and values
literalValue
: intervalLiteral
| stringLiteral
: stringLiteral
| integerLiteral
| decimalLiteral
| booleanLiteral
Expand Down Expand Up @@ -830,13 +810,8 @@ keywordsCanBeId
: D // OD SQL and ODBC special
| timespanUnit
| SPAN
| evalFunctionName
| relevanceArgName
| intervalUnit
| dateTimeFunctionName
| textFunctionName
| mathematicalFunctionName
| positionFunctionName
// commands
| SEARCH
| DESCRIBE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,11 @@ 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());
}
// if (ctx.tableFunction() != null) {
// return visitTableFunction(ctx.tableFunction());
// } else {
return visitTableSourceClause(ctx.tableSourceClause());
// }
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,55 +244,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 3b4a57e

Please sign in to comment.