Bläddra i källkod

HUE-4489 [editor] The new autocompleter should allow white space between UDF name and parenthesis

Johan Ahlen 9 år sedan
förälder
incheckning
411b335

+ 127 - 124
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql.jison

@@ -141,10 +141,10 @@ NonStartingToken
  : '<hive>ALL' | '<hive>ARRAY' | '<hive>AVRO' | '<hive>BINARY' | '<hive>BUCKETS' | '<hive>AS' | '<hive>CLUSTERED' | '<hive>COLLECTION' | '<hive>CONF' | '<hive>CROSS' | '<hive>CURRENT' | '<hive>DATE' | '<hive>DELIMITED' | '<hive>ESCAPED' | '<hive>EXTENDED' | '<hive>EXTERNAL' | '<hive>FIELDS' | '<hive>FORMAT' | '<hive>FUNCTION' | '<hive>GRANT' | '<hive>LATERAL' | '<hive>MACRO' | '<hive>TABLE' | '<hive>USER' | '<hive>ASC' | '<hive>COLUMNS' | '<hive>COMMENT' | '<hive>COMPACTIONS' | '<hive>DATA' | '<hive>DATABASES' | '<hive>DEFINED' | '<hive>DESC' | '<hive>STORED_AS_DIRECTORIES' | '<hive>FORMATTED' | '<hive>FUNCTIONS' | '<hive>INDEX' | '<hive>INDEXES' | '<hive>INPATH' | '<hive>INPUTFORMAT' | '<hive>ITEMS' | '<hive>LIMIT' | '<hive>KEYS' | '<hive>LINES' | '<hive>LOCATION' | '<hive>LOCKS' | '<hive>MAP' | '<hive>ORC' | '<hive>OUTPUTFORMAT' | '<hive>PARQUET' | '<hive>PARTITIONED' | '<hive>PARTITIONS' | '<hive>RCFILE' | '<hive>ROLE' | '<hive>ROLES' | '<hive>SCHEMA' | '<hive>SCHEMAS' | '<hive>SEQUENCEFILE' | '<hive>SERDE' | '<hive>SERDEPROPERTIES' | '<hive>SKEWED' | '<hive>SORTED' | '<hive>STORED' | '<hive>STRING' | '<hive>STRUCT' | '<hive>TABLES' | '<hive>TBLPROPERTIES' | '<hive>TEMPORARY' | '<hive>TERMINATED' | '<hive>TEXTFILE' | '<hive>TINYINT' | '<hive>TRANSACTIONS' | '<hive>UNIONTYPE' | '<hive>VIEW' | '<hive>WINDOW' | '<hive>.' | '<hive>[' | '<hive>]'
  | '<impala>AGGREGATE' | '<impala>AVRO' | '<impala>CACHED' | '<impala>COLUMN' | '<impala>COMMENT' | '<impala>DATA' | '<impala>DATABASES' | '<impala>DELIMITED' | '<impala>ESCAPED' | '<impala>EXTERNAL' | '<impala>FIELDS' | '<impala>FIRST' | '<impala>FORMAT' | '<impala>FORMATTED' | '<impala>FUNCTION' | '<impala>FUNCTIONS' | '<impala>GROUP' | '<impala>INCREMENTAL' | '<impala>INPATH' | '<impala>LAST' | '<impala>LINES' | '<impala>LOCATION' | '<impala>NULLS' | '<impala>PARTITIONS' | '<impala>REAL' | '<impala>SCHEMAS' | '<impala>STATS' | '<impala>TABLE' | '<impala>TABLES' | '<impala>USING' | '<impala>ANALYTIC' | '<impala>ANTI' | '<impala>CURRENT' | '<impala>GRANT' | '<impala>PARQUET' | '<impala>PARTITIONED' | '<impala>RCFILE' | '<impala>ROLE' | '<impala>ROLES' | '<impala>SEQUENCEFILE' | '<impala>SERDEPROPERTIES' | '<impala>SHUFFLE' | '<impala>STORED' | '<impala>TBLPROPERTIES' | '<impala>TERMINATED' | '<impala>TEXTFILE' | '<impala>BROADCAST' | '<impala>.' | '<impala>[' | '<impala>]'
  | 'ALL' | 'AS' | 'ASC' | 'BETWEEN' | 'BIGINT' | 'BOOLEAN' | 'BY' | 'CASE' | 'CHAR' | 'CURRENT' | 'DATABASE' | 'DECIMAL' | 'DISTINCT' | 'DOUBLE' | 'DESC' | 'ELSE' | 'END' | 'EXISTS' | 'FALSE' | 'FLOAT' | 'FOLLOWING' | 'FROM' | 'FULL' | 'GROUP' | 'GROUPING' | 'IF' | 'IN' | 'INNER' | 'INT' | 'INTO' | 'IS' | 'JOIN' | 'LEFT' | 'LIKE' | 'LIMIT' | 'NOT' | 'NULL' | 'ON' | 'ORDER' | 'OUTER' | 'OVER' | 'PARTITION' | 'PRECEDING' | 'RANGE' | 'REGEXP' | 'RIGHT' | 'RLIKE' | 'ROW' | 'ROWS' | 'SCHEMA' | 'SEMI' | 'SET' | 'SMALLINT' | 'STRING' | 'TABLE' | 'THEN' | 'TIMESTAMP' | 'TINYINT' | 'TRUE' | 'VARCHAR' | 'WHEN' | 'WHERE' | 'WITH' | 'ROLE'
- | 'AVG(' | 'CAST(' | 'COUNT(' | 'MAX(' | 'MIN(' | 'STDDEV_POP(' | 'STDDEV_SAMP(' | 'SUM(' | 'VARIANCE(' | 'VAR_POP(' | 'VAR_SAMP('
- | '<hive>COLLECT_SET(' | '<hive>COLLECT_LIST(' | '<hive>CORR(' | '<hive>COVAR_POP(' | '<hive>COVAR_SAMP(' | '<hive>HISTOGRAM_NUMERIC(' | '<hive>NTILE(' | '<hive>PERCENTILE(' | '<hive>PERCENTILE_APPROX('
- | '<impala>APPX_MEDIAN(' | '<impala>EXTRACT(' | '<impala>GROUP_CONCAT(' | '<impala>STDDEV(' | '<impala>VARIANCE_POP(' | '<impala>VARIANCE_SAMP('
- | 'ANALYTIC(', 'UDF('
+ | 'AVG' | 'CAST' | 'COUNT' | 'MAX' | 'MIN' | 'STDDEV_POP' | 'STDDEV_SAMP' | 'SUM' | 'VARIANCE' | 'VAR_POP' | 'VAR_SAMP'
+ | '<hive>COLLECT_SET' | '<hive>COLLECT_LIST' | '<hive>CORR' | '<hive>COVAR_POP' | '<hive>COVAR_SAMP' | '<hive>HISTOGRAM_NUMERIC' | '<hive>NTILE' | '<hive>PERCENTILE' | '<hive>PERCENTILE_APPROX'
+ | '<impala>APPX_MEDIAN' | '<impala>EXTRACT' | '<impala>GROUP_CONCAT' | '<impala>STDDEV' | '<impala>VARIANCE_POP' | '<impala>VARIANCE_SAMP'
+ | 'ANALYTIC'
  | 'UNSIGNED_INTEGER' | 'UNSIGNED_INTEGER_E' | 'REGULAR_IDENTIFIER' | 'HDFS_START_QUOTE' | 'AND' | 'OR' | '=' | '<' | '>' | 'COMPARISON_OPERATOR' | '-' | '*' | 'ARITHMETIC_OPERATOR' | ',' | '.' | '~' | '!' | '(' | ')' | '[' | ']' | 'VARIABLE_REFERENCE' | 'BACKTICK' | 'SINGLE_QUOTE' | 'DOUBLE_QUOTE'
  ;
 
@@ -2057,25 +2057,36 @@ UserDefinedFunction_EDIT
  ;
 
 ArbitraryFunction
- : 'UDF(' ')'                      -> { types: findReturnTypes($1) }
- | 'UDF(' ValueExpressionList ')'  -> { function: $1.substring(0, $1.length - 1), expression: $2, types: findReturnTypes($1) }
+ : 'REGULAR_IDENTIFIER' '(' ')'
+   {
+     addFunctionLocation(@1, $1);
+     $$ = { types: findReturnTypes($1) }
+   }
+ | 'REGULAR_IDENTIFIER' '(' ValueExpressionList ')'
+   {
+     addFunctionLocation(@1, $1);
+     $$ = { function: $1, expression: $3, types: findReturnTypes($1) }
+   }
  ;
 
 ArbitraryFunction_EDIT
