Просмотр исходного кода

HUE-9370 [editor] Add details about UDF argument locations to the Hive, Presto and Impala parsers

This also removes some duplicate function locations in the generic dialects.
Johan Ahlen 5 лет назад
Родитель
Сommit
750073b49e
43 измененных файлов с 681 добавлено и 569 удалено
  1. 2 5
      desktop/core/src/desktop/js/parse/jison/sql/generic/sql_main.jison
  2. 25 29
      desktop/core/src/desktop/js/parse/jison/sql/generic/sql_udf.jison
  3. 9 9
      desktop/core/src/desktop/js/parse/jison/sql/hive/sql_main.jison
  4. 0 466
      desktop/core/src/desktop/js/parse/jison/sql/hive/sql_udf.jison
  5. 8 2
      desktop/core/src/desktop/js/parse/jison/sql/hive/structure.json
  6. 27 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/udf/sql_aggregate.jison
  7. 19 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/udf/sql_arbitrary.jison
  8. 80 0
      desktop/core/src/desktop/js/parse/jison/sql/hive/udf/sql_extract.jison
  9. 12 12
      desktop/core/src/desktop/js/parse/jison/sql/impala/sql_main.jison
  10. 231 44
      desktop/core/src/desktop/js/parse/jison/sql/impala/sql_udf.jison
  11. 8 2
      desktop/core/src/desktop/js/parse/jison/sql/presto/structure.json
  12. 0 0
      desktop/core/src/desktop/js/parse/sql/calcite/calciteAutocompleteParser.js
  13. 0 0
      desktop/core/src/desktop/js/parse/sql/calcite/calciteSyntaxParser.js
  14. 0 0
      desktop/core/src/desktop/js/parse/sql/druid/druidAutocompleteParser.js
  15. 0 0
      desktop/core/src/desktop/js/parse/sql/druid/druidSyntaxParser.js
  16. 0 0
      desktop/core/src/desktop/js/parse/sql/elasticsearch/elasticsearchAutocompleteParser.js
  17. 0 0
      desktop/core/src/desktop/js/parse/sql/elasticsearch/elasticsearchSyntaxParser.js
  18. 0 0
      desktop/core/src/desktop/js/parse/sql/flink/flinkAutocompleteParser.js
  19. 0 0
      desktop/core/src/desktop/js/parse/sql/flink/flinkSyntaxParser.js
  20. 0 0
      desktop/core/src/desktop/js/parse/sql/generic/genericAutocompleteParser.js
  21. 0 0
      desktop/core/src/desktop/js/parse/sql/generic/genericSyntaxParser.js
  22. 0 0
      desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js
  23. 0 0
      desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js
  24. 40 0
      desktop/core/src/desktop/js/parse/sql/hive/test/hiveAutocompleteParser.Locations.test.js
  25. 54 0
      desktop/core/src/desktop/js/parse/sql/hive/test/hiveAutocompleteParser.Select.test.js
  26. 0 0
      desktop/core/src/desktop/js/parse/sql/impala/impalaAutocompleteParser.js
  27. 0 0
      desktop/core/src/desktop/js/parse/sql/impala/impalaSyntaxParser.js
  28. 48 0
      desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Locations.test.js
  29. 24 0
      desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Select.test.js
  30. 0 0
      desktop/core/src/desktop/js/parse/sql/ksql/ksqlAutocompleteParser.js
  31. 0 0
      desktop/core/src/desktop/js/parse/sql/ksql/ksqlSyntaxParser.js
  32. 0 0
      desktop/core/src/desktop/js/parse/sql/phoenix/phoenixAutocompleteParser.js
  33. 0 0
      desktop/core/src/desktop/js/parse/sql/phoenix/phoenixSyntaxParser.js
  34. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/prestoAutocompleteParser.js
  35. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/prestoSyntaxParser.js
  36. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Analyze.test.js
  37. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Describe.test.js
  38. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Grant.test.js
  39. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.ImportExport.test.js
  40. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Load.test.js
  41. 40 0
      desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Locations.test.js
  42. 54 0
      desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Select.test.js
  43. 0 0
      desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Show.test.js

+ 2 - 5
desktop/core/src/desktop/js/parse/jison/sql/generic/sql_main.jison

