SQL: Fix precedence of `::` psql like CAST operator (#40665)
Previously, an expression like `10 + 2::long` would be interpreted as `CAST(10 + 2 AS LONG)` instead of `10 + CAST(2 AS LONG)`. (cherry picked from commit e34cc2f38b1477e78788ee377938f42cc47187c7)
This commit is contained in:
parent
31776a4b15
commit
862fe612e0
|
@ -210,11 +210,11 @@ valueExpression
|
||||||
| left=valueExpression operator=(ASTERISK | SLASH | PERCENT) right=valueExpression #arithmeticBinary
|
| left=valueExpression operator=(ASTERISK | SLASH | PERCENT) right=valueExpression #arithmeticBinary
|
||||||
| left=valueExpression operator=(PLUS | MINUS) right=valueExpression #arithmeticBinary
|
| left=valueExpression operator=(PLUS | MINUS) right=valueExpression #arithmeticBinary
|
||||||
| left=valueExpression comparisonOperator right=valueExpression #comparison
|
| left=valueExpression comparisonOperator right=valueExpression #comparison
|
||||||
| valueExpression CAST_OP dataType #castOperatorExpression
|
|
||||||
;
|
;
|
||||||
|
|
||||||
primaryExpression
|
primaryExpression
|
||||||
: castExpression #cast
|
: castExpression #cast
|
||||||
|
| primaryExpression CAST_OP dataType #castOperatorExpression
|
||||||
| extractExpression #extract
|
| extractExpression #extract
|
||||||
| builtinDateTimeFunction #currentDateTimeFunction
|
| builtinDateTimeFunction #currentDateTimeFunction
|
||||||
| constant #constantDefault
|
| constant #constantDefault
|
||||||
|
|
|
@ -416,7 +416,7 @@ abstract class ExpressionBuilder extends IdentifierBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object visitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx) {
|
public Object visitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx) {
|
||||||
return new Cast(source(ctx), expression(ctx.valueExpression()), typedParsing(ctx.dataType(), DataType.class));
|
return new Cast(source(ctx), expression(ctx.primaryExpression()), typedParsing(ctx.dataType(), DataType.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -599,18 +599,6 @@ class SqlBaseBaseListener implements SqlBaseListener {
|
||||||
* <p>The default implementation does nothing.</p>
|
* <p>The default implementation does nothing.</p>
|
||||||
*/
|
*/
|
||||||
@Override public void exitComparison(SqlBaseParser.ComparisonContext ctx) { }
|
@Override public void exitComparison(SqlBaseParser.ComparisonContext ctx) { }
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx) { }
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -635,6 +623,18 @@ class SqlBaseBaseListener implements SqlBaseListener {
|
||||||
* <p>The default implementation does nothing.</p>
|
* <p>The default implementation does nothing.</p>
|
||||||
*/
|
*/
|
||||||
@Override public void exitArithmeticUnary(SqlBaseParser.ArithmeticUnaryContext ctx) { }
|
@Override public void exitArithmeticUnary(SqlBaseParser.ArithmeticUnaryContext ctx) { }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation does nothing.</p>
|
||||||
|
*/
|
||||||
|
@Override public void enterDereference(SqlBaseParser.DereferenceContext ctx) { }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation does nothing.</p>
|
||||||
|
*/
|
||||||
|
@Override public void exitDereference(SqlBaseParser.DereferenceContext ctx) { }
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -647,30 +647,6 @@ class SqlBaseBaseListener implements SqlBaseListener {
|
||||||
* <p>The default implementation does nothing.</p>
|
* <p>The default implementation does nothing.</p>
|
||||||
*/
|
*/
|
||||||
@Override public void exitCast(SqlBaseParser.CastContext ctx) { }
|
@Override public void exitCast(SqlBaseParser.CastContext ctx) { }
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterExtract(SqlBaseParser.ExtractContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitExtract(SqlBaseParser.ExtractContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx) { }
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -683,6 +659,30 @@ class SqlBaseBaseListener implements SqlBaseListener {
|
||||||
* <p>The default implementation does nothing.</p>
|
* <p>The default implementation does nothing.</p>
|
||||||
*/
|
*/
|
||||||
@Override public void exitConstantDefault(SqlBaseParser.ConstantDefaultContext ctx) { }
|
@Override public void exitConstantDefault(SqlBaseParser.ConstantDefaultContext ctx) { }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation does nothing.</p>
|
||||||
|
*/
|
||||||
|
@Override public void enterExtract(SqlBaseParser.ExtractContext ctx) { }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation does nothing.</p>
|
||||||
|
*/
|
||||||
|
@Override public void exitExtract(SqlBaseParser.ExtractContext ctx) { }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation does nothing.</p>
|
||||||
|
*/
|
||||||
|
@Override public void enterParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx) { }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation does nothing.</p>
|
||||||
|
*/
|
||||||
|
@Override public void exitParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx) { }
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -695,6 +695,18 @@ class SqlBaseBaseListener implements SqlBaseListener {
|
||||||
* <p>The default implementation does nothing.</p>
|
* <p>The default implementation does nothing.</p>
|
||||||
*/
|
*/
|
||||||
@Override public void exitStar(SqlBaseParser.StarContext ctx) { }
|
@Override public void exitStar(SqlBaseParser.StarContext ctx) { }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation does nothing.</p>
|
||||||
|
*/
|
||||||
|
@Override public void enterCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx) { }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation does nothing.</p>
|
||||||
|
*/
|
||||||
|
@Override public void exitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx) { }
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -707,6 +719,18 @@ class SqlBaseBaseListener implements SqlBaseListener {
|
||||||
* <p>The default implementation does nothing.</p>
|
* <p>The default implementation does nothing.</p>
|
||||||
*/
|
*/
|
||||||
@Override public void exitFunction(SqlBaseParser.FunctionContext ctx) { }
|
@Override public void exitFunction(SqlBaseParser.FunctionContext ctx) { }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation does nothing.</p>
|
||||||
|
*/
|
||||||
|
@Override public void enterCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx) { }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation does nothing.</p>
|
||||||
|
*/
|
||||||
|
@Override public void exitCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx) { }
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -719,30 +743,6 @@ class SqlBaseBaseListener implements SqlBaseListener {
|
||||||
* <p>The default implementation does nothing.</p>
|
* <p>The default implementation does nothing.</p>
|
||||||
*/
|
*/
|
||||||
@Override public void exitSubqueryExpression(SqlBaseParser.SubqueryExpressionContext ctx) { }
|
@Override public void exitSubqueryExpression(SqlBaseParser.SubqueryExpressionContext ctx) { }
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterDereference(SqlBaseParser.DereferenceContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitDereference(SqlBaseParser.DereferenceContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx) { }
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
|
|
@ -354,13 +354,6 @@ class SqlBaseBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SqlBa
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
*/
|
*/
|
||||||
@Override public T visitComparison(SqlBaseParser.ComparisonContext ctx) { return visitChildren(ctx); }
|
@Override public T visitComparison(SqlBaseParser.ComparisonContext ctx) { return visitChildren(ctx); }
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation returns the result of calling
|
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
|
||||||
*/
|
|
||||||
@Override public T visitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx) { return visitChildren(ctx); }
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -375,6 +368,13 @@ class SqlBaseBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SqlBa
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
*/
|
*/
|
||||||
@Override public T visitArithmeticUnary(SqlBaseParser.ArithmeticUnaryContext ctx) { return visitChildren(ctx); }
|
@Override public T visitArithmeticUnary(SqlBaseParser.ArithmeticUnaryContext ctx) { return visitChildren(ctx); }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation returns the result of calling
|
||||||
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
|
*/
|
||||||
|
@Override public T visitDereference(SqlBaseParser.DereferenceContext ctx) { return visitChildren(ctx); }
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -382,20 +382,6 @@ class SqlBaseBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SqlBa
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
*/
|
*/
|
||||||
@Override public T visitCast(SqlBaseParser.CastContext ctx) { return visitChildren(ctx); }
|
@Override public T visitCast(SqlBaseParser.CastContext ctx) { return visitChildren(ctx); }
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation returns the result of calling
|
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
|
||||||
*/
|
|
||||||
@Override public T visitExtract(SqlBaseParser.ExtractContext ctx) { return visitChildren(ctx); }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation returns the result of calling
|
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
|
||||||
*/
|
|
||||||
@Override public T visitCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx) { return visitChildren(ctx); }
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -403,6 +389,20 @@ class SqlBaseBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SqlBa
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
*/
|
*/
|
||||||
@Override public T visitConstantDefault(SqlBaseParser.ConstantDefaultContext ctx) { return visitChildren(ctx); }
|
@Override public T visitConstantDefault(SqlBaseParser.ConstantDefaultContext ctx) { return visitChildren(ctx); }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation returns the result of calling
|
||||||
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
|
*/
|
||||||
|
@Override public T visitExtract(SqlBaseParser.ExtractContext ctx) { return visitChildren(ctx); }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation returns the result of calling
|
||||||
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
|
*/
|
||||||
|
@Override public T visitParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx) { return visitChildren(ctx); }
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -410,6 +410,13 @@ class SqlBaseBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SqlBa
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
*/
|
*/
|
||||||
@Override public T visitStar(SqlBaseParser.StarContext ctx) { return visitChildren(ctx); }
|
@Override public T visitStar(SqlBaseParser.StarContext ctx) { return visitChildren(ctx); }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation returns the result of calling
|
||||||
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
|
*/
|
||||||
|
@Override public T visitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx) { return visitChildren(ctx); }
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -417,6 +424,13 @@ class SqlBaseBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SqlBa
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
*/
|
*/
|
||||||
@Override public T visitFunction(SqlBaseParser.FunctionContext ctx) { return visitChildren(ctx); }
|
@Override public T visitFunction(SqlBaseParser.FunctionContext ctx) { return visitChildren(ctx); }
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* <p>The default implementation returns the result of calling
|
||||||
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
|
*/
|
||||||
|
@Override public T visitCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx) { return visitChildren(ctx); }
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@ -424,20 +438,6 @@ class SqlBaseBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SqlBa
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
* {@link #visitChildren} on {@code ctx}.</p>
|
||||||
*/
|
*/
|
||||||
@Override public T visitSubqueryExpression(SqlBaseParser.SubqueryExpressionContext ctx) { return visitChildren(ctx); }
|
@Override public T visitSubqueryExpression(SqlBaseParser.SubqueryExpressionContext ctx) { return visitChildren(ctx); }
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation returns the result of calling
|
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
|
||||||
*/
|
|
||||||
@Override public T visitDereference(SqlBaseParser.DereferenceContext ctx) { return visitChildren(ctx); }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation returns the result of calling
|
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
|
||||||
*/
|
|
||||||
@Override public T visitParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx) { return visitChildren(ctx); }
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
|
|
@ -549,18 +549,6 @@ interface SqlBaseListener extends ParseTreeListener {
|
||||||
* @param ctx the parse tree
|
* @param ctx the parse tree
|
||||||
*/
|
*/
|
||||||
void exitComparison(SqlBaseParser.ComparisonContext ctx);
|
void exitComparison(SqlBaseParser.ComparisonContext ctx);
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by the {@code castOperatorExpression}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#valueExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by the {@code castOperatorExpression}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#valueExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx);
|
|
||||||
/**
|
/**
|
||||||
* Enter a parse tree produced by the {@code arithmeticBinary}
|
* Enter a parse tree produced by the {@code arithmeticBinary}
|
||||||
* labeled alternative in {@link SqlBaseParser#valueExpression}.
|
* labeled alternative in {@link SqlBaseParser#valueExpression}.
|
||||||
|
@ -585,6 +573,18 @@ interface SqlBaseListener extends ParseTreeListener {
|
||||||
* @param ctx the parse tree
|
* @param ctx the parse tree
|
||||||
*/
|
*/
|
||||||
void exitArithmeticUnary(SqlBaseParser.ArithmeticUnaryContext ctx);
|
void exitArithmeticUnary(SqlBaseParser.ArithmeticUnaryContext ctx);
|
||||||
|
/**
|
||||||
|
* Enter a parse tree produced by the {@code dereference}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
void enterDereference(SqlBaseParser.DereferenceContext ctx);
|
||||||
|
/**
|
||||||
|
* Exit a parse tree produced by the {@code dereference}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
void exitDereference(SqlBaseParser.DereferenceContext ctx);
|
||||||
/**
|
/**
|
||||||
* Enter a parse tree produced by the {@code cast}
|
* Enter a parse tree produced by the {@code cast}
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
@ -597,30 +597,6 @@ interface SqlBaseListener extends ParseTreeListener {
|
||||||
* @param ctx the parse tree
|
* @param ctx the parse tree
|
||||||
*/
|
*/
|
||||||
void exitCast(SqlBaseParser.CastContext ctx);
|
void exitCast(SqlBaseParser.CastContext ctx);
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by the {@code extract}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterExtract(SqlBaseParser.ExtractContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by the {@code extract}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitExtract(SqlBaseParser.ExtractContext ctx);
|
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by the {@code currentDateTimeFunction}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by the {@code currentDateTimeFunction}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx);
|
|
||||||
/**
|
/**
|
||||||
* Enter a parse tree produced by the {@code constantDefault}
|
* Enter a parse tree produced by the {@code constantDefault}
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
@ -633,6 +609,30 @@ interface SqlBaseListener extends ParseTreeListener {
|
||||||
* @param ctx the parse tree
|
* @param ctx the parse tree
|
||||||
*/
|
*/
|
||||||
void exitConstantDefault(SqlBaseParser.ConstantDefaultContext ctx);
|
void exitConstantDefault(SqlBaseParser.ConstantDefaultContext ctx);
|
||||||
|
/**
|
||||||
|
* Enter a parse tree produced by the {@code extract}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
void enterExtract(SqlBaseParser.ExtractContext ctx);
|
||||||
|
/**
|
||||||
|
* Exit a parse tree produced by the {@code extract}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
void exitExtract(SqlBaseParser.ExtractContext ctx);
|
||||||
|
/**
|
||||||
|
* Enter a parse tree produced by the {@code parenthesizedExpression}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
void enterParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx);
|
||||||
|
/**
|
||||||
|
* Exit a parse tree produced by the {@code parenthesizedExpression}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
void exitParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx);
|
||||||
/**
|
/**
|
||||||
* Enter a parse tree produced by the {@code star}
|
* Enter a parse tree produced by the {@code star}
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
@ -645,6 +645,18 @@ interface SqlBaseListener extends ParseTreeListener {
|
||||||
* @param ctx the parse tree
|
* @param ctx the parse tree
|
||||||
*/
|
*/
|
||||||
void exitStar(SqlBaseParser.StarContext ctx);
|
void exitStar(SqlBaseParser.StarContext ctx);
|
||||||
|
/**
|
||||||
|
* Enter a parse tree produced by the {@code castOperatorExpression}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
void enterCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx);
|
||||||
|
/**
|
||||||
|
* Exit a parse tree produced by the {@code castOperatorExpression}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
void exitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx);
|
||||||
/**
|
/**
|
||||||
* Enter a parse tree produced by the {@code function}
|
* Enter a parse tree produced by the {@code function}
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
@ -657,6 +669,18 @@ interface SqlBaseListener extends ParseTreeListener {
|
||||||
* @param ctx the parse tree
|
* @param ctx the parse tree
|
||||||
*/
|
*/
|
||||||
void exitFunction(SqlBaseParser.FunctionContext ctx);
|
void exitFunction(SqlBaseParser.FunctionContext ctx);
|
||||||
|
/**
|
||||||
|
* Enter a parse tree produced by the {@code currentDateTimeFunction}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
void enterCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx);
|
||||||
|
/**
|
||||||
|
* Exit a parse tree produced by the {@code currentDateTimeFunction}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
*/
|
||||||
|
void exitCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx);
|
||||||
/**
|
/**
|
||||||
* Enter a parse tree produced by the {@code subqueryExpression}
|
* Enter a parse tree produced by the {@code subqueryExpression}
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
@ -669,30 +693,6 @@ interface SqlBaseListener extends ParseTreeListener {
|
||||||
* @param ctx the parse tree
|
* @param ctx the parse tree
|
||||||
*/
|
*/
|
||||||
void exitSubqueryExpression(SqlBaseParser.SubqueryExpressionContext ctx);
|
void exitSubqueryExpression(SqlBaseParser.SubqueryExpressionContext ctx);
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by the {@code dereference}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterDereference(SqlBaseParser.DereferenceContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by the {@code dereference}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitDereference(SqlBaseParser.DereferenceContext ctx);
|
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by the {@code parenthesizedExpression}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by the {@code parenthesizedExpression}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx);
|
|
||||||
/**
|
/**
|
||||||
* Enter a parse tree produced by {@link SqlBaseParser#builtinDateTimeFunction}.
|
* Enter a parse tree produced by {@link SqlBaseParser#builtinDateTimeFunction}.
|
||||||
* @param ctx the parse tree
|
* @param ctx the parse tree
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -330,13 +330,6 @@ interface SqlBaseVisitor<T> extends ParseTreeVisitor<T> {
|
||||||
* @return the visitor result
|
* @return the visitor result
|
||||||
*/
|
*/
|
||||||
T visitComparison(SqlBaseParser.ComparisonContext ctx);
|
T visitComparison(SqlBaseParser.ComparisonContext ctx);
|
||||||
/**
|
|
||||||
* Visit a parse tree produced by the {@code castOperatorExpression}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#valueExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
* @return the visitor result
|
|
||||||
*/
|
|
||||||
T visitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx);
|
|
||||||
/**
|
/**
|
||||||
* Visit a parse tree produced by the {@code arithmeticBinary}
|
* Visit a parse tree produced by the {@code arithmeticBinary}
|
||||||
* labeled alternative in {@link SqlBaseParser#valueExpression}.
|
* labeled alternative in {@link SqlBaseParser#valueExpression}.
|
||||||
|
@ -351,6 +344,13 @@ interface SqlBaseVisitor<T> extends ParseTreeVisitor<T> {
|
||||||
* @return the visitor result
|
* @return the visitor result
|
||||||
*/
|
*/
|
||||||
T visitArithmeticUnary(SqlBaseParser.ArithmeticUnaryContext ctx);
|
T visitArithmeticUnary(SqlBaseParser.ArithmeticUnaryContext ctx);
|
||||||
|
/**
|
||||||
|
* Visit a parse tree produced by the {@code dereference}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
* @return the visitor result
|
||||||
|
*/
|
||||||
|
T visitDereference(SqlBaseParser.DereferenceContext ctx);
|
||||||
/**
|
/**
|
||||||
* Visit a parse tree produced by the {@code cast}
|
* Visit a parse tree produced by the {@code cast}
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
@ -358,20 +358,6 @@ interface SqlBaseVisitor<T> extends ParseTreeVisitor<T> {
|
||||||
* @return the visitor result
|
* @return the visitor result
|
||||||
*/
|
*/
|
||||||
T visitCast(SqlBaseParser.CastContext ctx);
|
T visitCast(SqlBaseParser.CastContext ctx);
|
||||||
/**
|
|
||||||
* Visit a parse tree produced by the {@code extract}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
* @return the visitor result
|
|
||||||
*/
|
|
||||||
T visitExtract(SqlBaseParser.ExtractContext ctx);
|
|
||||||
/**
|
|
||||||
* Visit a parse tree produced by the {@code currentDateTimeFunction}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
* @return the visitor result
|
|
||||||
*/
|
|
||||||
T visitCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx);
|
|
||||||
/**
|
/**
|
||||||
* Visit a parse tree produced by the {@code constantDefault}
|
* Visit a parse tree produced by the {@code constantDefault}
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
@ -379,6 +365,20 @@ interface SqlBaseVisitor<T> extends ParseTreeVisitor<T> {
|
||||||
* @return the visitor result
|
* @return the visitor result
|
||||||
*/
|
*/
|
||||||
T visitConstantDefault(SqlBaseParser.ConstantDefaultContext ctx);
|
T visitConstantDefault(SqlBaseParser.ConstantDefaultContext ctx);
|
||||||
|
/**
|
||||||
|
* Visit a parse tree produced by the {@code extract}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
* @return the visitor result
|
||||||
|
*/
|
||||||
|
T visitExtract(SqlBaseParser.ExtractContext ctx);
|
||||||
|
/**
|
||||||
|
* Visit a parse tree produced by the {@code parenthesizedExpression}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
* @return the visitor result
|
||||||
|
*/
|
||||||
|
T visitParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx);
|
||||||
/**
|
/**
|
||||||
* Visit a parse tree produced by the {@code star}
|
* Visit a parse tree produced by the {@code star}
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
@ -386,6 +386,13 @@ interface SqlBaseVisitor<T> extends ParseTreeVisitor<T> {
|
||||||
* @return the visitor result
|
* @return the visitor result
|
||||||
*/
|
*/
|
||||||
T visitStar(SqlBaseParser.StarContext ctx);
|
T visitStar(SqlBaseParser.StarContext ctx);
|
||||||
|
/**
|
||||||
|
* Visit a parse tree produced by the {@code castOperatorExpression}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
* @return the visitor result
|
||||||
|
*/
|
||||||
|
T visitCastOperatorExpression(SqlBaseParser.CastOperatorExpressionContext ctx);
|
||||||
/**
|
/**
|
||||||
* Visit a parse tree produced by the {@code function}
|
* Visit a parse tree produced by the {@code function}
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
@ -393,6 +400,13 @@ interface SqlBaseVisitor<T> extends ParseTreeVisitor<T> {
|
||||||
* @return the visitor result
|
* @return the visitor result
|
||||||
*/
|
*/
|
||||||
T visitFunction(SqlBaseParser.FunctionContext ctx);
|
T visitFunction(SqlBaseParser.FunctionContext ctx);
|
||||||
|
/**
|
||||||
|
* Visit a parse tree produced by the {@code currentDateTimeFunction}
|
||||||
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
* @param ctx the parse tree
|
||||||
|
* @return the visitor result
|
||||||
|
*/
|
||||||
|
T visitCurrentDateTimeFunction(SqlBaseParser.CurrentDateTimeFunctionContext ctx);
|
||||||
/**
|
/**
|
||||||
* Visit a parse tree produced by the {@code subqueryExpression}
|
* Visit a parse tree produced by the {@code subqueryExpression}
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
||||||
|
@ -400,20 +414,6 @@ interface SqlBaseVisitor<T> extends ParseTreeVisitor<T> {
|
||||||
* @return the visitor result
|
* @return the visitor result
|
||||||
*/
|
*/
|
||||||
T visitSubqueryExpression(SqlBaseParser.SubqueryExpressionContext ctx);
|
T visitSubqueryExpression(SqlBaseParser.SubqueryExpressionContext ctx);
|
||||||
/**
|
|
||||||
* Visit a parse tree produced by the {@code dereference}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
* @return the visitor result
|
|
||||||
*/
|
|
||||||
T visitDereference(SqlBaseParser.DereferenceContext ctx);
|
|
||||||
/**
|
|
||||||
* Visit a parse tree produced by the {@code parenthesizedExpression}
|
|
||||||
* labeled alternative in {@link SqlBaseParser#primaryExpression}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
* @return the visitor result
|
|
||||||
*/
|
|
||||||
T visitParenthesizedExpression(SqlBaseParser.ParenthesizedExpressionContext ctx);
|
|
||||||
/**
|
/**
|
||||||
* Visit a parse tree produced by {@link SqlBaseParser#builtinDateTimeFunction}.
|
* Visit a parse tree produced by {@link SqlBaseParser#builtinDateTimeFunction}.
|
||||||
* @param ctx the parse tree
|
* @param ctx the parse tree
|
||||||
|
|
|
@ -282,6 +282,19 @@ public class ExpressionTests extends ESTestCase {
|
||||||
assertEquals("line 1:12: Does not recognize type [InVaLiD]", ex.getMessage());
|
assertEquals("line 1:12: Does not recognize type [InVaLiD]", ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCastOperatorPrecedence() {
|
||||||
|
Expression expr = parser.createExpression("(10* 2::long)");
|
||||||
|
assertEquals(Mul.class, expr.getClass());
|
||||||
|
Mul mul = (Mul) expr;
|
||||||
|
assertEquals(DataType.LONG, mul.dataType());
|
||||||
|
assertEquals(DataType.INTEGER, mul.left().dataType());
|
||||||
|
assertEquals(Cast.class, mul.right().getClass());
|
||||||
|
Cast cast = (Cast) mul.right();
|
||||||
|
assertEquals(DataType.INTEGER, cast.from());
|
||||||
|
assertEquals(DataType.LONG, cast.to());
|
||||||
|
assertEquals(DataType.LONG, cast.dataType());
|
||||||
|
}
|
||||||
|
|
||||||
public void testCastOperatorWithUnquotedDataType() {
|
public void testCastOperatorWithUnquotedDataType() {
|
||||||
Expression expr = parser.createExpression("(10* 2)::long");
|
Expression expr = parser.createExpression("(10* 2)::long");
|
||||||
assertEquals(Cast.class, expr.getClass());
|
assertEquals(Cast.class, expr.getClass());
|
||||||
|
|
Loading…
Reference in New Issue