- : 'UDF(' AnyCursor RightParenthesisOrError
+ : 'REGULAR_IDENTIFIER' '(' AnyCursor RightParenthesisOrError
    {
+     addFunctionLocation(@1, $1);
      valueExpressionSuggest();
      applyArgumentTypesToSuggestions($1, 1);
      $$ = { types: findReturnTypes($1) };
    }
- | 'UDF(' ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | 'REGULAR_IDENTIFIER' '(' ValueExpressionList 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($2);
+     addFunctionLocation(@1, $1);
+     suggestValueExpressionKeywords($3);
      $$ = { types: findReturnTypes($1) };
    }
- | 'UDF(' ValueExpressionList_EDIT RightParenthesisOrError
+ | 'REGULAR_IDENTIFIER' '(' ValueExpressionList_EDIT RightParenthesisOrError
    {
-     applyArgumentTypesToSuggestions($1, $2.position);
+     addFunctionLocation(@1, $1);
+     applyArgumentTypesToSuggestions($1, $3.position);
      $$ = { types: findReturnTypes($1) };
    }
  ;
@@ -2093,25 +2104,25 @@ AggregateFunction_EDIT
  ;
 
 AnalyticFunction
- : 'ANALYTIC(' ')'                      -> { types: findReturnTypes($1) }
- | 'ANALYTIC(' ValueExpressionList ')'  -> { function: $1.substring(0, $1.length - 1), expression: $2, types: findReturnTypes($1) }
+ : 'ANALYTIC' '(' ')'                      -> { types: findReturnTypes($1) }
+ | 'ANALYTIC' '(' ValueExpressionList ')'  -> { function: $1, expression: $2, types: findReturnTypes($1) }
  ;
 
 AnalyticFunction_EDIT
- : 'ANALYTIC(' AnyCursor RightParenthesisOrError
+ : 'ANALYTIC' '(' AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
      applyArgumentTypesToSuggestions($1, 1);
      $$ = { types: findReturnTypes($1) };
    }
- | 'ANALYTIC(' ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | 'ANALYTIC' '(' ValueExpressionList 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($2);
+     suggestValueExpressionKeywords($3);
      $$ = { types: findReturnTypes($1) };
    }
- | 'ANALYTIC(' ValueExpressionList_EDIT RightParenthesisOrError
+ | 'ANALYTIC' '(' ValueExpressionList_EDIT RightParenthesisOrError
    {
-     applyArgumentTypesToSuggestions($1, $2.position);
+     applyArgumentTypesToSuggestions($1, $3.position);
      $$ = { types: findReturnTypes($1) };
    }
  ;
@@ -2286,45 +2297,45 @@ OptionalWindowClause_EDIT
  ;
 
 CastFunction
- : 'CAST(' ValueExpression AnyAs PrimitiveType ')'  -> { types: [ $4.toUpperCase() ] }
- | 'CAST(' ')'                                      -> { types: [ 'T' ] }
+ : 'CAST' '(' ValueExpression AnyAs PrimitiveType ')'  -> { types: [ $5.toUpperCase() ] }
+ | 'CAST' '(' ')'                                      -> { types: [ 'T' ] }
  ;
 
 CastFunction_EDIT
- : 'CAST(' AnyCursor AnyAs PrimitiveType RightParenthesisOrError
+ : 'CAST' '(' AnyCursor AnyAs PrimitiveType RightParenthesisOrError
    {
      valueExpressionSuggest();
-     $$ = { types: [ $4.toUpperCase() ] };
+     $$ = { types: [ $5.toUpperCase() ] };
    }
- | 'CAST(' AnyCursor AnyAs RightParenthesisOrError
+ | 'CAST' '(' AnyCursor AnyAs RightParenthesisOrError
    {
      valueExpressionSuggest();
      $$ = { types: [ 'T' ] };
    }
- | 'CAST(' AnyCursor RightParenthesisOrError
+ | 'CAST' '(' AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
      $$ = { types: [ 'T' ] };
    }
- | 'CAST(' ValueExpression_EDIT AnyAs PrimitiveType RightParenthesisOrError  -> { types: [ $4.toUpperCase() ] }
- | 'CAST(' ValueExpression_EDIT AnyAs RightParenthesisOrError                -> { types: [ 'T' ] }
- | 'CAST(' ValueExpression_EDIT RightParenthesisOrError                      -> { types: [ 'T' ] }
- | 'CAST(' ValueExpression 'CURSOR' PrimitiveType RightParenthesisOrError
+ | 'CAST' '(' ValueExpression_EDIT AnyAs PrimitiveType RightParenthesisOrError  -> { types: [ $5.toUpperCase() ] }
+ | 'CAST' '(' ValueExpression_EDIT AnyAs RightParenthesisOrError                -> { types: [ 'T' ] }
+ | 'CAST' '(' ValueExpression_EDIT RightParenthesisOrError                      -> { types: [ 'T' ] }
+ | 'CAST' '(' ValueExpression 'CURSOR' PrimitiveType RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($2, ['AS']);
-     $$ =  { types: [ $4.toUpperCase() ] };
+     suggestValueExpressionKeywords($3, ['AS']);
+     $$ =  { types: [ $5.toUpperCase() ] };
    }
- | 'CAST(' ValueExpression 'CURSOR' RightParenthesisOrError
+ | 'CAST' '(' ValueExpression 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($2, ['AS']);
+     suggestValueExpressionKeywords($3, ['AS']);
      $$ = { types: [ 'T' ] };
    }
- | 'CAST(' ValueExpression AnyAs 'CURSOR' RightParenthesisOrError
+ | 'CAST' '(' ValueExpression AnyAs 'CURSOR' RightParenthesisOrError
    {
      suggestKeywords(getTypeKeywords());
      $$ = { types: [ 'T' ] };
    }
- | 'CAST(' AnyAs 'CURSOR' RightParenthesisOrError
+ | 'CAST' '(' AnyAs 'CURSOR' RightParenthesisOrError
    {
      suggestKeywords(getTypeKeywords());
      $$ = { types: [ 'T' ] };
@@ -2332,16 +2343,16 @@ CastFunction_EDIT
  ;
 
 CountFunction
- : 'COUNT(' '*' ')'                                        -> { types: findReturnTypes($1) }
- | 'COUNT(' ')'                                            -> { types: findReturnTypes($1) }
- | 'COUNT(' OptionalAllOrDistinct ValueExpressionList ')'  -> { types: findReturnTypes($1) }
+ : 'COUNT' '(' '*' ')'                                        -> { types: findReturnTypes($1) }
+ | 'COUNT' '(' ')'                                            -> { types: findReturnTypes($1) }
+ | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList ')'  -> { types: findReturnTypes($1) }
  ;
 
 CountFunction_EDIT
- : 'COUNT(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
+ : 'COUNT' '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
    {
      suggestColumns();
-     if (!$2) {
+     if (!$3) {
        if (isImpala()) {
          suggestKeywords(['*', 'ALL', 'DISTINCT']);
        } else {
@@ -2350,14 +2361,14 @@ CountFunction_EDIT
      }
      $$ = { types: findReturnTypes($1) };
    }
- | 'COUNT(' OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($3);
+     suggestValueExpressionKeywords($4);
      $$ = { types: findReturnTypes($1) };
    }
- | 'COUNT(' OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
+ | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
    {
-     if ($3.cursorAtStart && !$2) {
+     if ($4.cursorAtStart && !$3) {
        if (isImpala()) {
          suggestKeywords(['ALL', 'DISTINCT']);
        } else {
@@ -2369,17 +2380,17 @@ CountFunction_EDIT
  ;
 
 OtherAggregateFunction
- : OtherAggregateFunction_Type OptionalAllOrDistinct ')'                      -> { types: findReturnTypes($1) }
- | OtherAggregateFunction_Type OptionalAllOrDistinct ValueExpressionList ')'  -> { types: findReturnTypes($1) }
+ : OtherAggregateFunction_Type '(' OptionalAllOrDistinct ')'                      -> { types: findReturnTypes($1) }
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList ')'  -> { types: findReturnTypes($1) }
  ;
 
 OtherAggregateFunction_EDIT
- : OtherAggregateFunction_Type OptionalAllOrDistinct AnyCursor RightParenthesisOrError
+ : OtherAggregateFunction_Type '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
    {
      suggestFunctions();
      suggestColumns();
-     if (!$2) {
-       if ($1.toLowerCase() === 'group_concat(') {
+     if (!$3) {
+       if ($1.toLowerCase() === 'group_concat') {
          suggestKeywords(['ALL' ]);
        } else if (isImpala()) {
          suggestKeywords(['ALL', 'DISTINCT']);
@@ -2390,15 +2401,15 @@ OtherAggregateFunction_EDIT
      applyArgumentTypesToSuggestions($1, 1);
      $$ = { types: findReturnTypes($1) };
    }
- | OtherAggregateFunction_Type OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($3);
+     suggestValueExpressionKeywords($4);
      $$ = { types: findReturnTypes($1) };
    }
- | OtherAggregateFunction_Type OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
    {
-     if ($3.cursorAtStart && !$2) {
-       if ($1.toLowerCase() === 'group_concat(') {
+     if ($4.cursorAtStart && !$3) {
+       if ($1.toLowerCase() === 'group_concat') {
          suggestKeywords(['ALL' ]);
        } else if (isImpala()) {
          suggestKeywords(['ALL', 'DISTINCT']);
@@ -2407,113 +2418,113 @@ OtherAggregateFunction_EDIT
        }
      }
      if (parser.yy.result.suggestFunctions && !parser.yy.result.suggestFunctions.types) {
-       applyArgumentTypesToSuggestions($1, $3.position);
+       applyArgumentTypesToSuggestions($1, $4.position);
      }
      $$ = { types: findReturnTypes($1) };
    }
  ;
 
 OtherAggregateFunction_Type
- : '<impala>APPX_MEDIAN('
- | 'AVG('
- | '<hive>COLLECT_SET('
- | '<hive>COLLECT_LIST('
- | '<hive>CORR('
- | '<hive>COVAR_POP('
- | '<hive>COVAR_SAMP('
- | '<impala>GROUP_CONCAT('
- | '<hive>HISTOGRAM_NUMERIC'
- | '<impala>STDDEV('
- | 'STDDEV_POP('
- | 'STDDEV_SAMP('
- | 'MAX('
- | 'MIN('
- | '<hive>NTILE('
- | '<hive>PERCENTILE('
- | '<hive>PERCENTILE_APPROX('
- | 'VARIANCE('
- | '<impala>VARIANCE_POP('
- | '<impala>VARIANCE_SAMP('
- | 'VAR_POP('
- | 'VAR_SAMP('
+ : '<impala>APPX_MEDIAN'
+ | 'AVG'
+ | '<hive>COLLECT_SET'
+ | '<hive>COLLECT_LIST'
+ | '<hive>CORR'
+ | '<hive>COVAR_POP'
+ | '<hive>COVAR_SAMP'
+ | '<impala>GROUP_CONCAT'
+ | '<hive>HISTOGRAM_NUMERI'
+ | '<impala>STDDEV'
+ | 'STDDEV_POP'
+ | 'STDDEV_SAMP'
+ | 'MAX'
+ | 'MIN'
+ | '<hive>NTILE'
+ | '<hive>PERCENTILE'
+ | '<hive>PERCENTILE_APPROX'
+ | 'VARIANCE'
+ | '<impala>VARIANCE_POP'
+ | '<impala>VARIANCE_SAMP'
+ | 'VAR_POP'
+ | 'VAR_SAMP'
  ;
 
 ExtractFunction
- : '<impala>EXTRACT(' ValueExpression FromOrComma ValueExpression ')'
- | '<impala>EXTRACT(' ')'
+ : '<impala>EXTRACT' '(' ValueExpression FromOrComma ValueExpression ')'
+ | '<impala>EXTRACT' '(' ')'
  ;
 
 ExtractFunction_EDIT
- : '<impala>EXTRACT(' AnyCursor FromOrComma ValueExpression RightParenthesisOrError
+ : '<impala>EXTRACT' '(' AnyCursor FromOrComma ValueExpression RightParenthesisOrError
    {
      valueExpressionSuggest();
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' AnyCursor FromOrComma RightParenthesisOrError
+ | '<impala>EXTRACT' '(' AnyCursor FromOrComma RightParenthesisOrError
    {
      valueExpressionSuggest();
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' AnyCursor RightParenthesisOrError
+ | '<impala>EXTRACT' '(' AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
      applyTypeToSuggestions(['STRING', 'TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression_EDIT FromOrComma ValueExpression RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression_EDIT FromOrComma ValueExpression RightParenthesisOrError
    {
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression_EDIT FromOrComma RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression_EDIT FromOrComma RightParenthesisOrError
    {
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression_EDIT RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression_EDIT RightParenthesisOrError
    {
      applyTypeToSuggestions(['STRING', 'TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression FromOrComma AnyCursor RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression FromOrComma AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' FromOrComma AnyCursor RightParenthesisOrError
+ | '<impala>EXTRACT' '(' FromOrComma AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression FromOrComma ValueExpression_EDIT RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression FromOrComma ValueExpression_EDIT RightParenthesisOrError
    {
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' FromOrComma ValueExpression_EDIT RightParenthesisOrError
+ | '<impala>EXTRACT' '(' FromOrComma ValueExpression_EDIT RightParenthesisOrError
    {
-    applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
+    applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression 'CURSOR' ValueExpression RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression 'CURSOR' ValueExpression RightParenthesisOrError
    {
-     if ($1.types[0] === 'STRING') {
-       suggestValueExpressionKeywords($2, ['FROM']);
+     if ($3.types[0] === 'STRING') {
+       suggestValueExpressionKeywords($3, ['FROM']);
      } else {
-       suggestValueExpressionKeywords($2);
+       suggestValueExpressionKeywords($3);
      }
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression 'CURSOR' RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression 'CURSOR' RightParenthesisOrError
    {
-     if ($1.types[0] === 'STRING') {
-       suggestValueExpressionKeywords($2, ['FROM']);
+     if ($3.types[0] === 'STRING') {
+       suggestValueExpressionKeywords($3, ['FROM']);
      } else {
-       suggestValueExpressionKeywords($2);
+       suggestValueExpressionKeywords($3);
      }
      $$ = { types: findReturnTypes($1) };
    }
@@ -2525,16 +2536,16 @@ FromOrComma
  ;
 
 SumFunction
- : 'SUM(' OptionalAllOrDistinct ValueExpression ')'  -> { types: findReturnTypes($1) }
- | 'SUM(' ')'                                        -> { types: findReturnTypes($1) }
+ : 'SUM' '(' OptionalAllOrDistinct ValueExpression ')'  -> { types: findReturnTypes($1) }
+ | 'SUM' '(' ')'                                        -> { types: findReturnTypes($1) }
  ;
 
 SumFunction_EDIT
- : 'SUM(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
+ : 'SUM' '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
      applyArgumentTypesToSuggestions($1, 1);
-     if (!$2) {
+     if (!$3) {
        if (isImpala()) {
          suggestKeywords(['ALL', 'DISTINCT']);
        } else {
@@ -2543,12 +2554,12 @@ SumFunction_EDIT
      }
      $$ = { types: findReturnTypes($1) };
    }
- | 'SUM(' OptionalAllOrDistinct ValueExpression 'CURSOR' RightParenthesisOrError
+ | 'SUM' '(' OptionalAllOrDistinct ValueExpression 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($3);
+     suggestValueExpressionKeywords($4);
      $$ = { types: findReturnTypes($1) };
    }
- | 'SUM(' OptionalAllOrDistinct ValueExpression_EDIT RightParenthesisOrError
+ | 'SUM' '(' OptionalAllOrDistinct ValueExpression_EDIT RightParenthesisOrError
    {
      if (parser.yy.result.suggestFunctions && ! parser.yy.result.suggestFunctions.types) {
        applyArgumentTypesToSuggestions($1, 1);
@@ -2567,7 +2578,7 @@ LateralView_INVALID
  : '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction RegularIdentifier error                     -> []
  | '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction error                                       -> []
  | '<hive>LATERAL' '<hive>VIEW' error                                                           -> []
- | '<hive>LATERAL' error                                                                  -> []
+ | '<hive>LATERAL' error                                                                        -> []
  ;
 
 LateralView_EDIT
@@ -3660,18 +3671,12 @@ TableDefinitionRightPart_EDIT
    }
  ;
 
-// Hack as no space is required between table name and '(' which would be read as UDF(
-// can be dropped if switched to LR(*)
 TableIdentifierAndOptionalColumnSpecification
  : SchemaQualifiedTableIdentifier OptionalColumnSpecificationsOrLike  -> $2
- | 'UDF(' DropLastLocation ColumnSpecificationList ')'
- | RegularOrBacktickedIdentifier AnyDot 'UDF(' DropLastLocation ColumnSpecificationList ')'
  ;
 
 TableIdentifierAndOptionalColumnSpecification_EDIT
  : SchemaQualifiedTableIdentifier OptionalColumnSpecificationsOrLike_EDIT
- | 'UDF(' DropLastLocation ColumnSpecificationList_EDIT RightParenthesisOrError
- | RegularOrBacktickedIdentifier AnyDot 'UDF(' DropLastLocation ColumnSpecificationList_EDIT RightParenthesisOrError
  ;
 
 DropLastLocation
@@ -5303,14 +5308,12 @@ var findCaseType = function (whenThenList) {
   return {types: ['T']};
 };
 
-findReturnTypes = function (funcToken) {
-  var funcName = funcToken.substring(0, funcToken.length - 1).toLowerCase();
-  return parser.yy.sqlFunctions.getReturnTypes(parser.yy.activeDialect, funcName);
+findReturnTypes = function (functionName) {
+  return parser.yy.sqlFunctions.getReturnTypes(parser.yy.activeDialect, functionName.toLowerCase());
 };
 
-var applyArgumentTypesToSuggestions = function (funcToken, position) {
-  var funcName = funcToken.substring(0, funcToken.length - 1).toLowerCase();
-  var foundArguments = parser.yy.sqlFunctions.getArgumentTypes(parser.yy.activeDialect, funcName, position);
+var applyArgumentTypesToSuggestions = function (functionName, position) {
+  var foundArguments = parser.yy.sqlFunctions.getArgumentTypes(parser.yy.activeDialect, functionName.toLowerCase(), position);
   if (foundArguments.length == 0 && parser.yy.result.suggestColumns) {
     delete parser.yy.result.suggestColumns;
     delete parser.yy.result.suggestKeyValues;

+ 36 - 36
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql.jisonlex

@@ -252,45 +252,45 @@
 'ROLE'                                     { return 'ROLE'; }
 
 // --- UDFs ---
-'AVG('                                     { addFunctionLocation(yylloc, 'avg'); return 'AVG('; }
-'CAST('                                    { addFunctionLocation(yylloc, 'cast'); return 'CAST('; }
-'COUNT('                                   { addFunctionLocation(yylloc, 'count'); return 'COUNT('; }
-'MAX('                                     { addFunctionLocation(yylloc, 'max'); return 'MAX('; }
-'MIN('                                     { addFunctionLocation(yylloc, 'min'); return 'MIN('; }
-'STDDEV_POP('                              { addFunctionLocation(yylloc, 'stddev_pop'); return 'STDDEV_POP('; }
-'STDDEV_SAMP('                             { addFunctionLocation(yylloc, 'stddev_samp'); return 'STDDEV_SAMP('; }
-'SUM('                                     { addFunctionLocation(yylloc, 'sum'); return 'SUM('; }
-'VARIANCE('                                { addFunctionLocation(yylloc, 'variance'); return 'VARIANCE('; }
-'VAR_POP('                                 { addFunctionLocation(yylloc, 'var_pop'); return 'VAR_POP('; }
-'VAR_SAMP('                                { addFunctionLocation(yylloc, 'var_samp'); return 'VAR_SAMP('; }
-<hive>'COLLECT_SET('                       { addFunctionLocation(yylloc, 'collect_set'); return '<hive>COLLECT_SET('; }
-<hive>'COLLECT_LIST('                      { addFunctionLocation(yylloc, 'collect_list'); return '<hive>COLLECT_LIST('; }
-<hive>'CORR('                              { addFunctionLocation(yylloc, 'corr'); return '<hive>CORR('; }
-<hive>'COVAR_POP('                         { addFunctionLocation(yylloc, 'covar_pop'); return '<hive>COVAR_POP('; }
-<hive>'COVAR_SAMP('                        { addFunctionLocation(yylloc, 'covar_samp'); return '<hive>COVAR_SAMP('; }
-<hive>'HISTOGRAM_NUMERIC('                 { addFunctionLocation(yylloc, 'histogram_numeric'); return '<hive>HISTOGRAM_NUMERIC('; }
-<hive>'NTILE('                             { addFunctionLocation(yylloc, 'ntile'); return '<hive>NTILE('; }
-<hive>'PERCENTILE('                        { addFunctionLocation(yylloc, 'percentile'); return '<hive>PERCENTILE('; }
-<hive>'PERCENTILE_APPROX('                 { addFunctionLocation(yylloc, 'percentile_approx'); return '<hive>PERCENTILE_APPROX('; }
-<impala>'APPX_MEDIAN('                     { addFunctionLocation(yylloc, 'appx_median'); return '<impala>APPX_MEDIAN('; }
-<impala>'EXTRACT('                         { addFunctionLocation(yylloc, 'extract'); return '<impala>EXTRACT('; }
-<impala>'GROUP_CONCAT('                    { addFunctionLocation(yylloc, 'group_concat'); return '<impala>GROUP_CONCAT('; }
-<impala>'STDDEV('                          { addFunctionLocation(yylloc, 'stddev'); return '<impala>STDDEV('; }
-<impala>'VARIANCE_POP('                    { addFunctionLocation(yylloc, 'variance_pop'); return '<impala>VARIANCE_POP('; }
-<impala>'VARIANCE_SAMP('                   { addFunctionLocation(yylloc, 'variance_samp'); return '<impala>VARIANCE_SAMP('; }
+'AVG'                                     { addFunctionLocation(yylloc, 'avg'); return 'AVG'; }
+'CAST'                                    { addFunctionLocation(yylloc, 'cast'); return 'CAST'; }
+'COUNT'                                   { addFunctionLocation(yylloc, 'count'); return 'COUNT'; }
+'MAX'                                     { addFunctionLocation(yylloc, 'max'); return 'MAX'; }
+'MIN'                                     { addFunctionLocation(yylloc, 'min'); return 'MIN'; }
+'STDDEV_POP'                              { addFunctionLocation(yylloc, 'stddev_pop'); return 'STDDEV_POP'; }
+'STDDEV_SAMP'                             { addFunctionLocation(yylloc, 'stddev_samp'); return 'STDDEV_SAMP'; }
+'SUM'                                     { addFunctionLocation(yylloc, 'sum'); return 'SUM'; }
+'VARIANCE'                                { addFunctionLocation(yylloc, 'variance'); return 'VARIANCE'; }
+'VAR_POP'                                 { addFunctionLocation(yylloc, 'var_pop'); return 'VAR_POP'; }
+'VAR_SAMP'                                { addFunctionLocation(yylloc, 'var_samp'); return 'VAR_SAMP'; }
+<hive>'COLLECT_SET'                       { addFunctionLocation(yylloc, 'collect_set'); return '<hive>COLLECT_SET'; }
+<hive>'COLLECT_LIST'                      { addFunctionLocation(yylloc, 'collect_list'); return '<hive>COLLECT_LIST'; }
+<hive>'CORR'                              { addFunctionLocation(yylloc, 'corr'); return '<hive>CORR'; }
+<hive>'COVAR_POP'                         { addFunctionLocation(yylloc, 'covar_pop'); return '<hive>COVAR_POP'; }
+<hive>'COVAR_SAMP'                        { addFunctionLocation(yylloc, 'covar_samp'); return '<hive>COVAR_SAMP'; }
+<hive>'HISTOGRAM_NUMERIC'                 { addFunctionLocation(yylloc, 'histogram_numeric'); return '<hive>HISTOGRAM_NUMERIC'; }
+<hive>'NTILE'                             { addFunctionLocation(yylloc, 'ntile'); return '<hive>NTILE'; }
+<hive>'PERCENTILE'                        { addFunctionLocation(yylloc, 'percentile'); return '<hive>PERCENTILE'; }
+<hive>'PERCENTILE_APPROX'                 { addFunctionLocation(yylloc, 'percentile_approx'); return '<hive>PERCENTILE_APPROX'; }
+<impala>'APPX_MEDIAN'                     { addFunctionLocation(yylloc, 'appx_median'); return '<impala>APPX_MEDIAN'; }
+<impala>'EXTRACT'                         { addFunctionLocation(yylloc, 'extract'); return '<impala>EXTRACT'; }
+<impala>'GROUP_CONCAT'                    { addFunctionLocation(yylloc, 'group_concat'); return '<impala>GROUP_CONCAT'; }
+<impala>'STDDEV'                          { addFunctionLocation(yylloc, 'stddev'); return '<impala>STDDEV'; }
+<impala>'VARIANCE_POP'                    { addFunctionLocation(yylloc, 'variance_pop'); return '<impala>VARIANCE_POP'; }
+<impala>'VARIANCE_SAMP'                   { addFunctionLocation(yylloc, 'variance_samp'); return '<impala>VARIANCE_SAMP'; }
 
 // Analytical functions
-'DENSE_RANK('                              { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC('; }
-'FIRST_VALUE('                             { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC('; }
-'LAG('                                     { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC('; }
-'LAST_VALUE('                              { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC('; }
-'LEAD('                                    { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC('; }
-'RANK('                                    { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC('; }
-'ROW_NUMBER('                              { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC('; }
-<hive>'CUME_DIST('                         { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC('; }
-<hive>'PERCENT_RANK('                      { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC('; }
+'DENSE_RANK'                              { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC'; }
+'FIRST_VALUE'                             { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC'; }
+'LAG'                                     { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC'; }
+'LAST_VALUE'                              { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC'; }
+'LEAD'                                    { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC'; }
+'RANK'                                    { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC'; }
+'ROW_NUMBER'                              { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC'; }
+<hive>'CUME_DIST'                         { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC'; }
+<hive>'PERCENT_RANK'                      { addFunctionLocation(yylloc, 'variance_samp'); return 'ANALYTIC'; }
 
-[A-Za-z][A-Za-z0-9_]*\(                    { addFunctionLocation(yylloc, yytext.substring(0, yytext.length - 1)); return 'UDF('; }
+// [A-Za-z][A-Za-z0-9_]*\(                    { addFunctionLocation(yylloc, yytext.substring(0, yytext.length - 1)); return 'UDF('; }
 
 [0-9]+                                     { return 'UNSIGNED_INTEGER'; }
 [0-9]+E                                    { return 'UNSIGNED_INTEGER_E'; }

+ 0 - 6
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_create.jison

@@ -280,18 +280,12 @@ TableDefinitionRightPart_EDIT
    }
  ;
 
-// Hack as no space is required between table name and '(' which would be read as UDF(
-// can be dropped if switched to LR(*)
 TableIdentifierAndOptionalColumnSpecification
  : SchemaQualifiedTableIdentifier OptionalColumnSpecificationsOrLike  -> $2
- | 'UDF(' DropLastLocation ColumnSpecificationList ')'
- | RegularOrBacktickedIdentifier AnyDot 'UDF(' DropLastLocation ColumnSpecificationList ')'
  ;
 
 TableIdentifierAndOptionalColumnSpecification_EDIT
  : SchemaQualifiedTableIdentifier OptionalColumnSpecificationsOrLike_EDIT
- | 'UDF(' DropLastLocation ColumnSpecificationList_EDIT RightParenthesisOrError
- | RegularOrBacktickedIdentifier AnyDot 'UDF(' DropLastLocation ColumnSpecificationList_EDIT RightParenthesisOrError
  ;
 
 DropLastLocation

+ 123 - 112
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison

@@ -141,10 +141,10 @@ NonStartingToken
  : '<hive>ALL' | '<hive>ARRAY' | '<hive>AVRO' | '<hive>BINARY' | '<hive>BUCKETS' | '<hive>AS' | '<hive>CLUSTERED' | '<hive>COLLECTION' | '<hive>CONF' | '<hive>CROSS' | '<hive>CURRENT' | '<hive>DATE' | '<hive>DELIMITED' | '<hive>ESCAPED' | '<hive>EXTENDED' | '<hive>EXTERNAL' | '<hive>FIELDS' | '<hive>FORMAT' | '<hive>FUNCTION' | '<hive>GRANT' | '<hive>LATERAL' | '<hive>MACRO' | '<hive>TABLE' | '<hive>USER' | '<hive>ASC' | '<hive>COLUMNS' | '<hive>COMMENT' | '<hive>COMPACTIONS' | '<hive>DATA' | '<hive>DATABASES' | '<hive>DEFINED' | '<hive>DESC' | '<hive>STORED_AS_DIRECTORIES' | '<hive>FORMATTED' | '<hive>FUNCTIONS' | '<hive>INDEX' | '<hive>INDEXES' | '<hive>INPATH' | '<hive>INPUTFORMAT' | '<hive>ITEMS' | '<hive>LIMIT' | '<hive>KEYS' | '<hive>LINES' | '<hive>LOCATION' | '<hive>LOCKS' | '<hive>MAP' | '<hive>ORC' | '<hive>OUTPUTFORMAT' | '<hive>PARQUET' | '<hive>PARTITIONED' | '<hive>PARTITIONS' | '<hive>RCFILE' | '<hive>ROLE' | '<hive>ROLES' | '<hive>SCHEMA' | '<hive>SCHEMAS' | '<hive>SEQUENCEFILE' | '<hive>SERDE' | '<hive>SERDEPROPERTIES' | '<hive>SKEWED' | '<hive>SORTED' | '<hive>STORED' | '<hive>STRING' | '<hive>STRUCT' | '<hive>TABLES' | '<hive>TBLPROPERTIES' | '<hive>TEMPORARY' | '<hive>TERMINATED' | '<hive>TEXTFILE' | '<hive>TINYINT' | '<hive>TRANSACTIONS' | '<hive>UNIONTYPE' | '<hive>VIEW' | '<hive>WINDOW' | '<hive>.' | '<hive>[' | '<hive>]'
  | '<impala>AGGREGATE' | '<impala>AVRO' | '<impala>CACHED' | '<impala>COLUMN' | '<impala>COMMENT' | '<impala>DATA' | '<impala>DATABASES' | '<impala>DELIMITED' | '<impala>ESCAPED' | '<impala>EXTERNAL' | '<impala>FIELDS' | '<impala>FIRST' | '<impala>FORMAT' | '<impala>FORMATTED' | '<impala>FUNCTION' | '<impala>FUNCTIONS' | '<impala>GROUP' | '<impala>INCREMENTAL' | '<impala>INPATH' | '<impala>LAST' | '<impala>LINES' | '<impala>LOCATION' | '<impala>NULLS' | '<impala>PARTITIONS' | '<impala>REAL' | '<impala>SCHEMAS' | '<impala>STATS' | '<impala>TABLE' | '<impala>TABLES' | '<impala>USING' | '<impala>ANALYTIC' | '<impala>ANTI' | '<impala>CURRENT' | '<impala>GRANT' | '<impala>PARQUET' | '<impala>PARTITIONED' | '<impala>RCFILE' | '<impala>ROLE' | '<impala>ROLES' | '<impala>SEQUENCEFILE' | '<impala>SERDEPROPERTIES' | '<impala>SHUFFLE' | '<impala>STORED' | '<impala>TBLPROPERTIES' | '<impala>TERMINATED' | '<impala>TEXTFILE' | '<impala>BROADCAST' | '<impala>.' | '<impala>[' | '<impala>]'
  | 'ALL' | 'AS' | 'ASC' | 'BETWEEN' | 'BIGINT' | 'BOOLEAN' | 'BY' | 'CASE' | 'CHAR' | 'CURRENT' | 'DATABASE' | 'DECIMAL' | 'DISTINCT' | 'DOUBLE' | 'DESC' | 'ELSE' | 'END' | 'EXISTS' | 'FALSE' | 'FLOAT' | 'FOLLOWING' | 'FROM' | 'FULL' | 'GROUP' | 'GROUPING' | 'IF' | 'IN' | 'INNER' | 'INT' | 'INTO' | 'IS' | 'JOIN' | 'LEFT' | 'LIKE' | 'LIMIT' | 'NOT' | 'NULL' | 'ON' | 'ORDER' | 'OUTER' | 'OVER' | 'PARTITION' | 'PRECEDING' | 'RANGE' | 'REGEXP' | 'RIGHT' | 'RLIKE' | 'ROW' | 'ROWS' | 'SCHEMA' | 'SEMI' | 'SET' | 'SMALLINT' | 'STRING' | 'TABLE' | 'THEN' | 'TIMESTAMP' | 'TINYINT' | 'TRUE' | 'VARCHAR' | 'WHEN' | 'WHERE' | 'WITH' | 'ROLE'
- | 'AVG(' | 'CAST(' | 'COUNT(' | 'MAX(' | 'MIN(' | 'STDDEV_POP(' | 'STDDEV_SAMP(' | 'SUM(' | 'VARIANCE(' | 'VAR_POP(' | 'VAR_SAMP('
- | '<hive>COLLECT_SET(' | '<hive>COLLECT_LIST(' | '<hive>CORR(' | '<hive>COVAR_POP(' | '<hive>COVAR_SAMP(' | '<hive>HISTOGRAM_NUMERIC(' | '<hive>NTILE(' | '<hive>PERCENTILE(' | '<hive>PERCENTILE_APPROX('
- | '<impala>APPX_MEDIAN(' | '<impala>EXTRACT(' | '<impala>GROUP_CONCAT(' | '<impala>STDDEV(' | '<impala>VARIANCE_POP(' | '<impala>VARIANCE_SAMP('
- | 'ANALYTIC(', 'UDF('
+ | 'AVG' | 'CAST' | 'COUNT' | 'MAX' | 'MIN' | 'STDDEV_POP' | 'STDDEV_SAMP' | 'SUM' | 'VARIANCE' | 'VAR_POP' | 'VAR_SAMP'
+ | '<hive>COLLECT_SET' | '<hive>COLLECT_LIST' | '<hive>CORR' | '<hive>COVAR_POP' | '<hive>COVAR_SAMP' | '<hive>HISTOGRAM_NUMERIC' | '<hive>NTILE' | '<hive>PERCENTILE' | '<hive>PERCENTILE_APPROX'
+ | '<impala>APPX_MEDIAN' | '<impala>EXTRACT' | '<impala>GROUP_CONCAT' | '<impala>STDDEV' | '<impala>VARIANCE_POP' | '<impala>VARIANCE_SAMP'
+ | 'ANALYTIC'
  | 'UNSIGNED_INTEGER' | 'UNSIGNED_INTEGER_E' | 'REGULAR_IDENTIFIER' | 'HDFS_START_QUOTE' | 'AND' | 'OR' | '=' | '<' | '>' | 'COMPARISON_OPERATOR' | '-' | '*' | 'ARITHMETIC_OPERATOR' | ',' | '.' | '~' | '!' | '(' | ')' | '[' | ']' | 'VARIABLE_REFERENCE' | 'BACKTICK' | 'SINGLE_QUOTE' | 'DOUBLE_QUOTE'
  ;
 
@@ -2057,25 +2057,36 @@ UserDefinedFunction_EDIT
  ;
 
 ArbitraryFunction
- : 'UDF(' ')'                      -> { types: findReturnTypes($1) }
- | 'UDF(' ValueExpressionList ')'  -> { function: $1.substring(0, $1.length - 1), expression: $2, types: findReturnTypes($1) }
+ : 'REGULAR_IDENTIFIER' '(' ')'
+   {
+     addFunctionLocation(@1, $1);
+     $$ = { types: findReturnTypes($1) }
+   }
+ | 'REGULAR_IDENTIFIER' '(' ValueExpressionList ')'
+   {
+     addFunctionLocation(@1, $1);
+     $$ = { function: $1, expression: $3, types: findReturnTypes($1) }
+   }
  ;
 
 ArbitraryFunction_EDIT
- : 'UDF(' AnyCursor RightParenthesisOrError
+ : 'REGULAR_IDENTIFIER' '(' AnyCursor RightParenthesisOrError
    {
+     addFunctionLocation(@1, $1);
      valueExpressionSuggest();
      applyArgumentTypesToSuggestions($1, 1);
      $$ = { types: findReturnTypes($1) };
    }
- | 'UDF(' ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | 'REGULAR_IDENTIFIER' '(' ValueExpressionList 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($2);
+     addFunctionLocation(@1, $1);
+     suggestValueExpressionKeywords($3);
      $$ = { types: findReturnTypes($1) };
    }
- | 'UDF(' ValueExpressionList_EDIT RightParenthesisOrError
+ | 'REGULAR_IDENTIFIER' '(' ValueExpressionList_EDIT RightParenthesisOrError
    {
-     applyArgumentTypesToSuggestions($1, $2.position);
+     addFunctionLocation(@1, $1);
+     applyArgumentTypesToSuggestions($1, $3.position);
      $$ = { types: findReturnTypes($1) };
    }
  ;
@@ -2093,25 +2104,25 @@ AggregateFunction_EDIT
  ;
 
 AnalyticFunction
- : 'ANALYTIC(' ')'                      -> { types: findReturnTypes($1) }
- | 'ANALYTIC(' ValueExpressionList ')'  -> { function: $1.substring(0, $1.length - 1), expression: $2, types: findReturnTypes($1) }
+ : 'ANALYTIC' '(' ')'                      -> { types: findReturnTypes($1) }
+ | 'ANALYTIC' '(' ValueExpressionList ')'  -> { function: $1, expression: $2, types: findReturnTypes($1) }
  ;
 
 AnalyticFunction_EDIT
- : 'ANALYTIC(' AnyCursor RightParenthesisOrError
+ : 'ANALYTIC' '(' AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
      applyArgumentTypesToSuggestions($1, 1);
      $$ = { types: findReturnTypes($1) };
    }
- | 'ANALYTIC(' ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | 'ANALYTIC' '(' ValueExpressionList 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($2);
+     suggestValueExpressionKeywords($3);
      $$ = { types: findReturnTypes($1) };
    }
- | 'ANALYTIC(' ValueExpressionList_EDIT RightParenthesisOrError
+ | 'ANALYTIC' '(' ValueExpressionList_EDIT RightParenthesisOrError
    {
-     applyArgumentTypesToSuggestions($1, $2.position);
+     applyArgumentTypesToSuggestions($1, $3.position);
      $$ = { types: findReturnTypes($1) };
    }
  ;
@@ -2286,45 +2297,45 @@ OptionalWindowClause_EDIT
  ;
 
 CastFunction
- : 'CAST(' ValueExpression AnyAs PrimitiveType ')'  -> { types: [ $4.toUpperCase() ] }
- | 'CAST(' ')'                                      -> { types: [ 'T' ] }
+ : 'CAST' '(' ValueExpression AnyAs PrimitiveType ')'  -> { types: [ $5.toUpperCase() ] }
+ | 'CAST' '(' ')'                                      -> { types: [ 'T' ] }
  ;
 
 CastFunction_EDIT
- : 'CAST(' AnyCursor AnyAs PrimitiveType RightParenthesisOrError
+ : 'CAST' '(' AnyCursor AnyAs PrimitiveType RightParenthesisOrError
    {
      valueExpressionSuggest();
-     $$ = { types: [ $4.toUpperCase() ] };
+     $$ = { types: [ $5.toUpperCase() ] };
    }
- | 'CAST(' AnyCursor AnyAs RightParenthesisOrError
+ | 'CAST' '(' AnyCursor AnyAs RightParenthesisOrError
    {
      valueExpressionSuggest();
      $$ = { types: [ 'T' ] };
    }
- | 'CAST(' AnyCursor RightParenthesisOrError
+ | 'CAST' '(' AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
      $$ = { types: [ 'T' ] };
    }
- | 'CAST(' ValueExpression_EDIT AnyAs PrimitiveType RightParenthesisOrError  -> { types: [ $4.toUpperCase() ] }
- | 'CAST(' ValueExpression_EDIT AnyAs RightParenthesisOrError                -> { types: [ 'T' ] }
- | 'CAST(' ValueExpression_EDIT RightParenthesisOrError                      -> { types: [ 'T' ] }
- | 'CAST(' ValueExpression 'CURSOR' PrimitiveType RightParenthesisOrError
+ | 'CAST' '(' ValueExpression_EDIT AnyAs PrimitiveType RightParenthesisOrError  -> { types: [ $5.toUpperCase() ] }
+ | 'CAST' '(' ValueExpression_EDIT AnyAs RightParenthesisOrError                -> { types: [ 'T' ] }
+ | 'CAST' '(' ValueExpression_EDIT RightParenthesisOrError                      -> { types: [ 'T' ] }
+ | 'CAST' '(' ValueExpression 'CURSOR' PrimitiveType RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($2, ['AS']);
-     $$ =  { types: [ $4.toUpperCase() ] };
+     suggestValueExpressionKeywords($3, ['AS']);
+     $$ =  { types: [ $5.toUpperCase() ] };
    }
- | 'CAST(' ValueExpression 'CURSOR' RightParenthesisOrError
+ | 'CAST' '(' ValueExpression 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($2, ['AS']);
+     suggestValueExpressionKeywords($3, ['AS']);
      $$ = { types: [ 'T' ] };
    }
- | 'CAST(' ValueExpression AnyAs 'CURSOR' RightParenthesisOrError
+ | 'CAST' '(' ValueExpression AnyAs 'CURSOR' RightParenthesisOrError
    {
      suggestKeywords(getTypeKeywords());
      $$ = { types: [ 'T' ] };
    }
- | 'CAST(' AnyAs 'CURSOR' RightParenthesisOrError
+ | 'CAST' '(' AnyAs 'CURSOR' RightParenthesisOrError
    {
      suggestKeywords(getTypeKeywords());
      $$ = { types: [ 'T' ] };
@@ -2332,16 +2343,16 @@ CastFunction_EDIT
  ;
 
 CountFunction
- : 'COUNT(' '*' ')'                                        -> { types: findReturnTypes($1) }
- | 'COUNT(' ')'                                            -> { types: findReturnTypes($1) }
- | 'COUNT(' OptionalAllOrDistinct ValueExpressionList ')'  -> { types: findReturnTypes($1) }
+ : 'COUNT' '(' '*' ')'                                        -> { types: findReturnTypes($1) }
+ | 'COUNT' '(' ')'                                            -> { types: findReturnTypes($1) }
+ | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList ')'  -> { types: findReturnTypes($1) }
  ;
 
 CountFunction_EDIT
- : 'COUNT(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
+ : 'COUNT' '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
    {
      suggestColumns();
-     if (!$2) {
+     if (!$3) {
        if (isImpala()) {
          suggestKeywords(['*', 'ALL', 'DISTINCT']);
        } else {
@@ -2350,14 +2361,14 @@ CountFunction_EDIT
      }
      $$ = { types: findReturnTypes($1) };
    }
- | 'COUNT(' OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($3);
+     suggestValueExpressionKeywords($4);
      $$ = { types: findReturnTypes($1) };
    }
- | 'COUNT(' OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
+ | 'COUNT' '(' OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
    {
-     if ($3.cursorAtStart && !$2) {
+     if ($4.cursorAtStart && !$3) {
        if (isImpala()) {
          suggestKeywords(['ALL', 'DISTINCT']);
        } else {
@@ -2369,17 +2380,17 @@ CountFunction_EDIT
  ;
 
 OtherAggregateFunction
- : OtherAggregateFunction_Type OptionalAllOrDistinct ')'                      -> { types: findReturnTypes($1) }
- | OtherAggregateFunction_Type OptionalAllOrDistinct ValueExpressionList ')'  -> { types: findReturnTypes($1) }
+ : OtherAggregateFunction_Type '(' OptionalAllOrDistinct ')'                      -> { types: findReturnTypes($1) }
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList ')'  -> { types: findReturnTypes($1) }
  ;
 
 OtherAggregateFunction_EDIT
- : OtherAggregateFunction_Type OptionalAllOrDistinct AnyCursor RightParenthesisOrError
+ : OtherAggregateFunction_Type '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
    {
      suggestFunctions();
      suggestColumns();
-     if (!$2) {
-       if ($1.toLowerCase() === 'group_concat(') {
+     if (!$3) {
+       if ($1.toLowerCase() === 'group_concat') {
          suggestKeywords(['ALL' ]);
        } else if (isImpala()) {
          suggestKeywords(['ALL', 'DISTINCT']);
@@ -2390,15 +2401,15 @@ OtherAggregateFunction_EDIT
      applyArgumentTypesToSuggestions($1, 1);
      $$ = { types: findReturnTypes($1) };
    }
- | OtherAggregateFunction_Type OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($3);
+     suggestValueExpressionKeywords($4);
      $$ = { types: findReturnTypes($1) };
    }
- | OtherAggregateFunction_Type OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
+ | OtherAggregateFunction_Type '(' OptionalAllOrDistinct ValueExpressionList_EDIT RightParenthesisOrError
    {
-     if ($3.cursorAtStart && !$2) {
-       if ($1.toLowerCase() === 'group_concat(') {
+     if ($4.cursorAtStart && !$3) {
+       if ($1.toLowerCase() === 'group_concat') {
          suggestKeywords(['ALL' ]);
        } else if (isImpala()) {
          suggestKeywords(['ALL', 'DISTINCT']);
@@ -2407,113 +2418,113 @@ OtherAggregateFunction_EDIT
        }
      }
      if (parser.yy.result.suggestFunctions && !parser.yy.result.suggestFunctions.types) {
-       applyArgumentTypesToSuggestions($1, $3.position);
+       applyArgumentTypesToSuggestions($1, $4.position);
      }
      $$ = { types: findReturnTypes($1) };
    }
  ;
 
 OtherAggregateFunction_Type
- : '<impala>APPX_MEDIAN('
- | 'AVG('
- | '<hive>COLLECT_SET('
- | '<hive>COLLECT_LIST('
- | '<hive>CORR('
- | '<hive>COVAR_POP('
- | '<hive>COVAR_SAMP('
- | '<impala>GROUP_CONCAT('
- | '<hive>HISTOGRAM_NUMERIC'
- | '<impala>STDDEV('
- | 'STDDEV_POP('
- | 'STDDEV_SAMP('
- | 'MAX('
- | 'MIN('
- | '<hive>NTILE('
- | '<hive>PERCENTILE('
- | '<hive>PERCENTILE_APPROX('
- | 'VARIANCE('
- | '<impala>VARIANCE_POP('
- | '<impala>VARIANCE_SAMP('
- | 'VAR_POP('
- | 'VAR_SAMP('
+ : '<impala>APPX_MEDIAN'
+ | 'AVG'
+ | '<hive>COLLECT_SET'
+ | '<hive>COLLECT_LIST'
+ | '<hive>CORR'
+ | '<hive>COVAR_POP'
+ | '<hive>COVAR_SAMP'
+ | '<impala>GROUP_CONCAT'
+ | '<hive>HISTOGRAM_NUMERI'
+ | '<impala>STDDEV'
+ | 'STDDEV_POP'
+ | 'STDDEV_SAMP'
+ | 'MAX'
+ | 'MIN'
+ | '<hive>NTILE'
+ | '<hive>PERCENTILE'
+ | '<hive>PERCENTILE_APPROX'
+ | 'VARIANCE'
+ | '<impala>VARIANCE_POP'
+ | '<impala>VARIANCE_SAMP'
+ | 'VAR_POP'
+ | 'VAR_SAMP'
  ;
 
 ExtractFunction
- : '<impala>EXTRACT(' ValueExpression FromOrComma ValueExpression ')'
- | '<impala>EXTRACT(' ')'
+ : '<impala>EXTRACT' '(' ValueExpression FromOrComma ValueExpression ')'
+ | '<impala>EXTRACT' '(' ')'
  ;
 
 ExtractFunction_EDIT
- : '<impala>EXTRACT(' AnyCursor FromOrComma ValueExpression RightParenthesisOrError
+ : '<impala>EXTRACT' '(' AnyCursor FromOrComma ValueExpression RightParenthesisOrError
    {
      valueExpressionSuggest();
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' AnyCursor FromOrComma RightParenthesisOrError
+ | '<impala>EXTRACT' '(' AnyCursor FromOrComma RightParenthesisOrError
    {
      valueExpressionSuggest();
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' AnyCursor RightParenthesisOrError
+ | '<impala>EXTRACT' '(' AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
      applyTypeToSuggestions(['STRING', 'TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression_EDIT FromOrComma ValueExpression RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression_EDIT FromOrComma ValueExpression RightParenthesisOrError
    {
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression_EDIT FromOrComma RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression_EDIT FromOrComma RightParenthesisOrError
    {
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['STRING'] : ['TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression_EDIT RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression_EDIT RightParenthesisOrError
    {
      applyTypeToSuggestions(['STRING', 'TIMESTAMP']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression FromOrComma AnyCursor RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression FromOrComma AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' FromOrComma AnyCursor RightParenthesisOrError
+ | '<impala>EXTRACT' '(' FromOrComma AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression FromOrComma ValueExpression_EDIT RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression FromOrComma ValueExpression_EDIT RightParenthesisOrError
    {
-     applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
+     applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' FromOrComma ValueExpression_EDIT RightParenthesisOrError
+ | '<impala>EXTRACT' '(' FromOrComma ValueExpression_EDIT RightParenthesisOrError
    {
-    applyTypeToSuggestions($3.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
+    applyTypeToSuggestions($4.toLowerCase() === 'from' ? ['TIMESTAMP'] : ['STRING']);
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression 'CURSOR' ValueExpression RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression 'CURSOR' ValueExpression RightParenthesisOrError
    {
-     if ($1.types[0] === 'STRING') {
-       suggestValueExpressionKeywords($2, ['FROM']);
+     if ($3.types[0] === 'STRING') {
+       suggestValueExpressionKeywords($3, ['FROM']);
      } else {
-       suggestValueExpressionKeywords($2);
+       suggestValueExpressionKeywords($3);
      }
      $$ = { types: findReturnTypes($1) };
    }
- | '<impala>EXTRACT(' ValueExpression 'CURSOR' RightParenthesisOrError
+ | '<impala>EXTRACT' '(' ValueExpression 'CURSOR' RightParenthesisOrError
    {
-     if ($1.types[0] === 'STRING') {
-       suggestValueExpressionKeywords($2, ['FROM']);
+     if ($3.types[0] === 'STRING') {
+       suggestValueExpressionKeywords($3, ['FROM']);
      } else {
-       suggestValueExpressionKeywords($2);
+       suggestValueExpressionKeywords($3);
      }
      $$ = { types: findReturnTypes($1) };
    }
@@ -2525,16 +2536,16 @@ FromOrComma
  ;
 
 SumFunction
- : 'SUM(' OptionalAllOrDistinct ValueExpression ')'  -> { types: findReturnTypes($1) }
- | 'SUM(' ')'                                        -> { types: findReturnTypes($1) }
+ : 'SUM' '(' OptionalAllOrDistinct ValueExpression ')'  -> { types: findReturnTypes($1) }
+ | 'SUM' '(' ')'                                        -> { types: findReturnTypes($1) }
  ;
 
 SumFunction_EDIT
- : 'SUM(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
+ : 'SUM' '(' OptionalAllOrDistinct AnyCursor RightParenthesisOrError
    {
      valueExpressionSuggest();
      applyArgumentTypesToSuggestions($1, 1);
-     if (!$2) {
+     if (!$3) {
        if (isImpala()) {
          suggestKeywords(['ALL', 'DISTINCT']);
        } else {
@@ -2543,12 +2554,12 @@ SumFunction_EDIT
      }
      $$ = { types: findReturnTypes($1) };
    }
- | 'SUM(' OptionalAllOrDistinct ValueExpression 'CURSOR' RightParenthesisOrError
+ | 'SUM' '(' OptionalAllOrDistinct ValueExpression 'CURSOR' RightParenthesisOrError
    {
-     suggestValueExpressionKeywords($3);
+     suggestValueExpressionKeywords($4);
      $$ = { types: findReturnTypes($1) };
    }
- | 'SUM(' OptionalAllOrDistinct ValueExpression_EDIT RightParenthesisOrError
+ | 'SUM' '(' OptionalAllOrDistinct ValueExpression_EDIT RightParenthesisOrError
    {
      if (parser.yy.result.suggestFunctions && ! parser.yy.result.suggestFunctions.types) {
        applyArgumentTypesToSuggestions($1, 1);
@@ -2567,7 +2578,7 @@ LateralView_INVALID
  : '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction RegularIdentifier error                     -> []
  | '<hive>LATERAL' '<hive>VIEW' UserDefinedFunction error                                       -> []
  | '<hive>LATERAL' '<hive>VIEW' error                                                           -> []
- | '<hive>LATERAL' error                                                                  -> []
+ | '<hive>LATERAL' error                                                                        -> []
  ;
 
 LateralView_EDIT

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js


+ 4 - 6
desktop/core/src/desktop/static/desktop/js/autocomplete/sql_support.js

@@ -179,14 +179,12 @@ var findCaseType = function (whenThenList) {
   return {types: ['T']};
 };
 
-findReturnTypes = function (funcToken) {
-  var funcName = funcToken.substring(0, funcToken.length - 1).toLowerCase();
-  return parser.yy.sqlFunctions.getReturnTypes(parser.yy.activeDialect, funcName);
+findReturnTypes = function (functionName) {
+  return parser.yy.sqlFunctions.getReturnTypes(parser.yy.activeDialect, functionName.toLowerCase());
 };
 
-var applyArgumentTypesToSuggestions = function (funcToken, position) {
-  var funcName = funcToken.substring(0, funcToken.length - 1).toLowerCase();
-  var foundArguments = parser.yy.sqlFunctions.getArgumentTypes(parser.yy.activeDialect, funcName, position);
+var applyArgumentTypesToSuggestions = function (functionName, position) {
+  var foundArguments = parser.yy.sqlFunctions.getArgumentTypes(parser.yy.activeDialect, functionName.toLowerCase(), position);
   if (foundArguments.length == 0 && parser.yy.result.suggestColumns) {
     delete parser.yy.result.suggestColumns;
     delete parser.yy.result.suggestKeyValues;

+ 10 - 10
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSelect.js

@@ -381,9 +381,9 @@ define([
             suggestKeywords: ['*'],
             locations: [
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 20}, identifierChain: [{ name: 'a'}], table: 'testTableB'},
-              { type: 'function', location: { first_line: 1, last_line: 1, first_column: 22, last_column: 25}, function: 'cos'},
+              { type: 'function', location: { first_line: 1, last_line: 1, first_column: 22, last_column: 24}, function: 'cos'},
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 47, last_column: 54}, identifierChain: [{ name: 'bla'}], table: 'testTableA'},
-              { type: 'function', location: { first_line: 1, last_line: 1, first_column: 56, last_column: 59}, function: 'cos'},
+              { type: 'function', location: { first_line: 1, last_line: 1, first_column: 56, last_column: 58}, function: 'cos'},
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 68, last_column: 78}, table: 'testTableA'},
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 84, last_column: 94}, table: 'testTableB'}
             ]
@@ -416,7 +416,7 @@ define([
           expectedResult: {
             lowerCase: false,
             locations: [
-              {type: 'function', location:{ first_line: 1, last_line: 1, first_column: 8, last_column: 13}, function: 'count'},
+              {type: 'function', location:{ first_line: 1, last_line: 1, first_column: 8, last_column: 12}, function: 'count'},
               {type: 'table', location: { first_line: 1, last_line: 1, first_column: 22, last_column: 31}, table: 'testTable'}
             ]
           }
@@ -432,16 +432,16 @@ define([
           expectedResult: {
             lowerCase: false,
             locations: [
-              { type: 'function', location: { first_line: 1, last_line: 1, first_column: 16, last_column: 21 }, function: 'round' },
+              { type: 'function', location: { first_line: 1, last_line: 1, first_column: 16, last_column: 20 }, function: 'round' },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 51, last_column: 64 }, identifierChain: [{ name: 'cat'}], database: 'tstDb1', table: 'b1' },
-              { type: 'function', location: { first_line: 1, last_line: 1, first_column: 72, last_column: 75 }, function: 'sum' },
+              { type: 'function', location: { first_line: 1, last_line: 1, first_column: 72, last_column: 74 }, function: 'sum' },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 76, last_column: 91 }, identifierChain: [{ name: 'price' }],database: 'tstDb1', table: 'b1' },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 94, last_column: 102 }, identifierChain: [{ name: 'qua' }], table: 'tran' },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 121, last_column: 123 }, database: 'tstDb1', table: 'b1' },
               { type: 'table', location: { first_line: 1, last_line: 1, first_column: 139, last_column: 143 }, table: 'tran' },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 149, last_column: 158 }, identifierChain: [{ name: 'b_id'}], table: 'tran' },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 161, last_column: 173 }, identifierChain: [{ name: 'id'}], database: 'tstDb1', table: 'b1' },
-              { type: 'function', location: { first_line: 1, last_line: 1, first_column: 178, last_column: 182 }, function: 'year' },
+              { type: 'function', location: { first_line: 1, last_line: 1, first_column: 178, last_column: 181 }, function: 'year' },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 183, last_column: 194 }, identifierChain: [{ name: 'tran_d' }], table: 'tran' },
               { type: 'column', location: { first_line: 1, last_line: 1, first_column: 234, last_column: 235 }, identifierChain: [{ name: 'cat' }], database: 'tstDb1', table: 'b1' }
             ]
@@ -558,7 +558,7 @@ define([
           expectedResult: {
             lowerCase: false,
             locations: [
-              {type: 'function', location: { first_line: 1, last_line: 1, first_column: 13, last_column: 16 }, function: 'cos'},
+              {type: 'function', location: { first_line: 1, last_line: 1, first_column: 13, last_column: 15 }, function: 'cos'},
               {type: 'column', location: { first_line: 1, last_line: 1, first_column: 17, last_column: 22 }, identifierChain: [{ name: 'a'}], database: 'db1', table: 'foo'},
               {type: 'column', location: { first_line: 1, last_line: 1, first_column: 26, last_column: 33 }, identifierChain: [{ name: 'boo'}], table: 'bar'},
               {type: 'column', location: { first_line: 2, last_line: 2, first_column: 7, last_column: 12 }, identifierChain: [{ name: 'b'}], table: 'bar'},
@@ -2843,7 +2843,7 @@ define([
               suggestIdentifiers: [{ name: 'explodedTable.', type: 'alias' }, { name: 'testItem', type: 'alias' }],
               locations: [
                 {type: 'table', location: { first_line: 1, last_line: 1, first_column: 14, last_column: 23 }, table: 'testTable' },
-                {type: 'function', location: { first_line: 1, last_line: 1, first_column: 37, last_column: 44 }, function: 'explode'},
+                {type: 'function', location: { first_line: 1, last_line: 1, first_column: 37, last_column: 43 }, function: 'explode'},
                 {type: 'column', location: { first_line: 1, last_line: 1, first_column: 45, last_column: 54 }, identifierChain: [{ name: 'testArray' }], table: 'testTable'}
               ]
             }
@@ -2993,9 +2993,9 @@ define([
               locations: [
                 { type: 'column', location: { first_line: 2, last_line: 2, first_column: 2, last_column: 11 }, identifierChain: [{ name: 'testArrayA'}, {name: 'item'}], table: 'testTable2'},
                 { type: 'table', location: { first_line: 5, last_line: 5, first_column: 3, last_column: 13 }, table: 'testTable2'},
-                { type: 'function', location: { first_line: 6, last_line: 6, first_column: 16, last_column: 23 }, function: 'explode'},
+                { type: 'function', location: { first_line: 6, last_line: 6, first_column: 16, last_column: 22 }, function: 'explode'},
                 { type: 'column', location: { first_line: 6, last_line: 6, first_column: 24, last_column: 38 }, identifierChain: [{ name: 'testArrayA'}], table: 'testTable2'},
-                { type: 'function', location: { first_line: 7, last_line: 7, first_column: 16, last_column: 23 }, function: 'explode'},
+                { type: 'function', location: { first_line: 7, last_line: 7, first_column: 16, last_column: 22 }, function: 'explode'},
                 { type: 'column', location: { first_line: 7, last_line: 7, first_column: 24, last_column: 38 }, identifierChain: [{ name: 'testArrayB'}] ,table: 'testTable2'}
               ]
             }

Vissa filer visades inte eftersom för många filer har ändrats