@@ -782,7 +782,7 @@ SelectStatement_EDIT
        }
        parser.suggestKeywords(keywords);
      } else {
-       parser.checkForSelectListKeywords($4);
+       parser.checkForSelectListKeywords($3);
      }
      if ($3.suggestFunctions) {
        parser.suggestFunctions();
@@ -1385,10 +1385,7 @@ OrderByIdentifier_EDIT
  ;
 
 OptionalAscOrDesc
- :
-  {
-    $$ = { suggestKeywords: ['ASC', 'DESC'] };
-  }
+ :                          -> { suggestKeywords: ['ASC', 'DESC'] };
  | 'ASC'
  | 'DESC'
  ;

+ 25 - 29
desktop/core/src/desktop/js/parse/jison/sql/generic/sql_udf.jison

@@ -42,6 +42,7 @@ NonParenthesizedValueExpressionPrimary
    }
  | ArbitraryFunctionName ArbitraryFunctionRightPart
   {
+    parser.addFunctionLocation(@1, $1);
     if ($2.expressions && $2.expressions.length) {
       $$ = { function: $1, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
     } else {
@@ -163,7 +164,7 @@ ArbitraryFunctionName
 
 ArbitraryFunctionRightPart
  : '(' ')'
- | '(' ArgumentList ')'  -> $2
+ | '(' UdfArgumentList ')'  -> $2
  ;
 
 ArbitraryFunctionRightPart_EDIT
@@ -175,15 +176,15 @@ ArbitraryFunctionRightPart_EDIT
        expressions: [{ expression: { text: '' }, location: @2 }]
      }
    }
- | '(' ArgumentList 'CURSOR' RightParenthesisOrError
+ | '(' UdfArgumentList 'CURSOR' RightParenthesisOrError
    {
      parser.suggestValueExpressionKeywords($2.expressions[$2.expressions.length - 1].expression);
      $$ = $1;
    }
- | '(' ArgumentList_EDIT RightParenthesisOrError      -> $2
+ | '(' UdfArgumentList_EDIT RightParenthesisOrError      -> $2
  ;
 
-ArgumentList
+UdfArgumentList
  : ValueExpression
    {
      $$ = {
@@ -191,7 +192,7 @@ ArgumentList
        expressions: [{ expression: $1, location: @1 }]
      }
    }
- | ArgumentList ',' ValueExpression
+ | UdfArgumentList ',' ValueExpression
    {
      $$ = {
        activePosition: $1.activePosition + 1,
@@ -200,7 +201,7 @@ ArgumentList
    }
  ;
 
-ArgumentList_EDIT
+UdfArgumentList_EDIT
  : ValueExpression_EDIT
    {
      $$ = {
@@ -208,28 +209,28 @@ ArgumentList_EDIT
        expressions: [{ expression: $1, location: @1 }]
      }
    }
- | ArgumentList ',' ValueExpression_EDIT
+ | UdfArgumentList ',' ValueExpression_EDIT
    {
      $$ = {
        activePosition: $1.activePosition + 1,
        expressions: $1.expressions.concat([{ expression: $3, location: @3 }])
      }
    }
- | ValueExpression_EDIT ',' ArgumentList
+ | ValueExpression_EDIT ',' UdfArgumentList
    {
      $$ = {
        activePosition: 1,
        expressions: [{ expression: $1, location: @1 }].concat($3.expressions)
      }
    }
- | ArgumentList ',' ValueExpression_EDIT ',' ArgumentList
+ | UdfArgumentList ',' ValueExpression_EDIT ',' UdfArgumentList
    {
      $$ = {
        activePosition: $1.activePosition + 1,
        expressions: $1.expressions.concat([{ expression: $3, location: @3 }]).concat($5.expressions)
      }
    }
- | ArgumentList ',' AnyCursor
+ | UdfArgumentList ',' AnyCursor
    {
      parser.valueExpressionSuggest();
      $$ = {
@@ -237,7 +238,7 @@ ArgumentList_EDIT
        expressions: $1.expressions.concat([{ expression: { text: '' }, location: @3 }])
      }
    }
- | ArgumentList ',' AnyCursor ',' ArgumentList
+ | UdfArgumentList ',' AnyCursor ',' UdfArgumentList
    {
      parser.valueExpressionSuggest();
      $$ = {
@@ -245,7 +246,7 @@ ArgumentList_EDIT
        expressions: $1.expressions.concat([{ expression: { text: '' }, location: @3 }]).concat($5.expressions)
      }
    }
- | ArgumentList 'CURSOR' ',' ArgumentList
+ | UdfArgumentList 'CURSOR' ',' UdfArgumentList
    {
      parser.suggestValueExpressionKeywords($1.expressions[$1.expressions.length - 1].expression);
      $$ = {
@@ -253,7 +254,7 @@ ArgumentList_EDIT
        expressions: $1.expressions.concat($4.expressions)
      }
    }
- | AnyCursor ',' ArgumentList
+ | AnyCursor ',' UdfArgumentList
    {
      parser.valueExpressionSuggest();
      $$ = {
@@ -279,7 +280,7 @@ ArgumentList_EDIT
        expressions: [{ expression: { text: '' }, location: @1 }, { expression: { text: '' }, location: @2 }]
      };
    }
- | ',' AnyCursor ',' ArgumentList
+ | ',' AnyCursor ',' UdfArgumentList
    {
      parser.valueExpressionSuggest();
      $$ = {
@@ -304,12 +305,10 @@ AggregateFunction_EDIT
 AnalyticFunction
  : 'ANALYTIC' '(' ')'
   {
-    parser.addFunctionLocation(@1, $1);
     $$ = { function: $1, types: ['UDFREF'] }
   }
- | 'ANALYTIC' '(' ArgumentList ')'
+ | 'ANALYTIC' '(' UdfArgumentList ')'
    {
-     parser.addFunctionLocation(@1, $1);
      parser.addFunctionArgumentLocations($1, $3.expressions);
      $$ = {
        function: $1,
@@ -322,21 +321,18 @@ AnalyticFunction
 AnalyticFunction_EDIT
  : 'ANALYTIC' '(' AnyCursor RightParenthesisOrError
    {
-     parser.addFunctionLocation(@1, $1);
      parser.valueExpressionSuggest();
      parser.applyArgumentTypesToSuggestions($1, 1);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | 'ANALYTIC' '(' ArgumentList 'CURSOR' RightParenthesisOrError
+ | 'ANALYTIC' '(' UdfArgumentList 'CURSOR' RightParenthesisOrError
    {
-     parser.addFunctionLocation(@1, $1);
      parser.addFunctionArgumentLocations($1, $3.expressions);
      parser.suggestValueExpressionKeywords($3.expressions[$3.expressions.length - 1].expression);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | 'ANALYTIC' '(' ArgumentList_EDIT RightParenthesisOrError
+ | 'ANALYTIC' '(' UdfArgumentList_EDIT RightParenthesisOrError
    {
-     parser.addFunctionLocation(@1, $1);
      parser.addFunctionArgumentLocations($1, $3.expressions);
      parser.applyArgumentTypesToSuggestions($1, $3.activePosition);
      $$ = { function: $1, types: ['UDFREF'] };
@@ -372,7 +368,7 @@ CastFunction
          first_line: @3.first_line,
          last_line: @5.last_line,
          first_column: @3.first_column,
-         last_column: @3.last_column
+         last_column: @5.last_column
        }
      }]);
      $$ = { types: [ $5.toUpperCase() ] }
@@ -434,7 +430,7 @@ CountFunction
    {
      $$ = { function: $1, types: ['UDFREF'] }
    }
- | 'COUNT' '(' OptionalAllOrDistinct ArgumentList ')'
+ | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList ')'
    {
      parser.addFunctionArgumentLocations($1, $4.expressions);
      $$ = { function: $1, types: ['UDFREF'] }
@@ -455,12 +451,12 @@ CountFunction_EDIT
      parser.suggestKeywords(keywords);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | 'COUNT' '(' OptionalAllOrDistinct ArgumentList 'CURSOR' RightParenthesisOrError
+ | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList 'CURSOR' RightParenthesisOrError
    {
      parser.suggestValueExpressionKeywords($4.expressions[$4.expressions.length - 1].expression);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | 'COUNT' '(' OptionalAllOrDistinct ArgumentList_EDIT RightParenthesisOrError
+ | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList_EDIT RightParenthesisOrError
    {
      if ($4.cursorAtStart) {
        var keywords = parser.getSelectListKeywords();
@@ -478,7 +474,7 @@ OtherAggregateFunction
    {
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ArgumentList ')'
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList ')'
    {
      parser.addFunctionArgumentLocations($1, $4.expressions);
      $$ = { function: $1, types: ['UDFREF'] };
@@ -504,12 +500,12 @@ OtherAggregateFunction_EDIT
      parser.applyArgumentTypesToSuggestions($1, 1);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ArgumentList 'CURSOR' RightParenthesisOrError
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList 'CURSOR' RightParenthesisOrError
    {
      parser.suggestValueExpressionKeywords($4.expressions[$4.expressions.length - 1].expression);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ArgumentList_EDIT RightParenthesisOrError
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList_EDIT RightParenthesisOrError
    {
      if ($4.cursorAtStart) {
        var keywords = parser.getSelectListKeywords(true);

+ 9 - 9
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_main.jison

@@ -2240,7 +2240,7 @@ InValueList
 NonParenthesizedValueExpressionPrimary
  : UnsignedValueSpecification
  | ColumnOrArbitraryFunctionRef  -> { types: ['COLREF'], columnReference: $1.chain }
- | 'NULL'                        -> { types: [ 'NULL' ] }
+ | 'NULL'                        -> { types: [ 'NULL' ], text: $1 }
  ;
 
 NonParenthesizedValueExpressionPrimary_EDIT
@@ -2294,7 +2294,7 @@ UnsignedValueSpecification_EDIT
  ;
 
 UnsignedLiteral
- : UnsignedNumericLiteral  -> { types: [ 'NUMBER' ] }
+ : UnsignedNumericLiteral  -> { types: [ 'NUMBER' ], text: $1 }
  | GeneralLiteral
  ;
 
@@ -2315,9 +2315,9 @@ ExactNumericLiteral
  ;
 
 ApproximateNumericLiteral
- : UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER'
- | '.' UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER'
- | 'UNSIGNED_INTEGER' '.' UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER'
+ : UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER'                        -> $1 + $2
+ | '.' UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER'                    -> $1 + $2 + $3
+ | 'UNSIGNED_INTEGER' '.' UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER' -> $1 + $2 + $3 + $4
  ;
 
 GeneralLiteral
@@ -2325,7 +2325,7 @@ GeneralLiteral
    {
      if (/\$\{[^}]*\}/.test($1)) {
        parser.addVariableLocation(@1, $1);
-       $$ = { types: [ 'STRING' ], columnReference: [{ name: $1 }] }
+       $$ = { types: [ 'STRING' ], columnReference: [{ name: $1 }], text: "'" + $1 + "'" }
      } else {
        $$ = { types: [ 'STRING' ] }
      }
@@ -2334,12 +2334,12 @@ GeneralLiteral
    {
      if (/\$\{[^}]*\}/.test($1)) {
        parser.addVariableLocation(@1, $1);
-       $$ = { types: [ 'STRING' ], columnReference: [{ name: $1 }] }
+       $$ = { types: [ 'STRING' ], columnReference: [{ name: $1 }], text: '"' + $1 + '"' }
      } else {
-       $$ = { types: [ 'STRING' ] }
+       $$ = { types: [ 'STRING' ], text: '"' + $1 + '"' }
      }
    }
- | TruthValue         -> { types: [ 'BOOLEAN' ] }
+ | TruthValue         -> { types: [ 'BOOLEAN' ], text: $1 }
  ;
 
 GeneralLiteral_EDIT

+ 0 - 466
desktop/core/src/desktop/js/parse/jison/sql/hive/sql_udf.jison

@@ -1,466 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-NonParenthesizedValueExpressionPrimary
- : ColumnOrArbitraryFunctionRef ArbitraryFunctionRightPart
-   {
-     // We need to handle arbitrary UDFs here instead of inside UserDefinedFunction or there will be a conflict
-     // with columnReference for functions like: db.udf(foo)
-     var fn = $1.chain[$1.chain.length - 1].name.toLowerCase();
-     $1.lastLoc.type = 'function';
-     $1.lastLoc.function = fn;
-     $1.lastLoc.location = {
-       first_line: $1.lastLoc.location.first_line,
-       last_line: $1.lastLoc.location.last_line,
-       first_column: $1.lastLoc.location.first_column,
-       last_column: $1.lastLoc.location.last_column - 1
-     }
-     if ($1.lastLoc !== $1.firstLoc) {
-        $1.firstLoc.type = 'database';
-     } else {
-       delete $1.lastLoc.identifierChain;
-     }
-     if ($2.expression) {
-       $$ = { function: fn, expression: $2.expression, types: ['UDFREF'] }
-     } else {
-       $$ = { function: fn, types: ['UDFREF'] }
-     }
-   }
- | ArbitraryFunctionName ArbitraryFunctionRightPart
-  {
-    parser.addFunctionLocation(@1, $1);
-    if ($2.expression) {
-      $$ = { function: $1, expression: $2.expression, types: ['UDFREF'] }
-    } else {
-      $$ = { function: $1, types: ['UDFREF'] }
-    }
-  }
- | UserDefinedFunction
- ;
-
-NonParenthesizedValueExpressionPrimary_EDIT
- : ColumnOrArbitraryFunctionRef ArbitraryFunctionRightPart_EDIT
-   {
-     var fn = $1.chain[$1.chain.length - 1].name.toLowerCase();
-     $1.lastLoc.type = 'function';
-     $1.lastLoc.function = fn;
-     $1.lastLoc.location = {
-       first_line: $1.lastLoc.location.first_line,
-       last_line: $1.lastLoc.location.last_line,
-       first_column: $1.lastLoc.location.first_column,
-       last_column: $1.lastLoc.location.last_column - 1
-     }
-     if ($1.lastLoc !== $1.firstLoc) {
-        $1.firstLoc.type = 'database';
-     } else {
-       delete $1.lastLoc.identifierChain;
-     }
-     if ($2.position) {
-       parser.applyArgumentTypesToSuggestions(fn, $2.position);
-     }
-     $$ = { function: fn, types: ['UDFREF'] };
-   }
- | ArbitraryFunctionName ArbitraryFunctionRightPart_EDIT
-   {
-     parser.addFunctionLocation(@1, $1);
-     if ($2.position) {
-       parser.applyArgumentTypesToSuggestions($1, $2.position);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | UserDefinedFunction_EDIT
- ;
-
-UserDefinedFunction
- : AggregateFunction OptionalOverClause
-   {
-     if (!$2) {
-       $1.suggestKeywords = ['OVER'];
-     }
-   }
- | AnalyticFunction OverClause
- | CastFunction
- | ExtractFunction
- ;
-
-UserDefinedFunction_EDIT
- : AggregateFunction_EDIT
- | AggregateFunction OptionalOverClause_EDIT
- | AnalyticFunction_EDIT
- | AnalyticFunction_EDIT OverClause
- | AnalyticFunction 'CURSOR'
-   {
-     parser.suggestKeywords(['OVER']);
-   }
- | AnalyticFunction OverClause_EDIT
- | CastFunction_EDIT
- | ExtractFunction_EDIT
- ;
-
-ArbitraryFunction
- : RegularIdentifier ArbitraryFunctionRightPart
-   {
-     parser.addFunctionLocation(@1, $1);
-     if ($2.expression) {
-       $$ = { function: $1, expression: $2.expression, types: ['UDFREF'] }
-     } else {
-       $$ = { function: $1, types: ['UDFREF'] }
-     }
-   }
- | ArbitraryFunctionName ArbitraryFunctionRightPart
-   {
-     parser.addFunctionLocation(@1, $1);
-     if ($2.expression) {
-       $$ = { function: $1, expression: $2.expression, types: ['UDFREF'] }
-     } else {
-       $$ = { function: $1, types: ['UDFREF'] }
-     }
-   }
- ;
-
-ArbitraryFunction_EDIT
- : RegularIdentifier ArbitraryFunctionRightPart_EDIT
-   {
-     parser.addFunctionLocation(@1, $1);
-     if ($2.position) {
-       parser.applyArgumentTypesToSuggestions($1, $2.position);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | ArbitraryFunctionName ArbitraryFunctionRightPart_EDIT
-   {
-     parser.addFunctionLocation(@1, $1);
-     if ($2.position) {
-       parser.applyArgumentTypesToSuggestions($1, $2.position);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- ;
-
-ArbitraryFunctionName
- : 'ARRAY'
- | 'BINARY'
- | 'IF'
- | 'MAP'
- | 'TRUNCATE'
- ;
-
-ArbitraryFunctionRightPart
- : '(' ')'
- | '(' ValueExpressionList ')'  -> { expression: $2 }
- ;
-
-ArbitraryFunctionRightPart_EDIT
- : '(' AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     $$ = { position: 1 }
-   }
- | '(' ValueExpressionList 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($3);
-   }
- | '(' ValueExpressionList_EDIT RightParenthesisOrError      -> $2
- ;
-
-AggregateFunction
- : CountFunction
- | SumFunction
- | OtherAggregateFunction
- ;
-
-AggregateFunction_EDIT
- : CountFunction_EDIT
- | SumFunction_EDIT
- | OtherAggregateFunction_EDIT
- ;
-
-AnalyticFunction
- : 'ANALYTIC' '(' ')'                      -> { function: $1, types: ['UDFREF'] }
- | 'ANALYTIC' '(' ValueExpressionList ')'  -> { function: $1, expression: $2, types: ['UDFREF'] }
- ;
-
-AnalyticFunction_EDIT
- : 'ANALYTIC' '(' AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     parser.applyArgumentTypesToSuggestions($1, 1);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'ANALYTIC' '(' ValueExpressionList 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($3);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'ANALYTIC' '(' ValueExpressionList_EDIT RightParenthesisOrError
-   {
-     parser.applyArgumentTypesToSuggestions($1, $3.position);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- ;
-
-OptionalOverClause
- :
- | OverClause
- ;
-
-OptionalOverClause_EDIT
- : OverClause_EDIT
- ;
-
-OverClause
- : 'OVER' RegularOrBacktickedIdentifier
- | 'OVER' WindowExpression
- ;
-
-OverClause_EDIT
- : 'OVER' WindowExpression_EDIT
- ;
-
-CastFunction
- : 'CAST' '(' ValueExpression 'AS' PrimitiveType ')'  -> { types: [ $5.toUpperCase() ] }
- | 'CAST' '(' ')'                                      -> { types: [ 'T' ] }
- ;
-
-CastFunction_EDIT
- : 'CAST' '(' AnyCursor 'AS' PrimitiveType RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     $$ = { types: [ $5.toUpperCase() ] };
-   }
- | 'CAST' '(' AnyCursor 'AS' RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     $$ = { types: [ 'T' ] };
-   }
- | 'CAST' '(' AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     $$ = { types: [ 'T' ] };
-   }
- | 'CAST' '(' ValueExpression_EDIT 'AS' PrimitiveType RightParenthesisOrError  -> { types: [ $5.toUpperCase() ] }
- | 'CAST' '(' ValueExpression_EDIT 'AS' RightParenthesisOrError                -> { types: [ 'T' ] }
- | 'CAST' '(' ValueExpression_EDIT RightParenthesisOrError                      -> { types: [ 'T' ] }
- | 'CAST' '(' ValueExpression 'CURSOR' PrimitiveType RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($3, [{ value: 'AS', weight: 2 }]);
-     $$ =  { types: [ $5.toUpperCase() ] };
-   }
- | 'CAST' '(' ValueExpression 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($3, [{ value: 'AS', weight: 2 }]);
-     $$ = { types: [ 'T' ] };
-   }
- | 'CAST' '(' ValueExpression 'AS' 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestKeywords(parser.getTypeKeywords());
-     $$ = { types: [ 'T' ] };
-   }
- | 'CAST' '(' 'AS' 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestKeywords(parser.getTypeKeywords());
-     $$ = { types: [ 'T' ] };
-   }
- ;
-
-CountFunction
- : 'COUNT' '(' '*' ')'                                        -> { function: $1, types: ['UDFREF'] }
- | 'COUNT' '(' ')'                                            -> { function: $1, types: ['UDFREF'] }
- | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList ')'  -> { function: $1, types: ['UDFREF'] }
- ;
-
-CountFunction_EDIT
- : 'COUNT' '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     var keywords = parser.getSelectListKeywords();
-     if (!$3) {
-       keywords.push('DISTINCT');
-       if (parser.yy.result.suggestKeywords) {
-         keywords = parser.yy.result.suggestKeywords.concat(keywords);
-       }
-     }
-     parser.suggestKeywords(keywords);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($4);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
-   {
-     if ($4.cursorAtStart) {
-       var keywords = parser.getSelectListKeywords();
-       if (!$3) {
-         keywords.push('DISTINCT');
-       }
-       parser.suggestKeywords(keywords);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- ;
-
-ExtractFunction
- : 'EXTRACT' '(' DateField 'FROM' ValueExpression ')'  -> { types: ['INT', 'INTEGER'] }
- ;
-
-ExtractFunction_EDIT
- : 'EXTRACT' '(' AnyCursor RightParenthesisOrError
-   {
-     parser.suggestKeywords(['DAY', 'DAYOFWEEK', 'HOUR', 'MINUTE', 'MONTH', 'QUARTER', 'SECOND', 'WEEK', 'YEAR']);
-     $$ = { types: ['INT', 'INTEGER'] }
-   }
- | 'EXTRACT' '(' DateField 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestKeywords(['FROM']);
-     $$ = { types: ['INT', 'INTEGER'] }
-   }
- | 'EXTRACT' '(' DateField 'FROM' 'CURSOR' RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     $$ = { types: ['INT', 'INTEGER'] }
-   }
- | 'EXTRACT' '(' DateField 'FROM' ValueExpression_EDIT RightParenthesisOrError  -> { types: ['INT', 'INTEGER'] }
- | 'EXTRACT' '(' AnyCursor 'FROM' ValueExpression RightParenthesisOrError
-   {
-      parser.suggestKeywords(['DAY', 'DAYOFWEEK', 'HOUR', 'MINUTE', 'MONTH', 'QUARTER', 'SECOND', 'WEEK', 'YEAR']);
-      $$ = { types: ['INT', 'INTEGER'] }
-   }
- | 'EXTRACT' '(' DateField 'CURSOR' ValueExpression RightParenthesisOrError
-   {
-     parser.suggestKeywords(['FROM']);
-     $$ = { types: ['INT', 'INTEGER'] }
-   }
- ;
-
-DateField
- : 'DAY'
- | 'DAYOFWEEK'
- | 'HOUR'
- | 'MINUTE'
- | 'MONTH'
- | 'QUARTER'
- | 'SECOND'
- | 'WEEK'
- | 'YEAR'
- ;
-
-OtherAggregateFunction
- : OtherAggregateFunction_Type '(' OptionalAllOrDistinct ')'                      -> { function: $1, types: ['UDFREF'] }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList ')'  -> { function: $1, types: ['UDFREF'] }
- ;
-
-OtherAggregateFunction_EDIT
- : OtherAggregateFunction_Type '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     var keywords = parser.getSelectListKeywords(true);
-     if (!$3) {
-       if ($1.toLowerCase() === 'group_concat') {
-         keywords.push('ALL');
-       } else {
-         keywords.push('DISTINCT');
-       }
-     }
-     if (parser.yy.result.suggestKeywords) {
-       keywords = parser.yy.result.suggestKeywords.concat(keywords);
-     }
-     parser.suggestKeywords(keywords);
-     parser.applyArgumentTypesToSuggestions($1, 1);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($4);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
-   {
-     if ($4.cursorAtStart) {
-       var keywords = parser.getSelectListKeywords(true);
-       if (!$3) {
-         if ($1.toLowerCase() === 'group_concat') {
-           keywords.push('ALL');
-         } else {
-           keywords.push('DISTINCT');
-         }
-       }
-       if (parser.yy.result.suggestKeywords) {
-         keywords = parser.yy.result.suggestKeywords.concat(keywords);
-       }
-       parser.suggestKeywords(keywords);
-     }
-     if (parser.yy.result.suggestFunctions && !parser.yy.result.suggestFunctions.types) {
-       parser.applyArgumentTypesToSuggestions($1, $4.position);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- ;
-
-OtherAggregateFunction_Type
- : 'AVG'
- | 'COLLECT_LIST'
- | 'COLLECT_SET'
- | 'CORR'
- | 'COVAR_POP'
- | 'COVAR_SAMP'
- | 'HISTOGRAM_NUMERIC'
- | 'MAX'
- | 'MIN'
- | 'NTILE'
- | 'PERCENTILE'
- | 'PERCENTILE_APPROX'
- | 'STDDEV_POP'
- | 'STDDEV_SAMP'
- | 'VAR_POP'
- | 'VAR_SAMP'
- | 'VARIANCE'
- ;
-
-SumFunction
- : 'SUM' '(' OptionalAllOrDistinct ValueExpression ')'  -> { function: $1, types: ['UDFREF'] }
- | 'SUM' '(' ')'                                        -> { function: $1, types: ['UDFREF'] }
- ;
-
-SumFunction_EDIT
- : 'SUM' '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
-   {
-     parser.valueExpressionSuggest();
-     parser.applyArgumentTypesToSuggestions($1, 1);
-     var keywords = parser.getSelectListKeywords(true);
-     if (!$3) {
-       keywords.push('DISTINCT');
-     }
-     if (parser.yy.result.suggestKeywords) {
-       keywords = parser.yy.result.suggestKeywords.concat(keywords);
-     }
-     parser.suggestKeywords(keywords);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'SUM' '(' OptionalAllOrDistinct ValueExpression 'CURSOR' RightParenthesisOrError
-   {
-     parser.suggestValueExpressionKeywords($4);
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- | 'SUM' '(' OptionalAllOrDistinct ValueExpression_EDIT RightParenthesisOrError
-   {
-     if (parser.yy.result.suggestFunctions && !parser.yy.result.suggestFunctions.types) {
-       parser.applyArgumentTypesToSuggestions($1, 1);
-     }
-     $$ = { function: $1, types: ['UDFREF'] };
-   }
- ;

+ 8 - 2
desktop/core/src/desktop/js/parse/jison/sql/hive/structure.json

@@ -18,7 +18,10 @@
     "sql_set.jison",
     "show/sql_show.jison",
     "show/sql_show_materialized_views.jison",
-    "sql_udf.jison",
+    "../generic/sql_udf.jison",
+    "udf/sql_aggregate.jison",
+    "udf/sql_arbitrary.jison",
+    "udf/sql_extract.jison",
     "sql_update.jison",
     "../generic/sql_use.jison",
     "../generic/sql_valueExpression.jison",
@@ -41,7 +44,10 @@
     "sql_set.jison",
     "show/sql_show.jison",
     "show/sql_show_materialized_views.jison",
-    "sql_udf.jison",
+    "../generic/sql_udf.jison",
+    "udf/sql_aggregate.jison",
+    "udf/sql_arbitrary.jison",
+    "udf/sql_extract.jison",
     "sql_update.jison",
     "../generic/sql_use.jison",
     "../generic/sql_valueExpression.jison",

+ 27 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/udf/sql_aggregate.jison

@@ -0,0 +1,27 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+OtherAggregateFunction_Type
+ : 'COLLECT_LIST'
+ | 'COLLECT_SET'
+ | 'CORR'
+ | 'COVAR_POP'
+ | 'COVAR_SAMP'
+ | 'HISTOGRAM_NUMERIC'
+ | 'NTILE'
+ | 'PERCENTILE'
+ | 'PERCENTILE_APPROX'
+ ;

+ 19 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/udf/sql_arbitrary.jison

@@ -0,0 +1,19 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+ArbitraryFunctionName
+ : 'BINARY'
+ ;

+ 80 - 0
desktop/core/src/desktop/js/parse/jison/sql/hive/udf/sql_extract.jison

@@ -0,0 +1,80 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+UserDefinedFunction
+ : ExtractFunction
+ ;
+
+UserDefinedFunction_EDIT
+ : ExtractFunction_EDIT
+ ;
+
+ExtractFunction
+ : 'EXTRACT' '(' DateField 'FROM' ValueExpression ')'
+   {
+     parser.addFunctionArgumentLocations($1, [{
+       expression: $5,
+       location: {
+         first_line: @3.first_line,
+         last_line: @5.last_line,
+         first_column: @3.first_column,
+         last_column: @5.last_column
+       }
+     }]);
+     $$ = { types: ['INT', 'INTEGER'] }
+   }
+ ;
+
+ExtractFunction_EDIT
+ : 'EXTRACT' '(' AnyCursor RightParenthesisOrError
+   {
+     parser.suggestKeywords(['DAY', 'DAYOFWEEK', 'HOUR', 'MINUTE', 'MONTH', 'QUARTER', 'SECOND', 'WEEK', 'YEAR']);
+     $$ = { types: ['INT', 'INTEGER'] }
+   }
+ | 'EXTRACT' '(' DateField 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestKeywords(['FROM']);
+     $$ = { types: ['INT', 'INTEGER'] }
+   }
+ | 'EXTRACT' '(' DateField 'FROM' 'CURSOR' RightParenthesisOrError
+   {
+     parser.valueExpressionSuggest();
+     $$ = { types: ['INT', 'INTEGER'] }
+   }
+ | 'EXTRACT' '(' DateField 'FROM' ValueExpression_EDIT RightParenthesisOrError  -> { types: ['INT', 'INTEGER'] }
+ | 'EXTRACT' '(' AnyCursor 'FROM' ValueExpression RightParenthesisOrError
+   {
+      parser.suggestKeywords(['DAY', 'DAYOFWEEK', 'HOUR', 'MINUTE', 'MONTH', 'QUARTER', 'SECOND', 'WEEK', 'YEAR']);
+      $$ = { types: ['INT', 'INTEGER'] }
+   }
+ | 'EXTRACT' '(' DateField 'CURSOR' ValueExpression RightParenthesisOrError
+   {
+     parser.suggestKeywords(['FROM']);
+     $$ = { types: ['INT', 'INTEGER'] }
+   }
+ ;
+
+DateField
+ : 'DAY'
+ | 'DAYOFWEEK'
+ | 'HOUR'
+ | 'MINUTE'
+ | 'MONTH'
+ | 'QUARTER'
+ | 'SECOND'
+ | 'WEEK'
+ | 'YEAR'
+ ;

+ 12 - 12
desktop/core/src/desktop/js/parse/jison/sql/impala/sql_main.jison

@@ -2172,9 +2172,9 @@ InValueList
 
 NonParenthesizedValueExpressionPrimary
  : UnsignedValueSpecification
- | ColumnOrArbitraryFunctionRef             -> { types: ['COLREF'], columnReference: $1.chain }
- | 'NULL'                      -> { types: [ 'NULL' ] }
- | IntervalSpecification       -> { types: [ 'TIMESTAMP' ] }
+ | ColumnOrArbitraryFunctionRef  -> { types: ['COLREF'], columnReference: $1.chain }
+ | 'NULL'                        -> { types: [ 'NULL' ], text: $1 }
+ | IntervalSpecification         -> { types: [ 'TIMESTAMP' ], text: $1 }
  ;
 
 NonParenthesizedValueExpressionPrimary_EDIT
@@ -2212,7 +2212,7 @@ ColumnOrArbitraryFunctionRef_EDIT
  ;
 
 IntervalSpecification
- : 'INTERVAL' SignedInteger RegularIdentifier
+ : 'INTERVAL' SignedInteger RegularIdentifier  -> $1 + $2 + $3
  ;
 
 IntervalSpecification_EDIT
@@ -2240,7 +2240,7 @@ UnsignedValueSpecification_EDIT
  ;
 
 UnsignedLiteral
- : UnsignedNumericLiteral  -> { types: [ 'NUMBER' ] }
+ : UnsignedNumericLiteral  -> { types: [ 'NUMBER' ], text: $1 }
  | GeneralLiteral
  ;
 
@@ -2261,9 +2261,9 @@ ExactNumericLiteral
  ;
 
 ApproximateNumericLiteral
- : UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER'
- | '.' UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER'
- | 'UNSIGNED_INTEGER' '.' UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER'
+ : UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER'                        -> $1 + $2
+ | '.' UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER'                    -> $1 + $2 + $3
+ | 'UNSIGNED_INTEGER' '.' UNSIGNED_INTEGER_E 'UNSIGNED_INTEGER' -> $1 + $2 + $3 + $4
  ;
 
 GeneralLiteral
@@ -2271,7 +2271,7 @@ GeneralLiteral
    {
      if (/\$\{[^}]*\}/.test($1)) {
        parser.addVariableLocation(@1, $1);
-       $$ = { types: [ 'STRING' ], columnReference: [{ name: $1 }] }
+       $$ = { types: [ 'STRING' ], columnReference: [{ name: $1 }], text: "'" + $1 + "'" }
      } else {
        $$ = { types: [ 'STRING' ] }
      }
@@ -2280,12 +2280,12 @@ GeneralLiteral
    {
      if (/\$\{[^}]*\}/.test($1)) {
        parser.addVariableLocation(@1, $1);
-       $$ = { types: [ 'STRING' ], columnReference: [{ name: $1 }] }
+       $$ = { types: [ 'STRING' ], columnReference: [{ name: $1 }], text: '"' + $1 + '"' }
      } else {
-       $$ = { types: [ 'STRING' ] }
+       $$ = { types: [ 'STRING' ], text: '"' + $1 + '"' }
      }
    }
- | TruthValue         -> { types: [ 'BOOLEAN' ] }
+ | TruthValue         -> { types: [ 'BOOLEAN' ], text: $1 }
  ;
 
 GeneralLiteral_EDIT

+ 231 - 44
desktop/core/src/desktop/js/parse/jison/sql/impala/sql_udf.jison

@@ -20,6 +20,7 @@ NonParenthesizedValueExpressionPrimary
      // We need to handle arbitrary UDFs here instead of inside UserDefinedFunction or there will be a conflict
      // with columnReference for functions like: db.udf(foo)
      var fn = $1.chain[$1.chain.length - 1].name.toLowerCase();
+     parser.addFunctionArgumentLocations(fn, $2.expressions, $1.chain);
      $1.lastLoc.type = 'function';
      $1.lastLoc.function = fn;
      $1.lastLoc.location = {
@@ -33,8 +34,8 @@ NonParenthesizedValueExpressionPrimary
      } else {
        delete $1.lastLoc.identifierChain;
      }
-     if ($2.expression) {
-       $$ = { function: fn, expression: $2.expression, types: ['UDFREF'] }
+     if ($2.expressions && $2.expressions.length) {
+       $$ = { function: fn, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
      } else {
        $$ = { function: fn, types: ['UDFREF'] }
      }
@@ -42,8 +43,8 @@ NonParenthesizedValueExpressionPrimary
  | ArbitraryFunctionName ArbitraryFunctionRightPart
   {
     parser.addFunctionLocation(@1, $1);
-    if ($2.expression) {
-      $$ = { function: $1, expression: $2.expression, types: ['UDFREF'] }
+    if ($2.expressions && $2.expressions.length) {
+      $$ = { function: $1, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
     } else {
       $$ = { function: $1, types: ['UDFREF'] }
     }
@@ -55,6 +56,7 @@ NonParenthesizedValueExpressionPrimary_EDIT
  : ColumnOrArbitraryFunctionRef ArbitraryFunctionRightPart_EDIT
    {
      var fn = $1.chain[$1.chain.length - 1].name.toLowerCase();
+     parser.addFunctionArgumentLocations(fn, $2.expressions, $1.chain);
      $1.lastLoc.type = 'function';
      $1.lastLoc.function = fn;
      $1.lastLoc.location = {
@@ -68,16 +70,17 @@ NonParenthesizedValueExpressionPrimary_EDIT
      } else {
        delete $1.lastLoc.identifierChain;
      }
-     if ($2.position) {
-       parser.applyArgumentTypesToSuggestions(fn, $2.position);
+     if ($2.activePosition) {
+       parser.applyArgumentTypesToSuggestions(fn, $2.activePosition);
      }
      $$ = { function: fn, types: ['UDFREF'] };
    }
  | ArbitraryFunctionName ArbitraryFunctionRightPart_EDIT
    {
      parser.addFunctionLocation(@1, $1);
-     if ($2.position) {
-       parser.applyArgumentTypesToSuggestions($1, $2.position);
+     parser.addFunctionArgumentLocations($1, $2.expressions);
+     if ($2.activePosition) {
+       parser.applyArgumentTypesToSuggestions($1, $2.activePosition);
      }
      $$ = { function: $1, types: ['UDFREF'] };
    }
@@ -114,8 +117,9 @@ ArbitraryFunction
  : RegularIdentifier ArbitraryFunctionRightPart
    {
      parser.addFunctionLocation(@1, $1);
-     if ($2.expression) {
-       $$ = { function: $1, expression: $2.expression, types: ['UDFREF'] }
+     parser.addFunctionArgumentLocations($1, $2.expressions);
+     if ($2.expressions && $2.expressions.length) {
+       $$ = { function: $1, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
      } else {
        $$ = { function: $1, types: ['UDFREF'] }
      }
@@ -123,8 +127,9 @@ ArbitraryFunction
  | ArbitraryFunctionName ArbitraryFunctionRightPart
    {
      parser.addFunctionLocation(@1, $1);
-     if ($2.expression) {
-       $$ = { function: $1, expression: $2.expression, types: ['UDFREF'] }
+     parser.addFunctionArgumentLocations($1, $2.expressions);
+     if ($2.expressions && $2.expressions.length) {
+       $$ = { function: $1, expression: $2.expressions[$2.expressions.length - 1].expression, types: ['UDFREF'] }
      } else {
        $$ = { function: $1, types: ['UDFREF'] }
      }
@@ -135,16 +140,18 @@ ArbitraryFunction_EDIT
  : RegularIdentifier ArbitraryFunctionRightPart_EDIT
    {
      parser.addFunctionLocation(@1, $1);
-     if ($2.position) {
-       parser.applyArgumentTypesToSuggestions($1, $2.position);
+     parser.addFunctionArgumentLocations($1, $2.expressions);
+     if ($2.activePosition) {
+       parser.applyArgumentTypesToSuggestions($1, $2.activePosition);
      }
      $$ = { function: $1, types: ['UDFREF'] };
    }
  | ArbitraryFunctionName ArbitraryFunctionRightPart_EDIT
    {
      parser.addFunctionLocation(@1, $1);
-     if ($2.position) {
-       parser.applyArgumentTypesToSuggestions($1, $2.position);
+     parser.addFunctionArgumentLocations($1, $2.expressions);
+     if ($2.activePosition) {
+       parser.applyArgumentTypesToSuggestions($1, $2.activePosition);
      }
      $$ = { function: $1, types: ['UDFREF'] };
    }
@@ -161,20 +168,130 @@ ArbitraryFunctionName
 
 ArbitraryFunctionRightPart
  : '(' ')'
- | '(' ValueExpressionList ')'  -> { expression: $2 }
+ | '(' UdfArgumentList ')'  -> $2
  ;
 
 ArbitraryFunctionRightPart_EDIT
  : '(' AnyCursor RightParenthesisOrError
    {
      parser.valueExpressionSuggest();
-     $$ = { position: 1 }
+     $$ = {
+       activePosition: 1,
+       expressions: [{ expression: { text: '' }, location: @2 }]
+     }
+   }
+ | '(' UdfArgumentList 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestValueExpressionKeywords($2.expressions[$2.expressions.length - 1].expression);
+     $$ = $1;
+   }
+ | '(' UdfArgumentList_EDIT RightParenthesisOrError      -> $2
+ ;
+
+UdfArgumentList
+ : ValueExpression
+   {
+     $$ = {
+       activePosition: 1,
+       expressions: [{ expression: $1, location: @1 }]
+     }
+   }
+ | UdfArgumentList ',' ValueExpression
+   {
+     $$ = {
+       activePosition: $1.activePosition + 1,
+       expressions: $1.expressions.concat([{ expression: $3, location: @3 }])
+     }
+   }
+ ;
+
+UdfArgumentList_EDIT
+ : ValueExpression_EDIT
+   {
+     $$ = {
+       activePosition: 1,
+       expressions: [{ expression: $1, location: @1 }]
+     }
+   }
+ | UdfArgumentList ',' ValueExpression_EDIT
+   {
+     $$ = {
+       activePosition: $1.activePosition + 1,
+       expressions: $1.expressions.concat([{ expression: $3, location: @3 }])
+     }
+   }
+ | ValueExpression_EDIT ',' UdfArgumentList
+   {
+     $$ = {
+       activePosition: 1,
+       expressions: [{ expression: $1, location: @1 }].concat($3.expressions)
+     }
+   }
+ | UdfArgumentList ',' ValueExpression_EDIT ',' UdfArgumentList
+   {
+     $$ = {
+       activePosition: $1.activePosition + 1,
+       expressions: $1.expressions.concat([{ expression: $3, location: @3 }]).concat($5.expressions)
+     }
+   }
+ | UdfArgumentList ',' AnyCursor
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       activePosition: $1.activePosition + 1,
+       expressions: $1.expressions.concat([{ expression: { text: '' }, location: @3 }])
+     }
+   }
+ | UdfArgumentList ',' AnyCursor ',' UdfArgumentList
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       activePosition: $1.activePosition + 1,
+       expressions: $1.expressions.concat([{ expression: { text: '' }, location: @3 }]).concat($5.expressions)
+     }
+   }
+ | UdfArgumentList 'CURSOR' ',' UdfArgumentList
+   {
+     parser.suggestValueExpressionKeywords($1.expressions[$1.expressions.length - 1].expression);
+     $$ = {
+       activePosition: $1.activePosition,
+       expressions: $1.expressions.concat($4.expressions)
+     }
+   }
+ | AnyCursor ',' UdfArgumentList
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       cursorAtStart : true,
+       activePosition: 1,
+       expressions: [{ expression: { text: '' }, location: @1 }].concat($3.expressions)
+     };
+   }
+ | AnyCursor ','
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       cursorAtStart : true,
+       activePosition: 1,
+       expressions: [{ expression: { text: '' }, location: @1 }, { expression: { text: '' }, location: @2 }]
+     };
+   }
+ | ',' AnyCursor
+   {
+     parser.valueExpressionSuggest();
+     $$ = {
+       activePosition: 2,
+       expressions: [{ expression: { text: '' }, location: @1 }, { expression: { text: '' }, location: @2 }]
+     };
    }
- | '(' ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | ',' AnyCursor ',' UdfArgumentList
    {
-     parser.suggestValueExpressionKeywords($3);
+     parser.valueExpressionSuggest();
+     $$ = {
+       activePosition: 2,
+       expressions: [{ expression: { text: '' }, location: @1 }, { expression: { text: '' }, location: @2 }].concat($4.expressions)
+     };
    }
- | '(' ValueExpressionList_EDIT RightParenthesisOrError      -> $2
  ;
 
 AggregateFunction
@@ -190,8 +307,19 @@ AggregateFunction_EDIT
  ;
 
 AnalyticFunction
- : 'ANALYTIC' '(' ')'                      -> { function: $1, types: ['UDFREF'] }
- | 'ANALYTIC' '(' ValueExpressionList ')'  -> { function: $1, expression: $2, types: ['UDFREF'] }
+ : 'ANALYTIC' '(' ')'
+  {
+    $$ = { function: $1, types: ['UDFREF'] }
+  }
+ | 'ANALYTIC' '(' UdfArgumentList ')'
+   {
+     parser.addFunctionArgumentLocations($1, $3.expressions);
+     $$ = {
+       function: $1,
+       expression: $3.expressions[$3.expressions.length - 1].expression,
+       types: ['UDFREF']
+     }
+   }
  ;
 
 AnalyticFunction_EDIT
@@ -201,14 +329,16 @@ AnalyticFunction_EDIT
      parser.applyArgumentTypesToSuggestions($1, 1);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | 'ANALYTIC' '(' ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | 'ANALYTIC' '(' UdfArgumentList 'CURSOR' RightParenthesisOrError
    {
-     parser.suggestValueExpressionKeywords($3);
+     parser.addFunctionArgumentLocations($1, $3.expressions);
+     parser.suggestValueExpressionKeywords($3.expressions[$3.expressions.length - 1].expression);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | 'ANALYTIC' '(' ValueExpressionList_EDIT RightParenthesisOrError
+ | 'ANALYTIC' '(' UdfArgumentList_EDIT RightParenthesisOrError
    {
-     parser.applyArgumentTypesToSuggestions($1, $3.position);
+     parser.addFunctionArgumentLocations($1, $3.expressions);
+     parser.applyArgumentTypesToSuggestions($1, $3.activePosition);
      $$ = { function: $1, types: ['UDFREF'] };
    }
  ;
@@ -232,7 +362,21 @@ OverClause_EDIT
  ;
 
 CastFunction
- : 'CAST' '(' ValueExpression 'AS' PrimitiveType ')'  -> { types: [ $5.toUpperCase() ] }
+ : 'CAST' '(' ValueExpression 'AS' PrimitiveType ')'
+   {
+     var expression = $3;
+     parser.extractExpressionText(expression, $3, $4, $5);
+     parser.addFunctionArgumentLocations($1, [{
+       expression: expression,
+       location: {
+         first_line: @3.first_line,
+         last_line: @5.last_line,
+         first_column: @3.first_column,
+         last_column: @5.last_column
+       }
+     }]);
+     $$ = { types: [ $5.toUpperCase() ] }
+   }
  | 'CAST' '(' ')'                                      -> { types: [ 'T' ] }
  ;
 
@@ -254,7 +398,7 @@ CastFunction_EDIT
    }
  | 'CAST' '(' ValueExpression_EDIT 'AS' PrimitiveType RightParenthesisOrError  -> { types: [ $5.toUpperCase() ] }
  | 'CAST' '(' ValueExpression_EDIT 'AS' RightParenthesisOrError                -> { types: [ 'T' ] }
- | 'CAST' '(' ValueExpression_EDIT RightParenthesisOrError                      -> { types: [ 'T' ] }
+ | 'CAST' '(' ValueExpression_EDIT RightParenthesisOrError                     -> { types: [ 'T' ] }
  | 'CAST' '(' ValueExpression 'CURSOR' PrimitiveType RightParenthesisOrError
    {
      parser.suggestValueExpressionKeywords($3, [{ value: 'AS', weight: 2 }]);
@@ -278,9 +422,23 @@ CastFunction_EDIT
  ;
 
 CountFunction
- : 'COUNT' '(' '*' ')'                                        -> { function: $1, types: ['UDFREF'] }
- | 'COUNT' '(' ')'                                            -> { function: $1, types: ['UDFREF'] }
- | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList ')'  -> { function: $1, types: ['UDFREF'] }
+ : 'COUNT' '(' '*' ')'
+   {
+     parser.addFunctionArgumentLocations($1, [{
+       expression: { text: $3 },
+       location: @3
+     }]);
+     $$ = { function: $1, types: ['UDFREF'] }
+   }
+ | 'COUNT' '(' ')'
+   {
+     $$ = { function: $1, types: ['UDFREF'] }
+   }
+ | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList ')'
+   {
+     parser.addFunctionArgumentLocations($1, $4.expressions);
+     $$ = { function: $1, types: ['UDFREF'] }
+   }
  ;
 
 CountFunction_EDIT
@@ -298,12 +456,12 @@ CountFunction_EDIT
      parser.suggestKeywords(keywords);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList 'CURSOR' RightParenthesisOrError
    {
-     parser.suggestValueExpressionKeywords($4);
+     parser.suggestValueExpressionKeywords($4.expressions[$4.expressions.length - 1].expression);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
+ | 'COUNT' '(' OptionalAllOrDistinct UdfArgumentList_EDIT RightParenthesisOrError
    {
      if ($4.cursorAtStart) {
        var keywords = parser.getSelectListKeywords();
@@ -318,8 +476,15 @@ CountFunction_EDIT
  ;
 
 OtherAggregateFunction
- : OtherAggregateFunction_Type '(' OptionalAllOrDistinct ')'                      -> { function: $1, types: ['UDFREF'] }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList ')'  -> { function: $1, types: ['UDFREF'] }
+ : OtherAggregateFunction_Type '(' OptionalAllOrDistinct ')'
+   {
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList ')'
+   {
+     parser.addFunctionArgumentLocations($1, $4.expressions);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
  ;
 
 OtherAggregateFunction_EDIT
@@ -342,12 +507,12 @@ OtherAggregateFunction_EDIT
      parser.applyArgumentTypesToSuggestions($1, 1);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList 'CURSOR' RightParenthesisOrError
    {
-     parser.suggestValueExpressionKeywords($4);
+     parser.suggestValueExpressionKeywords($4.expressions[$4.expressions.length - 1].expression);
      $$ = { function: $1, types: ['UDFREF'] };
    }
- | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct UdfArgumentList_EDIT RightParenthesisOrError
    {
      if ($4.cursorAtStart) {
        var keywords = parser.getSelectListKeywords(true);
@@ -365,7 +530,7 @@ OtherAggregateFunction_EDIT
        parser.suggestKeywords(keywords);
      }
      if (parser.yy.result.suggestFunctions && !parser.yy.result.suggestFunctions.types) {
-       parser.applyArgumentTypesToSuggestions($1, $4.position);
+       parser.applyArgumentTypesToSuggestions($1, $4.activePosition);
      }
      $$ = { function: $1, types: ['UDFREF'] };
    }
@@ -390,7 +555,22 @@ OtherAggregateFunction_Type
 
 ExtractFunction
  : 'EXTRACT' '(' ValueExpression FromOrComma ValueExpression ')'
+   {
+     parser.addFunctionArgumentLocations($1, [{
+       expression: $5,
+       location: {
+         first_line: @3.first_line,
+         last_line: @5.last_line,
+         first_column: @3.first_column,
+         last_column: @5.last_column
+       }
+     }]);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
  | 'EXTRACT' '(' ')'
+   {
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
  ;
 
 ExtractFunction_EDIT
@@ -486,8 +666,15 @@ FromOrComma
  ;
 
 SumFunction
- : 'SUM' '(' OptionalAllOrDistinct ValueExpression ')'  -> { function: $1, types: ['UDFREF'] }
- | 'SUM' '(' ')'                                        -> { function: $1, types: ['UDFREF'] }
+ : 'SUM' '(' OptionalAllOrDistinct ValueExpression ')'
+   {
+     parser.addFunctionArgumentLocations($1, $4.expressions);
+     $$ = { function: $1, types: ['UDFREF'] };
+   }
+ | 'SUM' '(' ')'
+   {
+     $$ = { function: $1, types: ['UDFREF'] }
+   }
  ;
 
 SumFunction_EDIT
@@ -513,7 +700,7 @@ SumFunction_EDIT
    }
  | 'SUM' '(' OptionalAllOrDistinct ValueExpression_EDIT RightParenthesisOrError
    {
-     if (parser.yy.result.suggestFunctions && ! parser.yy.result.suggestFunctions.types) {
+     if (parser.yy.result.suggestFunctions && !parser.yy.result.suggestFunctions.types) {
        parser.applyArgumentTypesToSuggestions($1, 1);
      }
      $$ = { function: $1, types: ['UDFREF'] };

+ 8 - 2
desktop/core/src/desktop/js/parse/jison/sql/presto/structure.json

@@ -15,7 +15,10 @@
     "sql_msck.jison",
     "../hive/sql_set.jison",
     "../hive/show/sql_show.jison",
-    "../hive/sql_udf.jison",
+    "../generic/sql_udf.jison",
+    "../hive/udf/sql_aggregate.jison",
+    "../hive/udf/sql_arbitrary.jison",
+    "../hive/udf/sql_extract.jison",
     "../hive/sql_update.jison",
     "../generic/sql_use.jison",
     "../generic/sql_valueExpression.jison",
@@ -35,7 +38,10 @@
     "sql_msck.jison",
     "../hive/sql_set.jison",
     "../hive/show/sql_show.jison",
-    "../hive/sql_udf.jison",
+    "../generic/sql_udf.jison",
+    "../hive/udf/sql_aggregate.jison",
+    "../hive/udf/sql_arbitrary.jison",
+    "../hive/udf/sql_extract.jison",
     "../hive/sql_update.jison",
     "../generic/sql_use.jison",
     "../generic/sql_valueExpression.jison",

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/calcite/calciteAutocompleteParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/calcite/calciteSyntaxParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/druid/druidAutocompleteParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/druid/druidSyntaxParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/elasticsearch/elasticsearchAutocompleteParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/elasticsearch/elasticsearchSyntaxParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/flink/flinkAutocompleteParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/flink/flinkSyntaxParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/generic/genericAutocompleteParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/generic/genericSyntaxParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js


+ 40 - 0
desktop/core/src/desktop/js/parse/sql/hive/test/hiveAutocompleteParser.Locations.test.js

@@ -63,6 +63,14 @@ describe('hiveAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 8, last_column: 10 },
           function: 'cos'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 12, last_column: 13 },
+          function: 'cos',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'cos' }],
+          expression: { types: ['NUMBER'], text: '1' }
+        },
         {
           type: 'alias',
           source: 'column',
@@ -1093,6 +1101,14 @@ describe('hiveAutocompleteParser.js locations', () => {
             location: { first_line: 1, last_line: 1, first_column: 13, last_column: 15 },
             function: 'cos'
           },
+          {
+            type: 'functionArgument',
+            location: { first_line: 1, last_line: 1, first_column: 17, last_column: 22 },
+            function: 'cos',
+            argumentPosition: 0,
+            identifierChain: [{ name: 'cos' }],
+            expression: { types: ['COLREF'], columnReference: [{ name: 'boo' }, { name: 'a' }] }
+          },
           {
             type: 'table',
             location: { first_line: 1, last_line: 1, first_column: 17, last_column: 20 },
@@ -1335,6 +1351,14 @@ describe('hiveAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 8, last_column: 12 },
           function: 'count'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 14, last_column: 15 },
+          function: 'count',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'count' }],
+          expression: { text: '*' }
+        },
         {
           type: 'table',
           location: { first_line: 1, last_line: 1, first_column: 22, last_column: 31 },
@@ -2261,6 +2285,14 @@ describe('hiveAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 22, last_column: 24 },
           function: 'cos'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 26, last_column: 27 },
+          function: 'cos',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'cos' }],
+          expression: { types: ['NUMBER'], text: '1' }
+        },
         {
           type: 'table',
           location: { first_line: 1, last_line: 1, first_column: 30, last_column: 33 },
@@ -2283,6 +2315,14 @@ describe('hiveAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 56, last_column: 58 },
           function: 'cos'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 60, last_column: 61 },
+          function: 'cos',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'cos' }],
+          expression: { types: ['NUMBER'], text: '1' }
+        },
         {
           type: 'table',
           location: { first_line: 1, last_line: 1, first_column: 68, last_column: 78 },

+ 54 - 0
desktop/core/src/desktop/js/parse/sql/hive/test/hiveAutocompleteParser.Select.test.js

@@ -359,6 +359,14 @@ describe('hiveAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 1, last_line: 1, first_column: 8, last_column: 12 },
               function: 'count'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 1, last_line: 1, first_column: 14, last_column: 15 },
+              function: 'count',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'count' }],
+              expression: { text: '*' }
+            },
             {
               type: 'table',
               location: { first_line: 1, last_line: 1, first_column: 18, last_column: 21 },
@@ -376,6 +384,14 @@ describe('hiveAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 1, last_line: 1, first_column: 29, last_column: 32 },
               function: 'avg'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 1, last_line: 1, first_column: 34, last_column: 36 },
+              function: 'avg',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'avg' }],
+              expression: { types: ['COLREF'], columnReference: [{ name: 'id' }] }
+            },
             {
               type: 'column',
               location: { first_line: 1, last_line: 1, first_column: 34, last_column: 36 },
@@ -2277,6 +2293,14 @@ describe('hiveAutocompleteParser.js SELECT statements', () => {
               identifierChain: [{ name: 'db' }, { name: 'customUdf' }],
               function: 'customudf'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 1, last_line: 1, first_column: 21, last_column: 24 },
+              function: 'customudf',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'db' }, { name: 'customUdf' }],
+              expression: { types: ['COLREF'], columnReference: [{ name: 'col' }] }
+            },
             {
               type: 'column',
               location: { first_line: 1, last_line: 1, first_column: 21, last_column: 24 },
@@ -3538,6 +3562,14 @@ describe('hiveAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 1, last_line: 1, first_column: 37, last_column: 43 },
               function: 'explode'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 1, last_line: 1, first_column: 45, last_column: 54 },
+              function: 'explode',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'explode' }],
+              expression: { types: ['COLREF'], columnReference: [{ name: 'testArray' }] }
+            },
             {
               type: 'column',
               location: { first_line: 1, last_line: 1, first_column: 45, last_column: 54 },
@@ -3807,6 +3839,17 @@ describe('hiveAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 6, last_line: 6, first_column: 16, last_column: 22 },
               function: 'explode'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 6, last_line: 6, first_column: 24, last_column: 38 },
+              function: 'explode',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'EXPLODE' }],
+              expression: {
+                types: ['COLREF'],
+                columnReference: [{ name: 'tt2' }, { name: 'testArrayA' }]
+              }
+            },
             {
               type: 'table',
               location: { first_line: 6, last_line: 6, first_column: 24, last_column: 27 },
@@ -3824,6 +3867,17 @@ describe('hiveAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 7, last_line: 7, first_column: 16, last_column: 22 },
               function: 'explode'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 7, last_line: 7, first_column: 24, last_column: 38 },
+              function: 'explode',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'EXPLODE' }],
+              expression: {
+                types: ['COLREF'],
+                columnReference: [{ name: 'tt2' }, { name: 'testArrayB' }]
+              }
+            },
             {
               type: 'table',
               location: { first_line: 7, last_line: 7, first_column: 24, last_column: 27 },

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/impala/impalaAutocompleteParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/impala/impalaSyntaxParser.js


+ 48 - 0
desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Locations.test.js

@@ -410,6 +410,14 @@ describe('impalaAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 8, last_column: 10 },
           function: 'cos'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 12, last_column: 13 },
+          function: 'cos',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'cos' }],
+          expression: { types: ['NUMBER'], text: '1' }
+        },
         {
           type: 'alias',
           source: 'column',
@@ -1641,6 +1649,14 @@ describe('impalaAutocompleteParser.js locations', () => {
             location: { first_line: 1, last_line: 1, first_column: 13, last_column: 15 },
             function: 'cos'
           },
+          {
+            type: 'functionArgument',
+            location: { first_line: 1, last_line: 1, first_column: 17, last_column: 22 },
+            function: 'cos',
+            argumentPosition: 0,
+            identifierChain: [{ name: 'cos' }],
+            expression: { types: ['COLREF'], columnReference: [{ name: 'boo' }, { name: 'a' }] }
+          },
           {
             type: 'table',
             location: { first_line: 1, last_line: 1, first_column: 17, last_column: 20 },
@@ -1898,6 +1914,14 @@ describe('impalaAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 8, last_column: 12 },
           function: 'count'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 14, last_column: 15 },
+          function: 'count',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'count' }],
+          expression: { text: '*' }
+        },
         {
           type: 'table',
           location: { first_line: 1, last_line: 1, first_column: 22, last_column: 31 },
@@ -2079,6 +2103,14 @@ describe('impalaAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 16, last_column: 20 },
           function: 'round'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 22, last_column: 27 },
+          function: 'round',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'ROUND' }],
+          expression: { types: ['COLREF'], columnReference: [{ name: 'tmp' }, { name: 'r' }] }
+        },
         {
           type: 'subQuery',
           location: { first_line: 1, last_line: 1, first_column: 22, last_column: 25 },
@@ -2091,6 +2123,14 @@ describe('impalaAutocompleteParser.js locations', () => {
           tables: [{ subQuery: 'tmp' }],
           qualified: true
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 29, last_column: 30 },
+          function: 'round',
+          argumentPosition: 1,
+          identifierChain: [{ name: 'ROUND' }],
+          expression: { types: ['NUMBER'], text: '2' }
+        },
         {
           type: 'alias',
           source: 'column',
@@ -2223,6 +2263,14 @@ describe('impalaAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 178, last_column: 181 },
           function: 'year'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 183, last_column: 194 },
+          function: 'year',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'YEAR' }],
+          expression: { types: ['COLREF'], columnReference: [{ name: 'tran' }, { name: 'tran_d' }] }
+        },
         {
           type: 'table',
           location: { first_line: 1, last_line: 1, first_column: 183, last_column: 187 },

+ 24 - 0
desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Select.test.js

@@ -418,6 +418,14 @@ describe('impalaAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 1, last_line: 1, first_column: 8, last_column: 12 },
               function: 'count'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 1, last_line: 1, first_column: 14, last_column: 15 },
+              function: 'count',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'count' }],
+              expression: { text: '*' }
+            },
             {
               type: 'table',
               location: { first_line: 1, last_line: 1, first_column: 18, last_column: 21 },
@@ -435,6 +443,14 @@ describe('impalaAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 1, last_line: 1, first_column: 29, last_column: 32 },
               function: 'avg'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 1, last_line: 1, first_column: 34, last_column: 36 },
+              function: 'avg',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'avg' }],
+              expression: { types: ['COLREF'], columnReference: [{ name: 'id' }] }
+            },
             {
               type: 'column',
               location: { first_line: 1, last_line: 1, first_column: 34, last_column: 36 },
@@ -2252,6 +2268,14 @@ describe('impalaAutocompleteParser.js SELECT statements', () => {
               identifierChain: [{ name: 'db' }, { name: 'customUdf' }],
               function: 'customudf'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 1, last_line: 1, first_column: 21, last_column: 24 },
+              function: 'customudf',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'db' }, { name: 'customUdf' }],
+              expression: { types: ['COLREF'], columnReference: [{ name: 'col' }] }
+            },
             {
               type: 'column',
               location: { first_line: 1, last_line: 1, first_column: 21, last_column: 24 },

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/ksql/ksqlAutocompleteParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/ksql/ksqlSyntaxParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/phoenix/phoenixAutocompleteParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/phoenix/phoenixSyntaxParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/prestoAutocompleteParser.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/prestoSyntaxParser.js


+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/spec/prestoAutocompleteParser_Analyze_Spec.js → desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Analyze.test.js


+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/spec/prestoAutocompleteParser_Describe_Spec.js → desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Describe.test.js


+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/spec/prestoAutocompleteParser_Grant_Spec.js → desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Grant.test.js


+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/spec/prestoAutocompleteParser_Import_Export_Spec.js → desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.ImportExport.test.js


+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/spec/prestoAutocompleteParser_Load_Spec.js → desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Load.test.js


+ 40 - 0
desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Locations.test.js

@@ -63,6 +63,14 @@ describe('prestoAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 8, last_column: 10 },
           function: 'cos'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 12, last_column: 13 },
+          function: 'cos',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'cos' }],
+          expression: { types: ['NUMBER'], text: '1' }
+        },
         {
           type: 'alias',
           source: 'column',
@@ -1093,6 +1101,14 @@ describe('prestoAutocompleteParser.js locations', () => {
             location: { first_line: 1, last_line: 1, first_column: 13, last_column: 15 },
             function: 'cos'
           },
+          {
+            type: 'functionArgument',
+            location: { first_line: 1, last_line: 1, first_column: 17, last_column: 22 },
+            function: 'cos',
+            argumentPosition: 0,
+            identifierChain: [{ name: 'cos' }],
+            expression: { types: ['COLREF'], columnReference: [{ name: 'boo' }, { name: 'a' }] }
+          },
           {
             type: 'table',
             location: { first_line: 1, last_line: 1, first_column: 17, last_column: 20 },
@@ -1335,6 +1351,14 @@ describe('prestoAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 8, last_column: 12 },
           function: 'count'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 14, last_column: 15 },
+          function: 'count',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'count' }],
+          expression: { text: '*' }
+        },
         {
           type: 'table',
           location: { first_line: 1, last_line: 1, first_column: 22, last_column: 31 },
@@ -2261,6 +2285,14 @@ describe('prestoAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 22, last_column: 24 },
           function: 'cos'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 26, last_column: 27 },
+          function: 'cos',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'cos' }],
+          expression: { types: ['NUMBER'], text: '1' }
+        },
         {
           type: 'table',
           location: { first_line: 1, last_line: 1, first_column: 30, last_column: 33 },
@@ -2283,6 +2315,14 @@ describe('prestoAutocompleteParser.js locations', () => {
           location: { first_line: 1, last_line: 1, first_column: 56, last_column: 58 },
           function: 'cos'
         },
+        {
+          type: 'functionArgument',
+          location: { first_line: 1, last_line: 1, first_column: 60, last_column: 61 },
+          function: 'cos',
+          argumentPosition: 0,
+          identifierChain: [{ name: 'cos' }],
+          expression: { types: ['NUMBER'], text: '1' }
+        },
         {
           type: 'table',
           location: { first_line: 1, last_line: 1, first_column: 68, last_column: 78 },

+ 54 - 0
desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Select.test.js

@@ -359,6 +359,14 @@ describe('prestoAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 1, last_line: 1, first_column: 8, last_column: 12 },
               function: 'count'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 1, last_line: 1, first_column: 14, last_column: 15 },
+              function: 'count',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'count' }],
+              expression: { text: '*' }
+            },
             {
               type: 'table',
               location: { first_line: 1, last_line: 1, first_column: 18, last_column: 21 },
@@ -376,6 +384,14 @@ describe('prestoAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 1, last_line: 1, first_column: 29, last_column: 32 },
               function: 'avg'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 1, last_line: 1, first_column: 34, last_column: 36 },
+              function: 'avg',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'avg' }],
+              expression: { types: ['COLREF'], columnReference: [{ name: 'id' }] }
+            },
             {
               type: 'column',
               location: { first_line: 1, last_line: 1, first_column: 34, last_column: 36 },
@@ -2277,6 +2293,14 @@ describe('prestoAutocompleteParser.js SELECT statements', () => {
               identifierChain: [{ name: 'db' }, { name: 'customUdf' }],
               function: 'customudf'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 1, last_line: 1, first_column: 21, last_column: 24 },
+              function: 'customudf',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'db' }, { name: 'customUdf' }],
+              expression: { types: ['COLREF'], columnReference: [{ name: 'col' }] }
+            },
             {
               type: 'column',
               location: { first_line: 1, last_line: 1, first_column: 21, last_column: 24 },
@@ -3538,6 +3562,14 @@ describe('prestoAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 1, last_line: 1, first_column: 37, last_column: 43 },
               function: 'explode'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 1, last_line: 1, first_column: 45, last_column: 54 },
+              function: 'explode',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'explode' }],
+              expression: { types: ['COLREF'], columnReference: [{ name: 'testArray' }] }
+            },
             {
               type: 'column',
               location: { first_line: 1, last_line: 1, first_column: 45, last_column: 54 },
@@ -3801,6 +3833,17 @@ describe('prestoAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 6, last_line: 6, first_column: 16, last_column: 22 },
               function: 'explode'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 6, last_line: 6, first_column: 24, last_column: 38 },
+              function: 'explode',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'EXPLODE' }],
+              expression: {
+                types: ['COLREF'],
+                columnReference: [{ name: 'tt2' }, { name: 'testArrayA' }]
+              }
+            },
             {
               type: 'table',
               location: { first_line: 6, last_line: 6, first_column: 24, last_column: 27 },
@@ -3818,6 +3861,17 @@ describe('prestoAutocompleteParser.js SELECT statements', () => {
               location: { first_line: 7, last_line: 7, first_column: 16, last_column: 22 },
               function: 'explode'
             },
+            {
+              type: 'functionArgument',
+              location: { first_line: 7, last_line: 7, first_column: 24, last_column: 38 },
+              function: 'explode',
+              argumentPosition: 0,
+              identifierChain: [{ name: 'EXPLODE' }],
+              expression: {
+                types: ['COLREF'],
+                columnReference: [{ name: 'tt2' }, { name: 'testArrayB' }]
+              }
+            },
             {
               type: 'table',
               location: { first_line: 7, last_line: 7, first_column: 24, last_column: 27 },

+ 0 - 0
desktop/core/src/desktop/js/parse/sql/presto/spec/prestoAutocompleteParser_Show_Spec.js → desktop/core/src/desktop/js/parse/sql/presto/test/prestoAutocompleteParser.Show.test.js


Некоторые файлы не были показаны из-за большого количества измененных файлов