1
0
Эх сурвалжийг харах

SQL: Polish grammar for intervals (#35853)

Costin Leau 7 жил өмнө
parent
commit
e22a83554e

+ 0 - 5
x-pack/plugin/sql/src/main/antlr/SqlBase.g4

@@ -288,11 +288,6 @@ interval
     : INTERVAL sign=(PLUS | MINUS)? (valueNumeric=number | valuePattern=string) leading=intervalField (TO trailing=intervalField)? 
     ;
     
-intervalValue
-    : number
-    | string
-    ;
-
 intervalField
     : YEAR | YEARS | MONTH | MONTHS | DAY | DAYS | HOUR | HOURS | MINUTE | MINUTES | SECOND | SECONDS
     ;

+ 5 - 4
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/parser/ExpressionBuilder.java

@@ -544,10 +544,10 @@ abstract class ExpressionBuilder extends IdentifierBuilder {
                         "Invalid interval declaration; trailing unit [{}] specified but the value is with numeric (single unit), "
                         + "use the string notation instead", trailing);
             }
-            value = of(interval.valueNumeric, negative, leading);
+            value = of(interval.valueNumeric, leading);
             valueAsText = interval.valueNumeric.getText();
         } else {
-            value = visitIntervalValue(interval.valuePattern, negative, intervalType);
+            value = of(interval.valuePattern, negative, intervalType);
             valueAsText = interval.valuePattern.getText();
         }
 
@@ -559,8 +559,9 @@ abstract class ExpressionBuilder extends IdentifierBuilder {
         return new Literal(source(ctx), name, timeInterval, intervalType);
     }
 
-    private TemporalAmount of(NumberContext valueNumeric, boolean negative, TimeUnit unit) {
+    private TemporalAmount of(NumberContext valueNumeric, TimeUnit unit) {
         // expect numbers for now
+        // as the number parsing handles the -, there's no need to look at that
         Literal value = (Literal) visit(valueNumeric);
         Number numeric = (Number) value.fold();
 
@@ -571,7 +572,7 @@ abstract class ExpressionBuilder extends IdentifierBuilder {
         return Intervals.of(source(valueNumeric), numeric.longValue(), unit);
     }
 
-    private TemporalAmount visitIntervalValue(StringContext valuePattern, boolean negative, DataType intervalType) {
+    private TemporalAmount of(StringContext valuePattern, boolean negative, DataType intervalType) {
         String valueString = string(valuePattern);
         Location loc = source(valuePattern);
         TemporalAmount interval = Intervals.parseInterval(loc, valueString, intervalType);

+ 0 - 12
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/parser/SqlBaseBaseListener.java

@@ -995,18 +995,6 @@ class SqlBaseBaseListener implements SqlBaseListener {
    * <p>The default implementation does nothing.</p>
    */
   @Override public void exitInterval(SqlBaseParser.IntervalContext ctx) { }
-  /**
-   * {@inheritDoc}
-   *
-   * <p>The default implementation does nothing.</p>
-   */
-  @Override public void enterIntervalValue(SqlBaseParser.IntervalValueContext ctx) { }
-  /**
-   * {@inheritDoc}
-   *
-   * <p>The default implementation does nothing.</p>
-   */
-  @Override public void exitIntervalValue(SqlBaseParser.IntervalValueContext ctx) { }
   /**
    * {@inheritDoc}
    *

+ 0 - 7
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/parser/SqlBaseBaseVisitor.java

@@ -585,13 +585,6 @@ class SqlBaseBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements SqlBa
    * {@link #visitChildren} on {@code ctx}.</p>
    */
   @Override public T visitInterval(SqlBaseParser.IntervalContext ctx) { return visitChildren(ctx); }
-  /**
-   * {@inheritDoc}
-   *
-   * <p>The default implementation returns the result of calling
-   * {@link #visitChildren} on {@code ctx}.</p>
-   */
-  @Override public T visitIntervalValue(SqlBaseParser.IntervalValueContext ctx) { return visitChildren(ctx); }
   /**
    * {@inheritDoc}
    *

+ 0 - 10
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/parser/SqlBaseListener.java

@@ -923,16 +923,6 @@ interface SqlBaseListener extends ParseTreeListener {
    * @param ctx the parse tree
    */
   void exitInterval(SqlBaseParser.IntervalContext ctx);
-  /**
-   * Enter a parse tree produced by {@link SqlBaseParser#intervalValue}.
-   * @param ctx the parse tree
-   */
-  void enterIntervalValue(SqlBaseParser.IntervalValueContext ctx);
-  /**
-   * Exit a parse tree produced by {@link SqlBaseParser#intervalValue}.
-   * @param ctx the parse tree
-   */
-  void exitIntervalValue(SqlBaseParser.IntervalValueContext ctx);
   /**
    * Enter a parse tree produced by {@link SqlBaseParser#intervalField}.
    * @param ctx the parse tree

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 182 - 183
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/parser/SqlBaseParser.java


+ 0 - 6
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/parser/SqlBaseVisitor.java

@@ -550,12 +550,6 @@ interface SqlBaseVisitor<T> extends ParseTreeVisitor<T> {
    * @return the visitor result
    */
   T visitInterval(SqlBaseParser.IntervalContext ctx);
-  /**
-   * Visit a parse tree produced by {@link SqlBaseParser#intervalValue}.
-   * @param ctx the parse tree
-   * @return the visitor result
-   */
-  T visitIntervalValue(SqlBaseParser.IntervalValueContext ctx);
   /**
    * Visit a parse tree produced by {@link SqlBaseParser#intervalField}.
    * @param ctx the parse tree

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно