|
26 | 26 | import org.elasticsearch.xpack.sql.expression.function.scalar.Cast; |
27 | 27 | import org.elasticsearch.xpack.sql.expression.literal.Interval; |
28 | 28 | import org.elasticsearch.xpack.sql.expression.literal.IntervalDayTime; |
| 29 | +import org.elasticsearch.xpack.sql.expression.literal.IntervalYearMonth; |
29 | 30 | import org.elasticsearch.xpack.sql.expression.literal.Intervals; |
30 | 31 | import org.elasticsearch.xpack.sql.expression.literal.Intervals.TimeUnit; |
31 | | -import org.elasticsearch.xpack.sql.expression.literal.IntervalYearMonth; |
32 | 32 | import org.elasticsearch.xpack.sql.expression.predicate.Range; |
33 | 33 | import org.elasticsearch.xpack.sql.expression.predicate.fulltext.MatchQueryPredicate; |
34 | 34 | import org.elasticsearch.xpack.sql.expression.predicate.fulltext.MultiMatchQueryPredicate; |
|
97 | 97 | import org.elasticsearch.xpack.sql.parser.SqlBaseParser.StringLiteralContext; |
98 | 98 | import org.elasticsearch.xpack.sql.parser.SqlBaseParser.StringQueryContext; |
99 | 99 | import org.elasticsearch.xpack.sql.parser.SqlBaseParser.SubqueryExpressionContext; |
| 100 | +import org.elasticsearch.xpack.sql.parser.SqlBaseParser.SysTypesContext; |
100 | 101 | import org.elasticsearch.xpack.sql.parser.SqlBaseParser.TimeEscapedLiteralContext; |
101 | 102 | import org.elasticsearch.xpack.sql.parser.SqlBaseParser.TimestampEscapedLiteralContext; |
102 | 103 | import org.elasticsearch.xpack.sql.proto.SqlTypedParamValue; |
@@ -653,12 +654,14 @@ public Literal visitIntegerLiteral(IntegerLiteralContext ctx) { |
653 | 654 | throw new ParsingException(source(ctx), siae.getMessage()); |
654 | 655 | } |
655 | 656 |
|
| 657 | + Object val = Long.valueOf(value); |
656 | 658 | DataType type = DataType.LONG; |
657 | 659 | // try to downsize to int if possible (since that's the most common type) |
658 | 660 | if ((int) value == value) { |
659 | 661 | type = DataType.INTEGER; |
| 662 | + val = Integer.valueOf((int) value); |
660 | 663 | } |
661 | | - return new Literal(source(ctx), value, type); |
| 664 | + return new Literal(source(ctx), val, type); |
662 | 665 | } |
663 | 666 |
|
664 | 667 | @Override |
@@ -836,6 +839,8 @@ private boolean hasMinusFromParent(SqlBaseParser.NumberContext ctx) { |
836 | 839 | } else if (parentCtx instanceof SqlBaseParser.IntervalContext) { |
837 | 840 | IntervalContext ic = (IntervalContext) parentCtx; |
838 | 841 | return ic.sign != null && ic.sign.getType() == SqlBaseParser.MINUS; |
| 842 | + } else if (parentCtx instanceof SqlBaseParser.SysTypesContext) { |
| 843 | + return ((SysTypesContext) parentCtx).MINUS() != null; |
839 | 844 | } |
840 | 845 | } |
841 | 846 | return false; |
|
0 commit comments