Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: allow LEFT and RIGHT as function names #32066

Merged
merged 2 commits into from
Jul 16, 2018
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
7 changes: 6 additions & 1 deletion x-pack/plugin/sql/src/main/antlr/SqlBase.g4
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,12 @@ functionExpression
;

functionTemplate
: identifier '(' (setQuantifier? expression (',' expression)*)? ')'
: functionName '(' (setQuantifier? expression (',' expression)*)? ')'
;
functionName
: LEFT
| RIGHT
| identifier
;

constant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@ public Function visitExtractExpression(ExtractExpressionContext ctx) {
@Override
public Function visitFunctionExpression(FunctionExpressionContext ctx) {
FunctionTemplateContext template = ctx.functionTemplate();

String name = visitIdentifier(template.identifier());
String name = template.functionName().getText();
boolean isDistinct = template.setQuantifier() != null && template.setQuantifier().DISTINCT() != null;
UnresolvedFunction.ResolutionType resolutionType =
isDistinct ? UnresolvedFunction.ResolutionType.DISTINCT : UnresolvedFunction.ResolutionType.STANDARD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,18 @@ class SqlBaseBaseListener implements SqlBaseListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFunctionTemplate(SqlBaseParser.FunctionTemplateContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFunctionName(SqlBaseParser.FunctionNameContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFunctionName(SqlBaseParser.FunctionNameContext ctx) { }
/**
* {@inheritDoc}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,13 @@ class SqlBaseBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SqlBa
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFunctionTemplate(SqlBaseParser.FunctionTemplateContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFunctionName(SqlBaseParser.FunctionNameContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,16 @@ interface SqlBaseListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitFunctionTemplate(SqlBaseParser.FunctionTemplateContext ctx);
/**
* Enter a parse tree produced by {@link SqlBaseParser#functionName}.
* @param ctx the parse tree
*/
void enterFunctionName(SqlBaseParser.FunctionNameContext ctx);
/**
* Exit a parse tree produced by {@link SqlBaseParser#functionName}.
* @param ctx the parse tree
*/
void exitFunctionName(SqlBaseParser.FunctionNameContext ctx);
/**
* Enter a parse tree produced by the {@code nullLiteral}
* labeled alternative in {@link SqlBaseParser#constant}.
Expand Down
Loading