Bläddra i källkod

HUE-9429 [editor] Merge the generic2 parser back into generic

Johan Ahlen 5 år sedan
förälder
incheckning
bafbb8ea9e
36 ändrade filer med 132 tillägg och 4073 borttagningar
  1. 22 0
      desktop/core/src/desktop/js/parse/jison/sql/druid/structure.json
  2. 22 0
      desktop/core/src/desktop/js/parse/jison/sql/elasticsearch/structure.json
  3. 22 0
      desktop/core/src/desktop/js/parse/jison/sql/flink/structure.json
  4. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/cte_select_statement.jison
  5. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/from_clause.jison
  6. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/group_by_clause.jison
  7. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/having_clause.jison
  8. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/joins.jison
  9. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/limit_clause.jison
  10. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/order_by_clause.jison
  11. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/select_conditions.jison
  12. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/select_statement.jison
  13. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/union_clause.jison
  14. 0 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/select/where_clause.jison
  15. 0 1000
      desktop/core/src/desktop/js/parse/jison/sql/generic/sql_main.jison
  16. 22 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/structure.json
  17. 0 1369
      desktop/core/src/desktop/js/parse/jison/sql/generic2/sql_main.jison
  18. 0 54
      desktop/core/src/desktop/js/parse/jison/sql/generic2/structure.json
  19. 22 0
      desktop/core/src/desktop/js/parse/jison/sql/ksql/structure.json
  20. 22 0
      desktop/core/src/desktop/js/parse/jison/sql/phoenix/structure.json
  21. 0 0
      desktop/core/src/desktop/js/parse/sql/druid/druidAutocompleteParser.js
  22. 0 0
      desktop/core/src/desktop/js/parse/sql/druid/druidSyntaxParser.js
  23. 0 0
      desktop/core/src/desktop/js/parse/sql/elasticsearch/elasticsearchAutocompleteParser.js
  24. 0 0
      desktop/core/src/desktop/js/parse/sql/elasticsearch/elasticsearchSyntaxParser.js
  25. 0 0
      desktop/core/src/desktop/js/parse/sql/flink/flinkAutocompleteParser.js
  26. 0 0
      desktop/core/src/desktop/js/parse/sql/flink/flinkSyntaxParser.js
  27. 0 0
      desktop/core/src/desktop/js/parse/sql/generic/genericAutocompleteParser.js
  28. 0 0
      desktop/core/src/desktop/js/parse/sql/generic/genericSyntaxParser.js
  29. 0 91
      desktop/core/src/desktop/js/parse/sql/generic2/generic2AutocompleteParser.js
  30. 0 91
      desktop/core/src/desktop/js/parse/sql/generic2/generic2SyntaxParser.js
  31. 0 1466
      desktop/core/src/desktop/js/parse/sql/generic2/sqlParseSupport.js
  32. 0 0
      desktop/core/src/desktop/js/parse/sql/ksql/ksqlAutocompleteParser.js
  33. 0 0
      desktop/core/src/desktop/js/parse/sql/ksql/ksqlSyntaxParser.js
  34. 0 0
      desktop/core/src/desktop/js/parse/sql/phoenix/phoenixAutocompleteParser.js
  35. 0 0
      desktop/core/src/desktop/js/parse/sql/phoenix/phoenixSyntaxParser.js
  36. 0 2
      desktop/core/src/desktop/js/parse/sql/sqlParserRepository.js

+ 22 - 0
desktop/core/src/desktop/js/parse/jison/sql/druid/structure.json

@@ -8,6 +8,17 @@
     "../generic/sql_error.jison",
     "../generic/sql_insert.jison",
     "../generic/sql_main.jison",
+    "../generic/select/cte_select_statement.jison",
+    "../generic/select/from_clause.jison",
+    "../generic/select/group_by_clause.jison",
+    "../generic/select/having_clause.jison",
+    "../generic/select/joins.jison",
+    "../generic/select/limit_clause.jison",
+    "../generic/select/order_by_clause.jison",
+    "../generic/select/select_conditions.jison",
+    "../generic/select/select_statement.jison",
+    "../generic/select/union_clause.jison",
+    "../generic/select/where_clause.jison",
     "../generic/sql_set.jison",
     "../generic/sql_udf.jison",
     "../generic/sql_update.jison",
@@ -22,6 +33,17 @@
     "../generic/sql_drop.jison",
     "../generic/sql_insert.jison",
     "../generic/sql_main.jison",
+    "../generic/select/cte_select_statement.jison",
+    "../generic/select/from_clause.jison",
+    "../generic/select/group_by_clause.jison",
+    "../generic/select/having_clause.jison",
+    "../generic/select/joins.jison",
+    "../generic/select/limit_clause.jison",
+    "../generic/select/order_by_clause.jison",
+    "../generic/select/select_conditions.jison",
+    "../generic/select/select_statement.jison",
+    "../generic/select/union_clause.jison",
+    "../generic/select/where_clause.jison",
     "../generic/sql_set.jison",
     "../generic/sql_udf.jison",
     "../generic/sql_update.jison",

+ 22 - 0
desktop/core/src/desktop/js/parse/jison/sql/elasticsearch/structure.json

@@ -8,6 +8,17 @@
     "../generic/sql_error.jison",
     "../generic/sql_insert.jison",
     "../generic/sql_main.jison",
+    "../generic/select/cte_select_statement.jison",
+    "../generic/select/from_clause.jison",
+    "../generic/select/group_by_clause.jison",
+    "../generic/select/having_clause.jison",
+    "../generic/select/joins.jison",
+    "../generic/select/limit_clause.jison",
+    "../generic/select/order_by_clause.jison",
+    "../generic/select/select_conditions.jison",
+    "../generic/select/select_statement.jison",
+    "../generic/select/union_clause.jison",
+    "../generic/select/where_clause.jison",
     "../generic/sql_set.jison",
     "../generic/sql_udf.jison",
     "../generic/sql_update.jison",
@@ -22,6 +33,17 @@
     "../generic/sql_drop.jison",
     "../generic/sql_insert.jison",
     "../generic/sql_main.jison",
+    "../generic/select/cte_select_statement.jison",
+    "../generic/select/from_clause.jison",
+    "../generic/select/group_by_clause.jison",
+    "../generic/select/having_clause.jison",
+    "../generic/select/joins.jison",
+    "../generic/select/limit_clause.jison",
+    "../generic/select/order_by_clause.jison",
+    "../generic/select/select_conditions.jison",
+    "../generic/select/select_statement.jison",
+    "../generic/select/union_clause.jison",
+    "../generic/select/where_clause.jison",
     "../generic/sql_set.jison",
     "../generic/sql_udf.jison",
     "../generic/sql_update.jison",

+ 22 - 0
desktop/core/src/desktop/js/parse/jison/sql/flink/structure.json

@@ -8,6 +8,17 @@
     "../generic/sql_error.jison",
     "../generic/sql_insert.jison",
     "../generic/sql_main.jison",
+    "../generic/select/cte_select_statement.jison",
+    "../generic/select/from_clause.jison",
+    "../generic/select/group_by_clause.jison",
+    "../generic/select/having_clause.jison",
+    "../generic/select/joins.jison",
+    "../generic/select/limit_clause.jison",
+    "../generic/select/order_by_clause.jison",
+    "../generic/select/select_conditions.jison",
+    "../generic/select/select_statement.jison",
+    "../generic/select/union_clause.jison",
+    "../generic/select/where_clause.jison",
     "../generic/sql_set.jison",
     "../generic/sql_udf.jison",
     "../generic/sql_update.jison",
@@ -22,6 +33,17 @@
     "../generic/sql_drop.jison",
     "../generic/sql_insert.jison",
     "../generic/sql_main.jison",
+    "../generic/select/cte_select_statement.jison",
+    "../generic/select/from_clause.jison",
+    "../generic/select/group_by_clause.jison",
+    "../generic/select/having_clause.jison",
+    "../generic/select/joins.jison",
+    "../generic/select/limit_clause.jison",
+    "../generic/select/order_by_clause.jison",
+    "../generic/select/select_conditions.jison",
+    "../generic/select/select_statement.jison",
+    "../generic/select/union_clause.jison",
+    "../generic/select/where_clause.jison",
     "../generic/sql_set.jison",
     "../generic/sql_udf.jison",
     "../generic/sql_update.jison",

+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic2/select/cte_select_statement.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/cte_select_statement.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic2/select/from_clause.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/from_clause.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic2/select/group_by_clause.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/group_by_clause.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic2/select/having_clause.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/having_clause.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic2/select/joins.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/joins.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic2/select/limit_clause.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/limit_clause.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic2/select/order_by_clause.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/order_by_clause.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic2/select/select_conditions.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/select_conditions.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic2/select/select_statement.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/select_statement.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic2/select/union_clause.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/union_clause.jison


+ 0 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic2/select/where_clause.jison → desktop/core/src/desktop/js/parse/jison/sql/generic/select/where_clause.jison


+ 0 - 1000
desktop/core/src/desktop/js/parse/jison/sql/generic/sql_main.jison

@@ -692,731 +692,6 @@ OptionalTypePrecision
  | '(' 'UNSIGNED_INTEGER' ',' 'UNSIGNED_INTEGER' ')'
  ;
 
-// ===================================== SELECT statement =====================================
-
-QuerySpecification
- : SelectStatement OptionalUnions                                   -> $1
- | CommonTableExpression SelectStatement OptionalUnions
- | CommonTableExpression '(' QuerySpecification ')' OptionalUnions  -> $3
- ;
-
-QuerySpecification_EDIT
- : SelectStatement_EDIT OptionalUnions
- | SelectStatement OptionalUnions_EDIT
- | CommonTableExpression '(' QuerySpecification_EDIT ')'
-   {
-     parser.addCommonTableExpressions($1);
-   }
- | CommonTableExpression SelectStatement_EDIT OptionalUnions
-   {
-     parser.addCommonTableExpressions($1);
-   }
- | CommonTableExpression SelectStatement OptionalUnions_EDIT
-   {
-     parser.addCommonTableExpressions($1);
-   }
- | CommonTableExpression_EDIT
- | CommonTableExpression_EDIT '(' QuerySpecification ')'
- | CommonTableExpression_EDIT SelectStatement OptionalUnions
- ;
-
-SelectStatement
- : 'SELECT' OptionalAllOrDistinct SelectList
-   {
-     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
-     $$ = { selectList: $3 };
-   }
- | 'SELECT' OptionalAllOrDistinct SelectList TableExpression
-   {
-     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
-     $$ = { selectList: $3, tableExpression: $4 }
-   }
- ;
-
-OptionalUnions
- :
- | Unions
- ;
-
-OptionalUnions_EDIT
- : Unions_EDIT
- ;
-
-Unions
- : UnionClause
- | Unions UnionClause
- ;
-
-Unions_EDIT
- : UnionClause_EDIT
- | Unions UnionClause_EDIT
- | UnionClause_EDIT Unions
- | Unions UnionClause_EDIT Unions
- ;
-
-UnionClause
- : 'UNION' NewStatement OptionalAllOrDistinct SelectStatement
- ;
-
-UnionClause_EDIT
- : 'UNION' NewStatement 'CURSOR'
-   {
-     parser.suggestKeywords(['ALL', 'DISTINCT', 'SELECT']);
-   }
- | 'UNION' NewStatement 'CURSOR' SelectStatement
-   {
-     parser.suggestKeywords(['ALL', 'DISTINCT']);
-   }
- | 'UNION' NewStatement OptionalAllOrDistinct SelectStatement_EDIT
- ;
-
-SelectStatement_EDIT
- : 'SELECT' OptionalAllOrDistinct SelectList_EDIT
-   {
-     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
-     if ($3.cursorAtStart) {
-       var keywords = parser.getSelectListKeywords();
-       if (!$2) {
-         keywords.push({ value: 'ALL', weight: 2 });
-         keywords.push({ value: 'DISTINCT', weight: 2 });
-       }
-       parser.suggestKeywords(keywords);
-     } else {
-       parser.checkForSelectListKeywords($3);
-     }
-     if ($3.suggestFunctions) {
-       parser.suggestFunctions();
-     }
-     if ($3.suggestColumns) {
-       parser.suggestColumns({ identifierChain: [], source: 'select' });
-     }
-     if ($3.suggestTables) {
-       parser.suggestTables({ prependQuestionMark: true, prependFrom: true });
-     }
-     if ($3.suggestDatabases) {
-       parser.suggestDatabases({ prependQuestionMark: true, prependFrom: true, appendDot: true });
-     }
-     if ($3.suggestAggregateFunctions && (!$2 || $2 === 'ALL')) {
-       parser.suggestAggregateFunctions();
-       parser.suggestAnalyticFunctions();
-     }
-   }
- | 'SELECT' OptionalAllOrDistinct 'CURSOR'
-   {
-     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3, true);
-     var keywords = parser.getSelectListKeywords();
-     if (!$2 || $2 === 'ALL') {
-       parser.suggestAggregateFunctions();
-       parser.suggestAnalyticFunctions();
-     }
-     if (!$2) {
-       keywords.push({ value: 'ALL', weight: 2 });
-       keywords.push({ value: 'DISTINCT', weight: 2 });
-     }
-     parser.suggestKeywords(keywords);
-     parser.suggestFunctions();
-     parser.suggestColumns({ identifierChain: [], source: 'select' });
-     parser.suggestTables({ prependQuestionMark: true, prependFrom: true });
-     parser.suggestDatabases({ prependQuestionMark: true, prependFrom: true, appendDot: true });
-   }
- | 'SELECT' OptionalAllOrDistinct SelectList TableExpression_EDIT
-   {
-     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
-   }
- | 'SELECT' OptionalAllOrDistinct SelectList_EDIT TableExpression
-   {
-     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
-     parser.selectListNoTableSuggest($3, $2);
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.source = 'select';
-     }
-   }
- | 'SELECT' OptionalAllOrDistinct 'CURSOR' TableExpression
-   {
-     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3, true);
-     var keywords = parser.getSelectListKeywords();
-     if (!$2 || $2 === 'ALL') {
-       parser.suggestAggregateFunctions();
-       parser.suggestAnalyticFunctions();
-     }
-     if (!$2) {
-       keywords.push({ value: 'ALL', weight: 2 });
-       keywords.push({ value: 'DISTINCT', weight: 2 });
-     }
-     parser.suggestKeywords(keywords);
-     parser.suggestFunctions();
-     parser.suggestColumns({ identifierChain: [], source: 'select' });
-     parser.suggestTables({ prependQuestionMark: true, prependFrom: true });
-     parser.suggestDatabases({ prependQuestionMark: true, prependFrom: true, appendDot: true });
-   }
- | 'SELECT' OptionalAllOrDistinct SelectList 'CURSOR' TableExpression
-   {
-     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
-     parser.checkForSelectListKeywords($3);
-   }
- | 'SELECT' OptionalAllOrDistinct SelectList 'CURSOR' ',' TableExpression
-   {
-     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
-     parser.checkForSelectListKeywords($3);
-   }
- | 'SELECT' OptionalAllOrDistinct SelectList 'CURSOR'
-   {
-     parser.addClauseLocation('selectList', parser.firstDefined($2, @2, $1, @1), @3);
-     parser.checkForSelectListKeywords($3);
-     var keywords = ['FROM'];
-     if (parser.yy.result.suggestKeywords) {
-       keywords = parser.yy.result.suggestKeywords.concat(keywords);
-     }
-     parser.suggestKeywords(keywords);
-     parser.suggestTables({ prependFrom: true });
-     parser.suggestDatabases({ prependFrom: true, appendDot: true });
-   }
- ;
-
-CommonTableExpression
- : 'WITH' WithQueries  -> $2
- ;
-
-CommonTableExpression_EDIT
- : 'WITH' WithQueries_EDIT
- ;
-
-WithQueries
- : WithQuery                   -> [$1]
- | WithQueries ',' WithQuery   -> $1.concat([$3])
- ;
-
-WithQueries_EDIT
- : WithQuery_EDIT
- | WithQueries ',' WithQuery_EDIT
-   {
-     parser.addCommonTableExpressions($1);
-   }
- | WithQuery_EDIT ',' WithQueries
- | WithQueries ',' WithQuery_EDIT ',' WithQueries
-   {
-     parser.addCommonTableExpressions($1);
-   }
- ;
-
-WithQuery
- : RegularOrBacktickedIdentifier 'AS' '(' TableSubQueryInner ')'
-   {
-     parser.addCteAliasLocation(@1, $1);
-     $4.alias = $1;
-     $$ = $4;
-   }
- ;
-
-WithQuery_EDIT
- : RegularOrBacktickedIdentifier 'CURSOR'
-   {
-     parser.suggestKeywords(['AS']);
-   }
- | RegularOrBacktickedIdentifier 'AS' '(' AnyCursor RightParenthesisOrError
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- | RegularOrBacktickedIdentifier 'AS' '(' TableSubQueryInner_EDIT RightParenthesisOrError
- ;
-
-OptionalAllOrDistinct
- :
- | 'ALL'
- | 'DISTINCT'
- ;
-
-TableExpression
- : FromClause OptionalSelectConditions
-   {
-     parser.addClauseLocation('whereClause', @1, $2.whereClauseLocation);
-     parser.addClauseLocation('limitClause', $2.limitClausePreceding || @1, $2.limitClauseLocation);
-   }
- ;
-
-TableExpression_EDIT
- : FromClause_EDIT OptionalSelectConditions
-   {
-     parser.addClauseLocation('whereClause', @1, $2.whereClauseLocation);
-     parser.addClauseLocation('limitClause', $2.limitClausePreceding || @1, $2.limitClauseLocation);
-   }
- | FromClause 'CURSOR' OptionalSelectConditions OptionalJoins
-   {
-     var keywords = [];
-
-     parser.addClauseLocation('whereClause', @1, $3.whereClauseLocation);
-     parser.addClauseLocation('limitClause', $2.limitClausePreceding || @1, $2.limitClauseLocation);
-
-     if ($1) {
-       if (typeof $1.tableReferenceList.hasJoinCondition !== 'undefined' && !$1.tableReferenceList.hasJoinCondition) {
-         keywords.push({ value: 'ON', weight: 3 });
-       }
-       if ($1.suggestKeywords) {
-         keywords = parser.createWeightedKeywords($1.suggestKeywords, 3);
-       }
-       if ($1.tableReferenceList.suggestJoinConditions) {
-         parser.suggestJoinConditions($1.tableReferenceList.suggestJoinConditions);
-       }
-       if ($1.tableReferenceList.suggestJoins) {
-         parser.suggestJoins($1.tableReferenceList.suggestJoins);
-       }
-       if ($1.tableReferenceList.suggestKeywords) {
-         keywords = keywords.concat(parser.createWeightedKeywords($1.tableReferenceList.suggestKeywords, 3));
-       }
-
-       // Lower the weights for 'TABLESAMPLE'
-       keywords.forEach(function (keyword) {
-         if (keyword.value === 'TABLESAMPLE') {
-           keyword.weight = 1.1;
-         }
-       });
-
-       if ($1.tableReferenceList.types) {
-         var veKeywords = parser.getValueExpressionKeywords($1.tableReferenceList);
-         keywords = keywords.concat(veKeywords.suggestKeywords);
-         if (veKeywords.suggestColRefKeywords) {
-           parser.suggestColRefKeywords(veKeywords.suggestColRefKeywords);
-           parser.addColRefIfExists($1.tableReferenceList);
-         }
-       }
-     }
-
-     if ($3.empty && $4 && $4.joinType.toUpperCase() === 'JOIN') {
-       keywords = keywords.concat(['FULL', 'FULL OUTER', 'INNER', 'LEFT', 'LEFT OUTER', 'RIGHT', 'RIGHT OUTER']);
-       parser.suggestKeywords(keywords);
-       return;
-     }
-
-     if ($3.suggestKeywords) {
-       keywords = keywords.concat(parser.createWeightedKeywords($3.suggestKeywords, 2));
-     }
-
-     if ($3.suggestFilters) {
-       parser.suggestFilters($3.suggestFilters);
-     }
-     if ($3.suggestGroupBys) {
-       parser.suggestGroupBys($3.suggestGroupBys);
-     }
-     if ($3.suggestOrderBys) {
-       parser.suggestOrderBys($3.suggestOrderBys);
-     }
-
-     if ($3.empty) {
-       keywords.push({ value: 'UNION', weight: 2.11 });
-     }
-
-     keywords = keywords.concat([
-       { value: 'FULL JOIN', weight: 1 },
-       { value: 'FULL OUTER JOIN', weight: 1 },
-       { value: 'INNER JOIN', weight: 1 },
-       { value: 'JOIN', weight: 1 },
-       { value: 'LEFT JOIN', weight: 1 },
-       { value: 'LEFT OUTER JOIN', weight: 1 },
-       { value: 'RIGHT JOIN', weight: 1 },
-       { value: 'RIGHT OUTER JOIN', weight: 1 }
-     ]);
-     parser.suggestKeywords(keywords);
-  }
- | FromClause OptionalSelectConditions_EDIT OptionalJoins
-   {
-     // A couple of things are going on here:
-     // - If there are no SelectConditions (WHERE, GROUP BY, etc.) we should suggest complete join options
-     // - If there's an OptionalJoin at the end, i.e. 'SELECT * FROM foo | JOIN ...' we should suggest
-     //   different join types
-     // - The FromClause could end with a valueExpression, in which case we should suggest keywords like '='
-     //   or 'AND' based on type
-
-     if (!$2) {
-       parser.addClauseLocation('whereClause', @1);
-       parser.addClauseLocation('limitClause', @1);
-       return;
-     }
-     parser.addClauseLocation('whereClause', @1, $2.whereClauseLocation);
-     parser.addClauseLocation('limitClause', $2.limitClausePreceding || @1, $2.limitClauseLocation);
-     var keywords = [];
-
-     if ($2.suggestColRefKeywords) {
-       parser.suggestColRefKeywords($2.suggestColRefKeywords);
-       parser.addColRefIfExists($2);
-     }
-
-     if ($2.suggestKeywords && $2.suggestKeywords.length) {
-       keywords = keywords.concat(parser.createWeightedKeywords($2.suggestKeywords, 2));
-     }
-
-     if ($2.cursorAtEnd) {
-       keywords.push({ value: 'UNION', weight: 2.11 });
-     }
-     parser.suggestKeywords(keywords);
-   }
- ;
-
-OptionalJoins
- :
- | Joins
- | Joins_INVALID
- ;
-
-FromClause
- : 'FROM' TableReferenceList
-   {
-     $$ = { tableReferenceList : $2 }
-   }
- ;
-
-FromClause_EDIT
- : 'FROM' 'CURSOR'
-   {
-       parser.suggestTables();
-       parser.suggestDatabases({ appendDot: true });
-   }
- | 'FROM' TableReferenceList_EDIT
- ;
-
-OptionalSelectConditions
- : OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
-   {
-     var keywords = parser.getKeywordsForOptionalsLR(
-       [$1, $2, $3, $4, $5],
-       [{ value: 'WHERE', weight: 7 }, { value: 'GROUP BY', weight: 6 }, { value: 'HAVING', weight: 5 }, { value: 'ORDER BY', weight: 4 }, { value: 'LIMIT', weight: 3 }],
-       [true, true, true, true, true]);
-
-     if (keywords.length > 0) {
-       $$ = { suggestKeywords: keywords, empty: !$1 && !$2 && !$3 && !$4 && !$5 };
-     } else {
-       $$ = {};
-     }
-
-     $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($4, @4, $3, @3, $2, @2, $1, @1);
-     $$.limitClauseLocation = $5 ? @5 : undefined;
-
-     if (!$1 && !$2 && !$3 && !$4 && !$5) {
-       $$.suggestFilters = { prefix: 'WHERE', tablePrimaries: parser.yy.latestTablePrimaries.concat() };
-     }
-     if (!$2 && !$3 && !$4 && !$5) {
-       $$.suggestGroupBys = { prefix: 'GROUP BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() };
-     }
-     if (!$4 && !$5) {
-       $$.suggestOrderBys = { prefix: 'ORDER BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() };
-     }
-   }
- ;
-
-OptionalSelectConditions_EDIT
- : WhereClause_EDIT OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
-   {
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.source = 'where';
-     }
-   }
- | OptionalWhereClause GroupByClause_EDIT OptionalHavingClause OptionalOrderByClause OptionalLimitClause
-   {
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.source = 'group by';
-     }
-   }
- | OptionalWhereClause OptionalGroupByClause HavingClause_EDIT OptionalOrderByClause OptionalLimitClause
- | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause_EDIT OptionalLimitClause
-   {
-     if (parser.yy.result.suggestColumns) {
-       parser.yy.result.suggestColumns.source = 'order by';
-     }
-   }
- | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause_EDIT
- ;
-
-OptionalSelectConditions_EDIT
- : WhereClause 'CURSOR' OptionalGroupByClause OptionalHavingClause OptionalOrderByClause OptionalLimitClause
-   {
-     var keywords = parser.getKeywordsForOptionalsLR(
-       [$3, $4, $5, $6],
-       [{ value: 'GROUP BY', weight: 8 }, { value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }],
-       [true, true, true, true]);
-     if ($1.suggestKeywords) {
-       keywords = keywords.concat(parser.createWeightedKeywords($1.suggestKeywords, 1));
-     }
-     $$ = parser.getValueExpressionKeywords($1, keywords);
-     $$.cursorAtEnd = !$3 && !$4 && !$5 && !$6;
-     if ($1.columnReference) {
-       $$.columnReference = $1.columnReference;
-     }
-     if (!$3) {
-       parser.suggestGroupBys({ prefix: 'GROUP BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() });
-     }
-     if (!$3 && !$4 && !$5) {
-       parser.suggestOrderBys({ prefix: 'ORDER BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() });
-     }
-     $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($5, @5, $4, @4, $3, @3, $1, @1);
-     $$.limitClauseLocation = $6 ? @6 : undefined;
-   }
- | OptionalWhereClause GroupByClause 'CURSOR' OptionalHavingClause OptionalOrderByClause OptionalLimitClause
-   {
-     var keywords = parser.getKeywordsForOptionalsLR(
-       [$4, $5, $6],
-       [{ value: 'HAVING', weight: 7 }, { value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }],
-       [true, true, true]);
-     if ($2.suggestKeywords) {
-       keywords = keywords.concat(parser.createWeightedKeywords($2.suggestKeywords, 8));
-     }
-     if ($2.valueExpression) {
-       $$ = parser.getValueExpressionKeywords($2.valueExpression, keywords);
-       if ($2.valueExpression.columnReference) {
-         $$.columnReference = $2.valueExpression.columnReference;
-       }
-     } else {
-       $$ = { suggestKeywords: keywords };
-     }
-     $$.cursorAtEnd = !$4 && !$5 && !$6;
-     if (!$4 && !$5) {
-       parser.suggestOrderBys({ prefix: 'ORDER BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() });
-     }
-     $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($5, @5, $4, @4, $2, @2);
-     $$.limitClauseLocation = $6 ? @6 : undefined;
-   }
- | OptionalWhereClause OptionalGroupByClause HavingClause 'CURSOR' OptionalOrderByClause OptionalLimitClause
-   {
-     var keywords = parser.getKeywordsForOptionalsLR(
-       [$5, $6],
-       [{ value: 'ORDER BY', weight: 5 }, { value: 'LIMIT', weight: 3 }],
-       [true, true]);
-     $$ = { suggestKeywords: keywords, cursorAtEnd: !$5 && !$6 };
-     if (!$5) {
-       parser.suggestOrderBys({ prefix: 'ORDER BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() });
-     }
-     $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($5, @5, $3, @3);
-     $$.limitClauseLocation = $6 ? @6 : undefined;
-   }
- | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OrderByClause 'CURSOR' OptionalLimitClause
-   {
-     var keywords = parser.getKeywordsForOptionalsLR(
-       [$6],
-       [{ value: 'LIMIT', weight: 3 }],
-       [true]);
-     if ($4.suggestKeywords) {
-       keywords = keywords.concat(parser.createWeightedKeywords($4.suggestKeywords, 4));
-     }
-     $$ = { suggestKeywords: keywords, cursorAtEnd: !$6 };
-     $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($4, @4);
-     $$.limitClauseLocation = $6 ? @6 : undefined;
-   }
- | OptionalWhereClause OptionalGroupByClause OptionalHavingClause OptionalOrderByClause LimitClause 'CURSOR'
-   {
-     $$ = { suggestKeywords: [], cursorAtEnd: true };
-     $$.whereClauseLocation = $1 ? @1 : undefined;
-     $$.limitClausePreceding = parser.firstDefined($4, @4, $3, @3, $2, @2, $1, @1);
-     $$.limitClauseLocation = @5;
-   }
- ;
-
-OptionalWhereClause
- :
- | WhereClause
- ;
-
-WhereClause
- : 'WHERE' SearchCondition  -> $2
- ;
-
-WhereClause_EDIT
- : 'WHERE' SearchCondition_EDIT
-   {
-     if ($2.suggestFilters) {
-       parser.suggestFilters({ tablePrimaries: parser.yy.latestTablePrimaries.concat() });
-     }
-   }
- | 'WHERE' 'CURSOR'
-   {
-     parser.suggestFunctions();
-     parser.suggestColumns();
-     parser.suggestKeywords(['EXISTS', 'NOT EXISTS']);
-     parser.suggestFilters({ tablePrimaries: parser.yy.latestTablePrimaries.concat() });
-   }
- ;
-
-OptionalGroupByClause
- :
- | GroupByClause
- ;
-
-GroupByClause
- : 'GROUP' 'BY' GroupByColumnList
-   {
-     $$ = { valueExpression: $3 };
-   }
- ;
-
-GroupByClause_EDIT
- : 'GROUP' 'BY' GroupByColumnList_EDIT
-   {
-     parser.suggestSelectListAliases();
-   }
- | 'GROUP' 'BY' 'CURSOR'
-   {
-     parser.valueExpressionSuggest();
-     parser.suggestSelectListAliases();
-     parser.suggestGroupBys({ tablePrimaries: parser.yy.latestTablePrimaries.concat() });
-   }
- | 'GROUP' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-     parser.suggestGroupBys({ prefix: 'BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() });
-   }
- ;
-
-ColumnGroupingSets
- :
- | ColumnReference
- | ColumnGroupingSets ',' ColumnGroupingSets
- | '(' ColumnGroupingSets ')'
- ;
-
-ColumnGroupingSets_EDIT
- : ColumnGroupingSet_EDIT
- | ColumnGroupingSet_EDIT ',' ColumnGroupingSets
- | ColumnGroupingSets ',' ColumnGroupingSet_EDIT
- | ColumnGroupingSets ',' ColumnGroupingSet_EDIT ',' ColumnGroupingSets
- | '(' ColumnGroupingSets_EDIT RightParenthesisOrError
- ;
-
-ColumnGroupingSet_EDIT
- : AnyCursor
-   {
-     parser.suggestColumns();
-   }
- | ColumnReference_EDIT
- ;
-
-GroupByColumnList
- : ValueExpression
- | GroupByColumnList ',' ValueExpression  -> $3
- ;
-
-GroupByColumnList_EDIT
- : ValueExpression_EDIT
- | 'CURSOR' ValueExpression
-   {
-     parser.valueExpressionSuggest();
-   }
- | 'CURSOR' ',' GroupByColumnList
-   {
-     parser.valueExpressionSuggest();
-   }
- | ValueExpression_EDIT ',' GroupByColumnList
- | GroupByColumnList ',' GroupByColumnListPartTwo_EDIT
- | GroupByColumnList ',' GroupByColumnListPartTwo_EDIT ','
- | GroupByColumnList ',' GroupByColumnListPartTwo_EDIT ',' GroupByColumnList
- ;
-
-GroupByColumnListPartTwo_EDIT
- : ValueExpression_EDIT
- | AnyCursor ValueExpression
-   {
-     parser.valueExpressionSuggest();
-   }
- | AnyCursor
-   {
-     parser.valueExpressionSuggest();
-   }
- ;
-
-OptionalOrderByClause
- :
- | OrderByClause
- ;
-
-OrderByClause
- : 'ORDER' 'BY' OrderByColumnList  -> $3
- ;
-
-OrderByClause_EDIT
- : 'ORDER' 'BY' OrderByColumnList_EDIT
-   {
-     if ($3.emptyOrderBy) {
-       parser.suggestOrderBys({ tablePrimaries: parser.yy.latestTablePrimaries.concat() });
-     }
-   }
- | 'ORDER' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-     parser.suggestOrderBys({ prefix: 'BY', tablePrimaries: parser.yy.latestTablePrimaries.concat() });
-   }
- ;
-
-OrderByColumnList
- : OrderByIdentifier
- | OrderByColumnList ',' OrderByIdentifier  -> $3
- ;
-
-OrderByColumnList_EDIT
- : OrderByIdentifier_EDIT
- | 'CURSOR' OrderByIdentifier
-   {
-     $$ = { emptyOrderBy: false }
-     parser.valueExpressionSuggest();
-     parser.suggestAnalyticFunctions();
-     parser.suggestSelectListAliases();
-   }
- | OrderByColumnList ',' OrderByIdentifier_EDIT                        -> { emptyOrderBy: false }
- | OrderByColumnList ',' OrderByIdentifier_EDIT ','                    -> { emptyOrderBy: false }
- | OrderByColumnList ',' OrderByIdentifier_EDIT ',' OrderByColumnList  -> { emptyOrderBy: false }
- ;
-
-OrderByIdentifier
- : ValueExpression OptionalAscOrDesc  -> parser.mergeSuggestKeywords($2)
- ;
-
-OrderByIdentifier_EDIT
- : ValueExpression_EDIT OptionalAscOrDesc
-   {
-     parser.suggestSelectListAliases();
-   }
- | AnyCursor OptionalAscOrDesc
-   {
-     $$ = { emptyOrderBy: true }
-     parser.valueExpressionSuggest();
-     parser.suggestAnalyticFunctions();
-     parser.suggestSelectListAliases();
-   }
- ;
-
-OptionalAscOrDesc
- :                          -> { suggestKeywords: ['ASC', 'DESC'] };
- | 'ASC'
- | 'DESC'
- ;
-
-OptionalLimitClause
- :
- | LimitClause
- ;
-
-LimitClause
- : 'LIMIT' UnsignedNumericLiteral
- | 'LIMIT' UnsignedNumericLiteral ',' UnsignedNumericLiteral
- | 'LIMIT' 'VARIABLE_REFERENCE'
- | 'LIMIT' 'VARIABLE_REFERENCE' ',' 'VARIABLE_REFERENCE'
- ;
-
-LimitClause_EDIT
- : 'LIMIT' 'CURSOR'
-   {
-     parser.suggestKeywords([{ value: '10', weight: 10000 }, { value: '100', weight: 10000 }, { value: '1000', weight: 10000 }, { value: '5000', weight: 10000 }, { value: '10000', weight: 10000 }])
-   }
- ;
-
-SearchCondition
- : ValueExpression
- ;
-
-SearchCondition_EDIT
- : ValueExpression_EDIT
- ;
-
 ValueExpression
  : NonParenthesizedValueExpressionPrimary
  ;
@@ -1629,110 +904,6 @@ OptionalNot
  | 'NOT'
  ;
 
-SelectSpecification
- : ValueExpression OptionalCorrelationName
-   {
-     if ($2) {
-       parser.addColumnAliasLocation($2.location, $2.alias, @1);
-       $$ = { valueExpression: $1, alias: $2.alias };
-       if (!parser.yy.selectListAliases) {
-         parser.yy.selectListAliases = [];
-       }
-       parser.yy.selectListAliases.push($1.function && $1.types && $1.types.length && $1.types[0] === 'UDFREF' ? { name: $2.alias, udfRef: $1.function, types: $1.types } : { name: $2.alias, types: $1.types || ['T'] });
-     } else {
-       $$ = { valueExpression: $1 }
-     }
-   }
- | '*'
-   {
-     parser.addAsteriskLocation(@1, [{ asterisk: true }]);
-     $$ = { asterisk: true }
-   }
- ;
-
-SelectSpecification_EDIT
- : ValueExpression_EDIT OptionalCorrelationName
-   {
-     if ($2) {
-       parser.addColumnAliasLocation($2.location, $2.alias, @1);
-     }
-   }
-
- | AnyCursor 'AS' RegularOrBacktickedIdentifier
-   {
-     parser.suggestFunctions();
-     parser.suggestColumns();
-     parser.addColumnAliasLocation(@3, $3, @1);
-     $$ = { suggestAggregateFunctions: true };
-   }
- | ValueExpression OptionalCorrelationName_EDIT  -> $2
- ;
-
-SelectList
- : SelectSpecification                 -> [ $1 ]
- | SelectList ',' SelectSpecification
-   {
-     $1.push($3);
-   }
- ;
-
-SelectList_EDIT
- : SelectSpecification_EDIT
- | 'CURSOR' SelectList
-   {
-     $$ = { cursorAtStart : true, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
-   }
- | 'CURSOR' ',' SelectList
-   {
-     $$ = { cursorAtStart : true, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
-   }
- | SelectSpecification_EDIT ',' SelectList
- | SelectList 'CURSOR' SelectList
-   {
-     parser.checkForSelectListKeywords($1);
-   }
- | SelectList 'CURSOR' ',' SelectList
-   {
-     parser.checkForSelectListKeywords($1);
-   }
- | SelectList ',' AnyCursor
-   {
-     $$ = { suggestKeywords: parser.getSelectListKeywords(), suggestTables: true, suggestDatabases: true, suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true };
-   }
- | SelectList ',' SelectSpecification_EDIT                 -> $3
- | SelectList ',' AnyCursor SelectList
-   {
-     $$ = { suggestKeywords: parser.getSelectListKeywords(), suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true,  };
-   }
- | SelectList ',' AnyCursor ','
-   {
-     $$ = { suggestKeywords: parser.getSelectListKeywords(), suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true,  };
-   }
- | SelectList ',' SelectSpecification_EDIT ','             -> $3
- | SelectList ',' AnyCursor ',' SelectList
-   {
-     $$ = { suggestKeywords: parser.getSelectListKeywords(), suggestFunctions: true, suggestColumns: true, suggestAggregateFunctions: true,  };
-   }
- | SelectList ',' SelectSpecification_EDIT ',' SelectList  -> $3
- ;
-
-TableReferenceList
- : TableReference
- | TableReferenceList ',' TableReference  -> $3
- ;
-
-TableReferenceList_EDIT
- : TableReference_EDIT
- | TableReference_EDIT ',' TableReference
- | TableReferenceList ',' TableReference_EDIT
- | TableReferenceList ',' TableReference_EDIT ',' TableReferenceList
- | TableReferenceList ',' AnyCursor
-   {
-       parser.suggestTables();
-       parser.suggestDatabases({ appendDot: true });
-   }
- ;
-
 TableReference
  : TablePrimaryOrJoinedTable
  ;
@@ -1782,154 +953,6 @@ JoinedTable_EDIT
  | TablePrimary_EDIT Joins
  ;
 
-Joins
- : JoinType TablePrimary OptionalJoinCondition
-   {
-     if ($3 && $3.valueExpression) {
-       $$ = $3.valueExpression;
-     } else {
-       $$ = {};
-     }
-     $$.joinType = $1;
-     if ($3.noJoinCondition) {
-       $$.suggestJoinConditions = { prependOn: true, tablePrimaries: parser.yy.latestTablePrimaries.concat() }
-     }
-     if ($3.suggestKeywords) {
-       $$.suggestKeywords = $3.suggestKeywords;
-     }
-     if (parser.yy.latestTablePrimaries.length > 0) {
-        parser.yy.latestTablePrimaries[parser.yy.latestTablePrimaries.length - 1].join = true;
-     }
-   }
- | Joins JoinType TablePrimary OptionalJoinCondition
-   {
-     if ($4 && $4.valueExpression) {
-       $$ = $4.valueExpression;
-     } else {
-       $$ = {};
-     }
-     $$.joinType = $1;
-     if ($4.noJoinCondition) {
-       $$.suggestJoinConditions = { prependOn: true, tablePrimaries: parser.yy.latestTablePrimaries.concat() }
-     }
-     if ($4.suggestKeywords) {
-       $$.suggestKeywords = $4.suggestKeywords;
-     }
-     if (parser.yy.latestTablePrimaries.length > 0) {
-       parser.yy.latestTablePrimaries[parser.yy.latestTablePrimaries.length - 1].join = true;
-     }
-   }
- ;
-
-Joins_INVALID
- : JoinType                                           -> { joinType: $1 }
- | JoinType Joins                                     -> { joinType: $1 }
- ;
-
-Join_EDIT
- : JoinType_EDIT TablePrimary OptionalJoinCondition
-   {
-     if ($1.suggestKeywords) {
-       parser.suggestKeywords($1.suggestKeywords);
-     }
-   }
- | JoinType_EDIT
-   {
-     if ($1.suggestKeywords) {
-       parser.suggestKeywords($1.suggestKeywords);
-     }
-   }
- | JoinType TablePrimary_EDIT OptionalJoinCondition
- | JoinType TablePrimary JoinCondition_EDIT
- | JoinType 'CURSOR' OptionalJoinCondition
-   {
-     if (parser.yy.latestTablePrimaries.length > 0) {
-       var idx = parser.yy.latestTablePrimaries.length - 1;
-       var tables = [];
-       do {
-         var tablePrimary = parser.yy.latestTablePrimaries[idx];
-         if (!tablePrimary.subQueryAlias) {
-           tables.unshift(tablePrimary.alias ? { identifierChain: tablePrimary.identifierChain, alias: tablePrimary.alias } : { identifierChain: tablePrimary.identifierChain })
-         }
-         idx--;
-       } while (idx >= 0 && tablePrimary.join && !tablePrimary.subQueryAlias)
-
-       if (tables.length > 0) {
-         parser.suggestJoins({
-           prependJoin: false,
-           joinType: $1,
-           tables: tables
-         })
-       }
-     }
-     parser.suggestTables();
-     parser.suggestDatabases({
-       appendDot: true
-     });
-   }
- ;
-
-Joins_EDIT
- : Join_EDIT
- | Join_EDIT Joins
- | Joins Join_EDIT
- | Joins Join_EDIT Joins
- ;
-
-JoinType
- : 'CROSS' 'JOIN'                 -> 'CROSS JOIN'
- | 'FULL' 'JOIN'                  -> 'FULL JOIN'
- | 'FULL' 'OUTER' 'JOIN'          -> 'FULL OUTER JOIN'
- | 'INNER' 'JOIN'                 -> 'INNER JOIN'
- | 'JOIN'                         -> 'JOIN'
- | 'LEFT' 'INNER' 'JOIN'          -> 'LEFT INNER JOIN'
- | 'LEFT' 'JOIN'                  -> 'LEFT JOIN'
- | 'LEFT' 'OUTER' 'JOIN'          -> 'LEFT OUTER JOIN'
- | 'LEFT' 'SEMI' 'JOIN'           -> 'LEFT SEMI JOIN'
- | 'OUTER' 'JOIN'                 -> 'OUTER JOIN'
- | 'RIGHT' 'INNER' 'JOIN'         -> 'RIGHT OUTER JOIN'
- | 'RIGHT' 'JOIN'                 -> 'RIGHT JOIN'
- | 'RIGHT' 'OUTER' 'JOIN'         -> 'RIGHT OUTER JOIN'
- | 'RIGHT' 'SEMI' 'JOIN'          -> 'RIGHT SEMI JOIN'
- | 'SEMI' 'JOIN'                  -> 'SEMI JOIN'
- ;
-
-JoinType_EDIT
- : 'CROSS' 'CURSOR'                 -> { suggestKeywords: ['JOIN'] }
- | 'FULL' 'CURSOR' 'JOIN'           -> { suggestKeywords: ['OUTER'] }
- | 'FULL' 'OUTER' 'CURSOR'          -> { suggestKeywords: ['JOIN'] }
- | 'INNER' 'CURSOR'                 -> { suggestKeywords: ['JOIN'] }
- | 'LEFT' 'CURSOR' 'JOIN'           -> { suggestKeywords: ['OUTER'] }
- | 'LEFT' 'INNER' 'CURSOR'          -> { suggestKeywords: ['JOIN'] }
- | 'LEFT' 'OUTER' 'CURSOR'          -> { suggestKeywords: ['JOIN'] }
- | 'LEFT' 'SEMI' 'CURSOR'           -> { suggestKeywords: ['JOIN'] }
- | 'OUTER' 'CURSOR'                 -> { suggestKeywords: ['JOIN'] }
- | 'RIGHT' 'CURSOR' 'JOIN'          -> { suggestKeywords: ['OUTER'] }
- | 'RIGHT' 'INNER' 'CURSOR'         -> { suggestKeywords: ['JOIN'] }
- | 'RIGHT' 'OUTER' 'CURSOR'         -> { suggestKeywords: ['JOIN'] }
- | 'RIGHT' 'SEMI' 'CURSOR'          -> { suggestKeywords: ['JOIN'] }
- | 'SEMI' 'CURSOR'                  -> { suggestKeywords: ['JOIN'] }
- ;
-
-OptionalJoinCondition
- :                                       -> { noJoinCondition: true, suggestKeywords: ['ON'] }
- | 'ON' ValueExpression                  -> { valueExpression: $2 }
- ;
-
-UsingColList
- : RegularOrBacktickedIdentifier
- | UsingColList ',' RegularOrBacktickedIdentifier
- ;
-
-JoinCondition_EDIT
- : 'ON' ValueExpression_EDIT
- | 'ON' 'CURSOR'
-   {
-     parser.valueExpressionSuggest();
-     parser.suggestJoinConditions({ prependOn: false });
-   }
- ;
-
 TablePrimary
  : TableOrQueryName OptionalCorrelationName
    {
@@ -2344,26 +1367,3 @@ IntegerOrUnbounded
  : 'UNSIGNED_INTEGER'
  | 'UNBOUNDED'
  ;
-
-OptionalHavingClause
- :
- | HavingClause
- ;
-
-HavingClause
- : 'HAVING' ValueExpression
- ;
-
-HavingClause_EDIT
- : 'HAVING' 'CURSOR'
-   {
-     parser.valueExpressionSuggest();
-     parser.suggestAggregateFunctions();
-     parser.suggestSelectListAliases(true);
-   }
- | 'HAVING' ValueExpression_EDIT
-   {
-     parser.suggestAggregateFunctions();
-     parser.suggestSelectListAliases(true);
-   }
- ;

+ 22 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/structure.json

@@ -8,6 +8,17 @@
     "sql_error.jison",
     "sql_insert.jison",
     "sql_main.jison",
+    "select/cte_select_statement.jison",
+    "select/from_clause.jison",
+    "select/group_by_clause.jison",
+    "select/having_clause.jison",
+    "select/joins.jison",
+    "select/limit_clause.jison",
+    "select/order_by_clause.jison",
+    "select/select_conditions.jison",
+    "select/select_statement.jison",
+    "select/union_clause.jison",
+    "select/where_clause.jison",
     "sql_set.jison",
     "sql_udf.jison",
     "sql_update.jison",
@@ -22,6 +33,17 @@
     "sql_drop.jison",
     "sql_insert.jison",
     "sql_main.jison",
+    "select/cte_select_statement.jison",
+    "select/from_clause.jison",
+    "select/group_by_clause.jison",
+    "select/having_clause.jison",
+    "select/joins.jison",
+    "select/limit_clause.jison",
+    "select/order_by_clause.jison",
+    "select/select_conditions.jison",
+    "select/select_statement.jison",
+    "select/union_clause.jison",
+    "select/where_clause.jison",
     "sql_set.jison",
     "sql_udf.jison",
     "sql_update.jison",

+ 0 - 1369
desktop/core/src/desktop/js/parse/jison/sql/generic2/sql_main.jison

@@ -1,1369 +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.
-
-SqlSyntax
- : NewStatement SqlStatements EOF
- ;
-
-SqlAutocomplete
- : NewStatement SqlStatements EOF
-   {
-     return parser.yy.result;
-   }
- | NewStatement SqlStatements_EDIT EOF
-   {
-     return parser.yy.result;
-   }
- ;
-
-NewStatement
- : /* empty */
-   {
-     parser.prepareNewStatement();
-   }
- ;
-
-SqlStatements
- :
- | SqlStatement
-   {
-     parser.addStatementLocation(@1);
-   }
- | SqlStatements ';' NewStatement SqlStatements
- ;
-
-SqlStatements_EDIT
- : SqlStatement_EDIT
-   {
-     parser.addStatementLocation(@1);
-   }
- | SqlStatement_EDIT ';' NewStatement SqlStatements
-   {
-     parser.addStatementLocation(@1);
-   }
- | SqlStatements ';' NewStatement SqlStatement_EDIT
-   {
-     parser.addStatementLocation(@4);
-   }
- | SqlStatements ';' NewStatement SqlStatement_EDIT ';' NewStatement SqlStatements
-   {
-     parser.addStatementLocation(@4);
-   }
- ;
-
-SqlStatement
- : DataDefinition
- | DataManipulation
- | QuerySpecification
- ;
-
-SqlStatement_EDIT
- : AnyCursor
-   {
-     parser.suggestDdlAndDmlKeywords();
-   }
- | CommonTableExpression 'CURSOR'
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- | DataDefinition_EDIT
- | DataManipulation_EDIT
- | QuerySpecification_EDIT
- | SetSpecification_EDIT
- ;
-
-NonReservedKeyword
- : 'ROLE'
- | 'OPTION'
- | 'STRUCT'
- ;
-
-RegularIdentifier
- : 'REGULAR_IDENTIFIER'
- | 'VARIABLE_REFERENCE'
- | NonReservedKeyword
- ;
-
-// This is a work-around for error handling when a statement starts with some token that the parser can understand but
-// it's not a valid statement (see ErrorStatement). It contains everything except valid starting tokens ('SELECT', 'USE' etc.)
-NonStartingToken
- : '!'
- | '('
- | ')'
- | '*'
- | ','
- | '-'
- | '.'
- | '<'
- | '='
- | '>'
- | '['
- | ']'
- | '~'
- | 'ALL'
- | 'ANALYTIC'
- | 'AND'
- | 'ARITHMETIC_OPERATOR'
- | 'ARRAY'
- | 'AS'
- | 'ASC'
- | 'AVG'
- | 'BACKTICK'
- | 'BETWEEN'
- | 'BIGINT'
- | 'BOOLEAN'
- | 'BY'
- | 'CASE'
- | 'CAST'
- | 'CHAR'
- | 'COMPARISON_OPERATOR'
- | 'COUNT'
- | 'CROSS'
- | 'CURRENT'
- | 'DATABASE'
- | 'DECIMAL'
- | 'DESC'
- | 'DISTINCT'
- | 'DOUBLE'
- | 'DOUBLE_QUOTE'
- | 'ELSE'
- | 'END'
- | 'EXISTS'
- | 'FALSE'
- | 'FLOAT'
- | 'FOLLOWING'
- | 'FROM'
- | 'FULL'
- | 'GROUP'
- | 'HAVING'
- | 'HDFS_START_QUOTE'
- | 'IF'
- | 'IN'
- | 'INNER'
- | 'INT'
- | 'INTO'
- | 'IS'
- | 'JOIN'
- | 'LEFT'
- | 'LIKE'
- | 'LIMIT'
- | 'MAP'
- | 'MAX'
- | 'MIN'
- | 'NOT'
- | 'NULL'
- | 'ON'
- | 'OPTION'
- | 'OR'
- | 'ORDER'
- | 'OUTER'
- | 'OVER'
- | 'PARTITION'
- | 'PRECEDING'
- | 'PURGE'
- | 'RANGE'
- | 'REGEXP'
- | 'REGULAR_IDENTIFIER'
- | 'RIGHT'
- | 'RLIKE'
- | 'ROLE'
- | 'ROW'
- | 'ROWS'
- | 'SCHEMA'
- | 'SEMI'
- | 'SET'
- | 'SINGLE_QUOTE'
- | 'SMALLINT'
- | 'STDDEV_POP'
- | 'STDDEV_SAMP'
- | 'STRING'
- | 'STRUCT'
- | 'SUM'
- | 'TABLE'
- | 'THEN'
- | 'TIMESTAMP'
- | 'TINYINT'
- | 'TRUE'
- | 'UNION'
- | 'UNSIGNED_INTEGER'
- | 'UNSIGNED_INTEGER_E'
- | 'VALUES'
- | 'VAR_POP'
- | 'VAR_SAMP'
- | 'VARCHAR'
- | 'VARIABLE_REFERENCE'
- | 'VARIANCE'
- | 'WHEN'
- | 'WHERE'
- ;
-
-// ===================================== Commonly used constructs =====================================
-
-Commas
- : ','
- | Commas ','
- ;
-
-AnyCursor
- : 'CURSOR'
- | 'PARTIAL_CURSOR'
- ;
-
-FromOrIn
- : 'FROM'
- | 'IN'
- ;
-
-DatabaseOrSchema
- : 'DATABASE'
- | 'SCHEMA'
- ;
-
-SingleQuotedValue
- : 'SINGLE_QUOTE' 'VALUE' 'SINGLE_QUOTE'  -> $2
- | 'SINGLE_QUOTE' 'SINGLE_QUOTE'          -> ''
- ;
-
-SingleQuotedValue_EDIT
- : 'SINGLE_QUOTE' 'PARTIAL_VALUE'
- ;
-
-DoubleQuotedValue
- : 'DOUBLE_QUOTE' 'VALUE' 'DOUBLE_QUOTE'  -> $2
- | 'DOUBLE_QUOTE' 'DOUBLE_QUOTE'          -> ''
- ;
-
-DoubleQuotedValue_EDIT
- : 'DOUBLE_QUOTE' 'PARTIAL_VALUE'
- ;
-
-QuotedValue
- : SingleQuotedValue
- | DoubleQuotedValue
- ;
-
-QuotedValue_EDIT
- : SingleQuotedValue_EDIT
- | DoubleQuotedValue_EDIT
- ;
-
-OptionalFromDatabase
- :
- | FromOrIn DatabaseIdentifier
- ;
-
-OptionalFromDatabase_EDIT
- : FromOrIn DatabaseIdentifier_EDIT
- ;
-
-OptionalCascade
- :
- | 'CASCADE'
- ;
-
-OptionalIfExists
- :
- | 'IF' 'EXISTS'
-   {
-     parser.yy.correlatedSubQuery = false;
-   }
- ;
-
-OptionalIfExists_EDIT
- : 'IF' 'CURSOR'
-   {
-     parser.suggestKeywords(['EXISTS']);
-   }
- ;
-
-OptionalIfNotExists
- :
- | 'IF' 'NOT' 'EXISTS'
-   {
-     parser.yy.correlatedSubQuery = false;
-   }
- ;
-
-OptionalIfNotExists_EDIT
- : 'IF' 'CURSOR'
-   {
-     parser.suggestKeywords(['NOT EXISTS']);
-   }
- | 'IF' 'NOT' 'CURSOR'
-   {
-     parser.suggestKeywords(['EXISTS']);
-   }
- ;
-
-OptionalInDatabase
- :
- | 'IN' DatabaseIdentifier
- | 'IN' DatabaseIdentifier_EDIT
- ;
-
-OptionalPartitionSpec
- :
- | PartitionSpec
- ;
-
-OptionalPartitionSpec_EDIT
- : PartitionSpec_EDIT
- ;
-
-PartitionSpec
- : 'PARTITION' '(' PartitionSpecList ')'
- ;
-
-PartitionSpec_EDIT
- : 'PARTITION' '(' PartitionSpecList_EDIT RightParenthesisOrError
- ;
-
-RangePartitionSpec
- : UnsignedValueSpecification RangePartitionComparisonOperator 'VALUES' RangePartitionComparisonOperator UnsignedValueSpecification
- ;
-
-RangePartitionSpec_EDIT
- : UnsignedValueSpecification 'CURSOR'
-   {
-     parser.suggestKeywords(['<', '<=', '<>', '=', '>', '>=']);
-   }
- | UnsignedValueSpecification RangePartitionComparisonOperator 'CURSOR'
-   {
-     parser.suggestKeywords(['VALUES']);
-   }
- | UnsignedValueSpecification RangePartitionComparisonOperator 'VALUES' 'CURSOR'
-   {
-     parser.suggestKeywords(['<', '<=', '<>', '=', '>', '>=']);
-   }
- | UnsignedValueSpecification 'CURSOR' 'VALUES' RangePartitionComparisonOperator UnsignedValueSpecification
-   {
-     parser.suggestKeywords(['<', '<=', '<>', '=', '>', '>=']);
-   }
- | UnsignedValueSpecification RangePartitionComparisonOperator 'CURSOR' RangePartitionComparisonOperator UnsignedValueSpecification
-   {
-     parser.suggestKeywords(['VALUES']);
-   }
- | UnsignedValueSpecification RangePartitionComparisonOperator 'VALUES' 'CURSOR' UnsignedValueSpecification
-   {
-     parser.suggestKeywords(['<', '<=', '<>', '=', '>', '>=']);
-   }
- ;
-
-RangePartitionComparisonOperator
- : 'COMPARISON_OPERATOR'
- | '='
- | '<'
- | '>'
- ;
-
-ConfigurationName
- : RegularIdentifier
- | 'CURSOR'
- ;
-
-PartialBacktickedOrAnyCursor
- : AnyCursor
- | PartialBacktickedIdentifier
- ;
-
-PartialBacktickedOrCursor
- : 'CURSOR'
- | PartialBacktickedIdentifier
- ;
-
-PartialBacktickedOrPartialCursor
- : 'PARTIAL_CURSOR'
- | PartialBacktickedIdentifier
- ;
-
-PartialBacktickedIdentifier
- : 'BACKTICK' 'PARTIAL_VALUE'
- ;
-
-RightParenthesisOrError
- : ')'
- | error
- ;
-
-OptionalParenthesizedColumnList
- :
- | ParenthesizedColumnList
- ;
-
-OptionalParenthesizedColumnList_EDIT
- : ParenthesizedColumnList_EDIT
- ;
-
-ParenthesizedColumnList
- : '(' ColumnList ')'
- ;
-
-ParenthesizedColumnList_EDIT
- : '(' ColumnList_EDIT RightParenthesisOrError
- | '(' AnyCursor RightParenthesisOrError
-   {
-     parser.suggestColumns();
-   }
- ;
-
-ColumnList
- : ColumnIdentifier
- | ColumnList ',' ColumnIdentifier
- ;
-
-ColumnList_EDIT
- : ColumnList ',' AnyCursor
-   {
-     parser.suggestColumns();
-   }
- | ColumnList ',' AnyCursor ',' ColumnList
-   {
-     parser.suggestColumns();
-   }
- ;
-
-ParenthesizedSimpleValueList
- : '(' SimpleValueList ')'
- ;
-
-SimpleValueList
- : UnsignedValueSpecification
- | SimpleValueList ',' UnsignedValueSpecification
- ;
-
-SchemaQualifiedTableIdentifier
- : RegularOrBacktickedIdentifier
-   {
-     parser.addTableLocation(@1, [ { name: $1 } ]);
-     $$ = { identifierChain: [ { name: $1 } ] };
-   }
- | RegularOrBacktickedIdentifier '.' RegularOrBacktickedIdentifier
-   {
-     parser.addDatabaseLocation(@1, [ { name: $1 } ]);
-     parser.addTableLocation(@3, [ { name: $1 }, { name: $3 } ]);
-     $$ = { identifierChain: [ { name: $1 }, { name: $3 } ] };
-   }
- ;
-
-SchemaQualifiedTableIdentifier_EDIT
- : PartialBacktickedIdentifier
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ appendDot: true });
-   }
- | PartialBacktickedIdentifier '.' RegularOrBacktickedIdentifier
-   {
-     parser.suggestDatabases();
-     $$ = { identifierChain: [{ name: $1 }] };
-   }
- | RegularOrBacktickedIdentifier '.' PartialBacktickedOrPartialCursor
-   {
-     parser.suggestTablesOrColumns($1);
-   }
- ;
-
-SchemaQualifiedIdentifier
- : RegularOrBacktickedIdentifier                                       -> [{ name: $1 }]
- | RegularOrBacktickedIdentifier '.' RegularOrBacktickedIdentifier  -> [{ name: $1 }, { name: $2 }]
- ;
-
-SchemaQualifiedIdentifier_EDIT
- : PartialBacktickedIdentifier
-   {
-     parser.suggestDatabases({ appendDot: true });
-   }
- | PartialBacktickedIdentifier '.' RegularOrBacktickedIdentifier
-   {
-     parser.suggestDatabases();
-     $$ = { identifierChain: [{ name: $1 }] };
-   }
- | RegularOrBacktickedIdentifier '.' PartialBacktickedOrPartialCursor
- ;
-
-DatabaseIdentifier
- : RegularOrBacktickedIdentifier
- ;
-
-DatabaseIdentifier_EDIT
- : PartialBacktickedOrCursor
-   {
-     parser.suggestDatabases();
-   }
- ;
-
-PartitionSpecList
- : PartitionExpression
- | PartitionSpecList ',' PartitionExpression
- ;
-
-PartitionSpecList_EDIT
- : PartitionExpression_EDIT
- | PartitionSpecList ',' PartitionExpression_EDIT
- | PartitionExpression_EDIT ',' PartitionSpecList
- | PartitionSpecList ',' PartitionExpression_EDIT ',' PartitionSpecList
- ;
-
-PartitionExpression
- : ColumnIdentifier '=' ValueExpression
- ;
-
-PartitionExpression_EDIT
- : ColumnIdentifier '=' ValueExpression_EDIT
- | ColumnIdentifier '=' AnyCursor
-   {
-     parser.valueExpressionSuggest();
-   }
- | PartialBacktickedIdentifier '=' ValueExpression
-   {
-     parser.suggestColumns();
-   }
- | AnyCursor
-   {
-     parser.suggestColumns();
-   }
- ;
-
-RegularOrBacktickedIdentifier
- : RegularIdentifier
- | 'BACKTICK' 'VALUE' 'BACKTICK'  -> $2
- | 'BACKTICK' 'BACKTICK'          -> ''
- ;
-
-// TODO: Same as SchemaQualifiedTableIdentifier?
-RegularOrBackTickedSchemaQualifiedName
- : RegularOrBacktickedIdentifier
-   {
-     parser.addTableLocation(@1, [ { name: $1 } ]);
-     $$ = { identifierChain: [ { name: $1 } ] };
-   }
- | RegularOrBacktickedIdentifier '.' RegularOrBacktickedIdentifier
-   {
-     parser.addDatabaseLocation(@1, [ { name: $1 } ]);
-     parser.addTableLocation(@3, [ { name: $1 }, { name: $3 } ]);
-     $$ = { identifierChain: [ { name: $1 }, { name: $3 } ] };
-   }
- ;
-
-RegularOrBackTickedSchemaQualifiedName_EDIT
- : PartialBacktickedIdentifier
-   {
-     parser.suggestTables();
-     parser.suggestDatabases({ prependDot: true });
-   }
- | RegularOrBacktickedIdentifier '.' PartialBacktickedOrPartialCursor
-   {
-     parser.suggestTablesOrColumns($1);
-   }
- ;
-
-
-LocalOrSchemaQualifiedName
- : RegularOrBackTickedSchemaQualifiedName
- | RegularOrBackTickedSchemaQualifiedName RegularOrBacktickedIdentifier  -> { identifierChain: $1.identifierChain, alias: $2 }
- ;
-
-LocalOrSchemaQualifiedName_EDIT
- : RegularOrBackTickedSchemaQualifiedName_EDIT
- | RegularOrBackTickedSchemaQualifiedName_EDIT RegularOrBacktickedIdentifier
- ;
-
-ColumnReference
- : BasicIdentifierChain
-   {
-     parser.yy.locations[parser.yy.locations.length - 1].type = 'column';
-   }
- | BasicIdentifierChain '.' '*'
-   {
-     parser.addAsteriskLocation(@3, $1.concat({ asterisk: true }));
-   }
- ;
-
-ColumnReference_EDIT
- : BasicIdentifierChain_EDIT
- ;
-
-BasicIdentifierChain
- : ColumnIdentifier
-   {
-     $$ = [ $1.identifier ];
-     parser.yy.firstChainLocation = parser.addUnknownLocation($1.location, [ $1.identifier ]);
-   }
- | BasicIdentifierChain '.' ColumnIdentifier
-   {
-     if (parser.yy.firstChainLocation) {
-       parser.yy.firstChainLocation.firstInChain = true;
-       delete parser.yy.firstChainLocation;
-     }
-     $1.push($3.identifier);
-     parser.addUnknownLocation($3.location, $1.concat());
-   }
- ;
-
-// TODO: Merge with DerivedColumnChain_EDIT ( issue is starting with PartialBacktickedOrPartialCursor)
-BasicIdentifierChain_EDIT
- : BasicIdentifierChain '.' PartialBacktickedOrPartialCursor
-   {
-     parser.suggestColumns({
-       identifierChain: $1
-     });
-     $$ = { suggestKeywords: [{ value: '*', weight: 10000 }] };
-   }
- | BasicIdentifierChain '.' PartialBacktickedOrPartialCursor '.' BasicIdentifierChain
-   {
-     parser.suggestColumns({
-       identifierChain: $1
-     });
-     $$ = { suggestKeywords: [{ value: '*', weight: 10000 }] };
-   }
- ;
-
-DerivedColumnChain
- : ColumnIdentifier  -> [ $1.identifier ]
- | DerivedColumnChain '.' ColumnIdentifier
-   {
-     $1.push($3.identifier);
-   }
- ;
-
-DerivedColumnChain_EDIT
- : PartialBacktickedIdentifierOrPartialCursor
-   {
-     parser.suggestColumns();
-   }
- | DerivedColumnChain '.' PartialBacktickedIdentifierOrPartialCursor
-   {
-     parser.suggestColumns({ identifierChain: $1 });
-   }
- | DerivedColumnChain '.' PartialBacktickedIdentifierOrPartialCursor '.' DerivedColumnChain
-   {
-     parser.suggestColumns({ identifierChain: $1 });
-   }
- | PartialBacktickedIdentifierOrPartialCursor '.' DerivedColumnChain
-   {
-     parser.suggestColumns();
-   }
- ;
-
-ColumnIdentifier
- : RegularOrBacktickedIdentifier                                                                               -> { identifier: { name: $1 }, location: @1 }
- ;
-
-PartialBacktickedIdentifierOrPartialCursor
- : PartialBacktickedIdentifier
- | 'PARTIAL_CURSOR'
- ;
-
-PrimitiveType
- : 'BIGINT'
- | 'BOOLEAN'
- | 'CHAR' OptionalTypeLength
- | 'DECIMAL' OptionalTypePrecision
- | 'DOUBLE'
- | 'FLOAT'
- | 'INT'
- | 'SMALLINT'
- | 'STRING'
- | 'TIMESTAMP'
- | 'TINYINT'
- | 'VARCHAR' OptionalTypeLength
- ;
-
-OptionalTypeLength
- :
- | '(' 'UNSIGNED_INTEGER' ')'
- ;
-
-OptionalTypePrecision
- :
- | '(' 'UNSIGNED_INTEGER' ')'
- | '(' 'UNSIGNED_INTEGER' ',' 'UNSIGNED_INTEGER' ')'
- ;
-
-ValueExpression
- : NonParenthesizedValueExpressionPrimary
- ;
-
-ValueExpression_EDIT
- : NonParenthesizedValueExpressionPrimary_EDIT
- ;
-
-ValueExpression_EDIT
- : ValueExpression 'NOT' 'CURSOR'
-   {
-     parser.suggestKeywords(['BETWEEN', 'EXISTS', 'IN', 'LIKE', 'REGEXP', 'RLIKE']);
-     $$ = { types: [ 'BOOLEAN' ] };
-   }
- ;
-
-ValueExpressionList
- : ValueExpression
-   {
-     $1.position = 1;
-   }
- | ValueExpressionList ',' ValueExpression
-   {
-     $3.position = $1.position + 1;
-     $$ = $3;
-   }
- ;
-
-ValueExpressionList_EDIT
- : ValueExpression_EDIT
-   {
-     $1.position = 1;
-   }
- | ValueExpressionList ',' ValueExpression_EDIT
-   {
-     $1.position += 1;
-   }
- | ValueExpression_EDIT ',' ValueExpressionList
-   {
-     $1.position = 1;
-   }
- | ValueExpressionList ',' ValueExpression_EDIT ',' ValueExpressionList
-   {
-     $1.position += 1;
-   }
- | ValueExpressionList ',' AnyCursor
-   {
-     parser.valueExpressionSuggest();
-     $1.position += 1;
-   }
- | ValueExpressionList ',' AnyCursor ',' ValueExpressionList
-   {
-     parser.valueExpressionSuggest();
-     $1.position += 1;
-   }
- | ValueExpressionList 'CURSOR' ',' ValueExpressionList
-   {
-     parser.suggestValueExpressionKeywords($1);
-   }
- | AnyCursor ',' ValueExpressionList
-   {
-     parser.valueExpressionSuggest();
-     $$ = { cursorAtStart : true, position: 1 };
-   }
- | AnyCursor ','
-   {
-     parser.valueExpressionSuggest();
-     $$ = { cursorAtStart : true, position: 1 };
-   }
- | ',' AnyCursor
-   {
-     parser.valueExpressionSuggest();
-     $$ = { position: 2 };
-   }
- | ',' AnyCursor ',' ValueExpressionList
-   {
-     parser.valueExpressionSuggest();
-     $$ = { position: 2 };
-   }
- ;
-
-InValueList
- : NonParenthesizedValueExpressionPrimary
- | InValueList ',' NonParenthesizedValueExpressionPrimary
- ;
-
-NonParenthesizedValueExpressionPrimary
- : UnsignedValueSpecification
- | ColumnOrArbitraryFunctionRef  -> { types: ['COLREF'], columnReference: $1.chain }
- | 'NULL'                        -> { types: [ 'NULL' ], text: $1 }
- ;
-
-NonParenthesizedValueExpressionPrimary_EDIT
- : UnsignedValueSpecification_EDIT
- | ColumnOrArbitraryFunctionRef_EDIT
-   {
-     if ($1.suggestKeywords) {
-       $$ = { types: ['COLREF'], columnReference: $1, suggestKeywords: $1.suggestKeywords };
-     } else {
-       $$ = { types: ['COLREF'], columnReference: $1 };
-     }
-   }
- ;
-
-ColumnOrArbitraryFunctionRef
- : BasicIdentifierChain
-   {
-     var lastLoc = parser.yy.locations[parser.yy.locations.length - 1];
-     if (lastLoc.type !== 'variable') {
-       lastLoc.type = 'column';
-     }
-     // used for function references with db prefix
-     var firstLoc = parser.yy.locations[parser.yy.locations.length - $1.length];
-     $$ = { chain: $1, firstLoc: firstLoc, lastLoc: lastLoc }
-   }
- | BasicIdentifierChain '.' '*'
-   {
-     parser.addAsteriskLocation(@3, $1.concat({ asterisk: true }));
-   }
- ;
-
-ColumnOrArbitraryFunctionRef_EDIT
- : BasicIdentifierChain_EDIT
- ;
-
-SignedInteger
- : UnsignedNumericLiteral
- | '-' UnsignedNumericLiteral
- | '+' UnsignedNumericLiteral
- ;
-
-UnsignedValueSpecification
- : UnsignedLiteral
- ;
-
-UnsignedValueSpecification_EDIT
- : UnsignedLiteral_EDIT
-   {
-     parser.suggestValues($1);
-   }
- ;
-
-UnsignedLiteral
- : UnsignedNumericLiteral  -> { types: [ 'NUMBER' ], text: $1 }
- | GeneralLiteral
- ;
-
-UnsignedLiteral_EDIT
- : GeneralLiteral_EDIT
- ;
-
-UnsignedNumericLiteral
- : ExactNumericLiteral
- | ApproximateNumericLiteral
- ;
-
-ExactNumericLiteral
- : 'UNSIGNED_INTEGER'
- | 'UNSIGNED_INTEGER' '.'                     -> $1 + $2
- | 'UNSIGNED_INTEGER' '.' 'UNSIGNED_INTEGER'  -> $1 + $2 + $3
- | '.' 'UNSIGNED_INTEGER'                     -> $1 + $2
- ;
-
-ApproximateNumericLiteral
- : 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
- : SingleQuotedValue
-   {
-     if (/\$\{[^}]*\}/.test($1)) {
-       parser.addVariableLocation(@1, $1);
-       $$ = { types: [ 'STRING' ], columnReference: [{ name: $1 }], text: "'" + $1 + "'" }
-     } else {
-       $$ = { types: [ 'STRING' ] }
-     }
-   }
- | DoubleQuotedValue
-   {
-     if (/\$\{[^}]*\}/.test($1)) {
-       parser.addVariableLocation(@1, $1);
-       $$ = { types: [ 'STRING' ], columnReference: [{ name: $1 }], text: '"' + $1 + '"' }
-     } else {
-       $$ = { types: [ 'STRING' ], text: '"' + $1 + '"' }
-     }
-   }
- | TruthValue         -> { types: [ 'BOOLEAN' ], text: $1 }
- ;
-
-GeneralLiteral_EDIT
- : SingleQuotedValue_EDIT
-  {
-    $$ = { partialQuote: '\'', missingEndQuote: parser.yy.missingEndQuote };
-  }
- | DoubleQuotedValue_EDIT
-  {
-    $$ = { partialQuote: '"', missingEndQuote: parser.yy.missingEndQuote };
-  }
- ;
-
-TruthValue
- : 'TRUE'
- | 'FALSE'
- ;
-
-OptionalNot
- :
- | 'NOT'
- ;
-
-TableReference
- : TablePrimaryOrJoinedTable
- ;
-
-TableReference_EDIT
- : TablePrimaryOrJoinedTable_EDIT
- ;
-
-TablePrimaryOrJoinedTable
- : TablePrimary
-   {
-     $$ = $1;
-
-     if (parser.yy.latestTablePrimaries.length > 0) {
-       var idx = parser.yy.latestTablePrimaries.length - 1;
-       var tables = [];
-       do {
-         var tablePrimary = parser.yy.latestTablePrimaries[idx];
-         if (!tablePrimary.subQueryAlias) {
-           tables.unshift(tablePrimary.alias ? { identifierChain: tablePrimary.identifierChain, alias: tablePrimary.alias } : { identifierChain: tablePrimary.identifierChain })
-         }
-         idx--;
-       } while (idx >= 0 && tablePrimary.join && !tablePrimary.subQueryAlias)
-
-       if (tables.length > 0) {
-         $$.suggestJoins = {
-           prependJoin: true,
-           tables: tables
-         };
-       }
-      }
-   }
- | JoinedTable
- ;
-
-TablePrimaryOrJoinedTable_EDIT
- : TablePrimary_EDIT
- | JoinedTable_EDIT
- ;
-
-JoinedTable
- : TablePrimary Joins  -> $2
- ;
-
-JoinedTable_EDIT
- : TablePrimary Joins_EDIT
- | TablePrimary_EDIT Joins
- ;
-
-TablePrimary
- : TableOrQueryName OptionalCorrelationName
-   {
-     $$ = {
-       primary: $1
-     }
-     if ($1.identifierChain) {
-       if ($2) {
-         $1.alias = $2.alias
-         parser.addTableAliasLocation($2.location, $2.alias, $1.identifierChain);
-       }
-       parser.addTablePrimary($1);
-     }
-
-     var keywords = [];
-     if (!$2) {
-       keywords = ['AS'];
-     } else if ($2.suggestKeywords) {
-       keywords = $2.suggestKeywords;
-     }
-     if (keywords.length > 0) {
-       $$.suggestKeywords = keywords;
-     }
-   }
- | DerivedTable OptionalCorrelationName
-   {
-     $$ = {
-       primary: $1
-     };
-
-     if ($2) {
-       $$.primary.alias = $2.alias;
-       parser.addTablePrimary({ subQueryAlias: $2.alias });
-       parser.addSubqueryAliasLocation($2.location, $2.alias, $1.identifierChain);
-     }
-
-     var keywords = [];
-     if (!$2) {
-       keywords = ['AS'];
-     }
-     if (keywords.length > 0) {
-       $$.suggestKeywords = keywords;
-     }
-   }
- ;
-
-TablePrimary_EDIT
- : TableOrQueryName_EDIT OptionalCorrelationName
-   {
-     if ($2) {
-       parser.addTableAliasLocation($2.location, $2.alias, $1.identifierChain);
-     }
-   }
- | DerivedTable_EDIT OptionalCorrelationName
-   {
-     if ($2) {
-       parser.addTablePrimary({ subQueryAlias: $2.alias });
-       parser.addSubqueryAliasLocation($2.location, $2.alias);
-     }
-   }
- | DerivedTable OptionalCorrelationName_EDIT
- ;
-
-TableOrQueryName
- : SchemaQualifiedTableIdentifier
- ;
-
-TableOrQueryName_EDIT
- : SchemaQualifiedTableIdentifier_EDIT
- ;
-
-DerivedTable
- : TableSubQuery
- ;
-
-DerivedTable_EDIT
- : TableSubQuery_EDIT
- ;
-
-OptionalOnColumn
- :
- | 'ON' ValueExpression
- ;
-
-OptionalOnColumn_EDIT
- : 'ON' 'CURSOR'
-   {
-     parser.valueExpressionSuggest();
-   }
- | 'ON' ValueExpression_EDIT
- ;
-
-PushQueryState
- :
-   {
-     parser.pushQueryState();
-   }
- ;
-
-PopQueryState
- :
-   {
-     parser.popQueryState();
-   }
- ;
-
-TableSubQuery
- : '(' TableSubQueryInner ')'  -> $2
- | '(' DerivedTable OptionalCorrelationName ')'
-   {
-     if ($3) {
-       $2.alias = $3.alias;
-       parser.addTablePrimary({ subQueryAlias: $3.alias });
-       parser.addSubqueryAliasLocation($3.location, $3.alias, $2.identifierChain);
-     }
-     $$ = $2;
-   }
- ;
-
-TableSubQuery_EDIT
- : '(' TableSubQueryInner_EDIT RightParenthesisOrError
- | '(' AnyCursor RightParenthesisOrError
-   {
-     parser.suggestKeywords(['SELECT']);
-   }
- ;
-
-TableSubQueryInner
- : PushQueryState SubQuery
-   {
-     var subQuery = parser.getSubQuery($2);
-     subQuery.columns.forEach(function (column) {
-       parser.expandIdentifierChain({ wrapper: column });
-       delete column.linked;
-     });
-     parser.popQueryState(subQuery);
-     $$ = subQuery;
-   }
- ;
-
-TableSubQueryInner_EDIT
- : PushQueryState SubQuery_EDIT PopQueryState
- ;
-
-SubQuery
- : QueryExpression
- ;
-
-SubQuery_EDIT
- : QueryExpression_EDIT
- ;
-
-QueryExpression
- : QueryExpressionBody
- ;
-
-QueryExpression_EDIT
- : QueryExpressionBody_EDIT
- ;
-
-QueryExpressionBody
- : NonJoinQueryExpression
- ;
-
-QueryExpressionBody_EDIT
- : NonJoinQueryExpression_EDIT
- ;
-
-NonJoinQueryExpression
- : NonJoinQueryTerm
- ;
-
-NonJoinQueryExpression_EDIT
- : NonJoinQueryTerm_EDIT
- ;
-
-NonJoinQueryTerm
- : NonJoinQueryPrimary
- ;
-
-NonJoinQueryTerm_EDIT
- : NonJoinQueryPrimary_EDIT
- ;
-
-NonJoinQueryPrimary
- : SimpleTable
- ;
-
-NonJoinQueryPrimary_EDIT
- : SimpleTable_EDIT
- ;
-
-SimpleTable
- : QuerySpecification
- ;
-
-SimpleTable_EDIT
- : QuerySpecification_EDIT
- ;
-
-OptionalCorrelationName
- :
- | RegularOrBacktickedIdentifier        -> { alias: $1, location: @1 }
- | QuotedValue                          -> { alias: $1, location: @1 }
- | 'AS' RegularOrBacktickedIdentifier  -> { alias: $2, location: @2 }
- | 'AS' QuotedValue                    -> { alias: $2, location: @2 }
- ;
-
-OptionalCorrelationName_EDIT
- : PartialBacktickedIdentifier
- | QuotedValue_EDIT
- | 'AS' PartialBacktickedIdentifier
- | 'AS' QuotedValue_EDIT
- | 'AS' 'CURSOR'
- ;
-
-WindowExpression
- : '(' OptionalPartitionBy OptionalOrderByAndWindow ')'
- ;
-
-WindowExpression_EDIT
- : '(' PartitionBy_EDIT OptionalOrderByAndWindow RightParenthesisOrError
-   {
-     if (parser.yy.result.suggestFunctions) {
-       parser.suggestAggregateFunctions();
-     }
-   }
- | '(' OptionalPartitionBy OptionalOrderByAndWindow_EDIT RightParenthesisOrError
-   {
-     if (parser.yy.result.suggestFunctions) {
-       parser.suggestAggregateFunctions();
-     }
-   }
- | '(' AnyCursor OptionalPartitionBy OptionalOrderByAndWindow RightParenthesisOrError
-   {
-     if (!$3 && !$4) {
-       parser.suggestKeywords([{ value: 'PARTITION BY', weight: 2 }, { value: 'ORDER BY', weight: 1 }]);
-     } else if (!$3) {
-       parser.suggestKeywords(['PARTITION BY']);
-     }
-   }
- | '(' 'PARTITION' 'BY' ValueExpressionList 'CURSOR' OptionalOrderByAndWindow RightParenthesisOrError
-    {
-      if (!$6) {
-        parser.suggestValueExpressionKeywords($4, [{ value: 'ORDER BY', weight: 2 }]);
-      } else {
-        parser.suggestValueExpressionKeywords($4);
-      }
-    }
-  ;
-
-OptionalPartitionBy
- :
- | PartitionBy
- ;
-
-PartitionBy
- : 'PARTITION' 'BY' ValueExpressionList  -> $3
- ;
-
-PartitionBy_EDIT
- : 'PARTITION' 'CURSOR'
-   {
-     parser.suggestKeywords(['BY']);
-   }
- | 'PARTITION' 'BY' 'CURSOR'
-   {
-     parser.valueExpressionSuggest();
-   }
- | 'PARTITION' 'BY' ValueExpressionList_EDIT
- ;
-
-OptionalOrderByAndWindow
- :
- | OrderByClause OptionalWindowSpec
- ;
-
-OptionalOrderByAndWindow_EDIT
-  : OrderByClause_EDIT
-    {
-      // Only allowed in last order by
-      delete parser.yy.result.suggestAnalyticFunctions;
-    }
-  | OrderByClause 'CURSOR' OptionalWindowSpec
-    {
-      var keywords = [];
-      if ($1.suggestKeywords) {
-        keywords = parser.createWeightedKeywords($1.suggestKeywords, 2);
-      }
-      if (!$3) {
-        keywords = keywords.concat([{ value: 'RANGE BETWEEN', weight: 1 }, { value: 'ROWS BETWEEN', weight: 1 }]);
-      }
-      parser.suggestKeywords(keywords);
-    }
-  | OrderByClause WindowSpec_EDIT
-  ;
-
-OptionalWindowSpec
- :
- | WindowSpec
- ;
-
-WindowSpec
- : RowsOrRange 'BETWEEN' PopLexerState OptionalCurrentOrPreceding OptionalAndFollowing
- | RowsOrRange 'UNBOUNDED' PopLexerState OptionalCurrentOrPreceding OptionalAndFollowing
- ;
-
-WindowSpec_EDIT
- : RowsOrRange 'CURSOR'
-   {
-     parser.suggestKeywords(['BETWEEN']);
-   }
- | RowsOrRange 'BETWEEN' PopLexerState OptionalCurrentOrPreceding OptionalAndFollowing 'CURSOR'
-   {
-     if (!$4 && !$5) {
-       parser.suggestKeywords(['CURRENT ROW', 'UNBOUNDED PRECEDING']);
-     } else if (!$5) {
-       parser.suggestKeywords(['AND']);
-     }
-   }
- | RowsOrRange 'BETWEEN' PopLexerState OptionalCurrentOrPreceding_EDIT OptionalAndFollowing
- | RowsOrRange 'BETWEEN' PopLexerState OptionalCurrentOrPreceding OptionalAndFollowing_EDIT
- | RowsOrRange 'UNBOUNDED' PopLexerState OptionalCurrentOrPreceding 'CURSOR'
- | RowsOrRange 'UNBOUNDED' PopLexerState OptionalCurrentOrPreceding_EDIT
- ;
-
-PopLexerState
- :
-  {
-    lexer.popState();
-  }
- ;
-
-PushHdfsLexerState
- :
-  {
-    lexer.begin('hdfs');
-  }
- ;
-
-HdfsPath
- : 'HDFS_START_QUOTE' 'HDFS_PATH' 'HDFS_END_QUOTE'
- ;
-
-HdfsPath_EDIT
- : 'HDFS_START_QUOTE' 'HDFS_PATH' 'PARTIAL_CURSOR' 'HDFS_PATH' 'HDFS_END_QUOTE'
-    {
-      parser.suggestHdfs({ path: $2 });
-    }
- | 'HDFS_START_QUOTE' 'HDFS_PATH' 'PARTIAL_CURSOR' 'HDFS_END_QUOTE'
-   {
-     parser.suggestHdfs({ path: $2 });
-   }
- | 'HDFS_START_QUOTE' 'HDFS_PATH' 'PARTIAL_CURSOR'
-    {
-      parser.suggestHdfs({ path: $2 });
-    }
- | 'HDFS_START_QUOTE' 'PARTIAL_CURSOR' 'HDFS_END_QUOTE'
-   {
-     parser.suggestHdfs({ path: '' });
-   }
- | 'HDFS_START_QUOTE' 'PARTIAL_CURSOR'
-    {
-      parser.suggestHdfs({ path: '' });
-    }
- ;
-
-RowsOrRange
- : 'ROWS'
- | 'RANGE'
- ;
-
-OptionalCurrentOrPreceding
- :
- | IntegerOrUnbounded 'PRECEDING'
- | 'CURRENT' 'ROW'
- ;
-
-OptionalCurrentOrPreceding_EDIT
- : IntegerOrUnbounded 'CURSOR'
-   {
-     parser.suggestKeywords(['PRECEDING']);
-   }
- | 'CURRENT' 'CURSOR'
-   {
-     parser.suggestKeywords(['ROW']);
-   }
- ;
-
-OptionalAndFollowing
- :
- | 'AND' 'CURRENT' 'ROW'
- | 'AND' IntegerOrUnbounded 'FOLLOWING'
- ;
-
-OptionalAndFollowing_EDIT
- : 'AND' 'CURSOR'
-   {
-     parser.suggestKeywords(['CURRENT ROW', 'UNBOUNDED FOLLOWING']);
-   }
- | 'AND' 'CURRENT' 'CURSOR'
-   {
-     parser.suggestKeywords(['ROW']);
-   }
- | 'AND' IntegerOrUnbounded 'CURSOR'
-   {
-     parser.suggestKeywords(['FOLLOWING']);
-   }
- ;
-
-IntegerOrUnbounded
- : 'UNSIGNED_INTEGER'
- | 'UNBOUNDED'
- ;

+ 0 - 54
desktop/core/src/desktop/js/parse/jison/sql/generic2/structure.json

@@ -1,54 +0,0 @@
-{
-  "lexer": "../generic/sql.jisonlex",
-  "autocomplete": [
-    "../generic/autocomplete_header.jison",
-    "../generic/sql_alter.jison",
-    "../generic/sql_create.jison",
-    "../generic/sql_drop.jison",
-    "../generic/sql_error.jison",
-    "../generic/sql_insert.jison",
-    "sql_main.jison",
-    "select/cte_select_statement.jison",
-    "select/from_clause.jison",
-    "select/group_by_clause.jison",
-    "select/having_clause.jison",
-    "select/joins.jison",
-    "select/limit_clause.jison",
-    "select/order_by_clause.jison",
-    "select/select_conditions.jison",
-    "select/select_statement.jison",
-    "select/union_clause.jison",
-    "select/where_clause.jison",
-    "../generic/sql_set.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
-    "../generic/sql_valueExpression.jison",
-    "../generic/autocomplete_footer.jison"
-  ],
-  "syntax": [
-    "../generic/syntax_header.jison",
-    "../generic/sql_alter.jison",
-    "../generic/sql_create.jison",
-    "../generic/sql_drop.jison",
-    "../generic/sql_insert.jison",
-    "sql_main.jison",
-    "select/cte_select_statement.jison",
-    "select/from_clause.jison",
-    "select/group_by_clause.jison",
-    "select/having_clause.jison",
-    "select/joins.jison",
-    "select/limit_clause.jison",
-    "select/order_by_clause.jison",
-    "select/select_conditions.jison",
-    "select/select_statement.jison",
-    "select/union_clause.jison",
-    "select/where_clause.jison",
-    "../generic/sql_set.jison",
-    "../generic/sql_udf.jison",
-    "../generic/sql_update.jison",
-    "../generic/sql_use.jison",
-    "../generic/sql_valueExpression.jison",
-    "../generic/syntax_footer.jison"
-  ]
-}

+ 22 - 0
desktop/core/src/desktop/js/parse/jison/sql/ksql/structure.json

@@ -8,6 +8,17 @@
     "../generic/sql_insert.jison",
     "sql_list.jison",
     "../generic/sql_main.jison",
+    "../generic/select/cte_select_statement.jison",
+    "../generic/select/from_clause.jison",
+    "../generic/select/group_by_clause.jison",
+    "../generic/select/having_clause.jison",
+    "../generic/select/joins.jison",
+    "../generic/select/limit_clause.jison",
+    "../generic/select/order_by_clause.jison",
+    "../generic/select/select_conditions.jison",
+    "../generic/select/select_statement.jison",
+    "../generic/select/union_clause.jison",
+    "../generic/select/where_clause.jison",
     "../generic/sql_set.jison",
     "sql_show.jison",
     "../generic/sql_udf.jison",
@@ -21,6 +32,17 @@
     "../generic/sql_insert.jison",
     "sql_list.jison",
     "../generic/sql_main.jison",
+    "../generic/select/cte_select_statement.jison",
+    "../generic/select/from_clause.jison",
+    "../generic/select/group_by_clause.jison",
+    "../generic/select/having_clause.jison",
+    "../generic/select/joins.jison",
+    "../generic/select/limit_clause.jison",
+    "../generic/select/order_by_clause.jison",
+    "../generic/select/select_conditions.jison",
+    "../generic/select/select_statement.jison",
+    "../generic/select/union_clause.jison",
+    "../generic/select/where_clause.jison",
     "../generic/sql_set.jison",
     "sql_show.jison",
     "../generic/sql_udf.jison",

+ 22 - 0
desktop/core/src/desktop/js/parse/jison/sql/phoenix/structure.json

@@ -8,6 +8,17 @@
     "../generic/sql_error.jison",
     "../generic/sql_insert.jison",
     "../generic/sql_main.jison",
+    "../generic/select/cte_select_statement.jison",
+    "../generic/select/from_clause.jison",
+    "../generic/select/group_by_clause.jison",
+    "../generic/select/having_clause.jison",
+    "../generic/select/joins.jison",
+    "../generic/select/limit_clause.jison",
+    "../generic/select/order_by_clause.jison",
+    "../generic/select/select_conditions.jison",
+    "../generic/select/select_statement.jison",
+    "../generic/select/union_clause.jison",
+    "../generic/select/where_clause.jison",
     "../generic/sql_set.jison",
     "../generic/sql_udf.jison",
     "../generic/sql_update.jison",
@@ -22,6 +33,17 @@
     "../generic/sql_drop.jison",
     "../generic/sql_insert.jison",
     "../generic/sql_main.jison",
+    "../generic/select/cte_select_statement.jison",
+    "../generic/select/from_clause.jison",
+    "../generic/select/group_by_clause.jison",
+    "../generic/select/having_clause.jison",
+    "../generic/select/joins.jison",
+    "../generic/select/limit_clause.jison",
+    "../generic/select/order_by_clause.jison",
+    "../generic/select/select_conditions.jison",
+    "../generic/select/select_statement.jison",
+    "../generic/select/union_clause.jison",
+    "../generic/select/where_clause.jison",
     "../generic/sql_set.jison",
     "../generic/sql_udf.jison",
     "../generic/sql_update.jison",

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


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


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


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


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


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


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


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


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 91
desktop/core/src/desktop/js/parse/sql/generic2/generic2AutocompleteParser.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 91
desktop/core/src/desktop/js/parse/sql/generic2/generic2SyntaxParser.js


+ 0 - 1466
desktop/core/src/desktop/js/parse/sql/generic2/sqlParseSupport.js

@@ -1,1466 +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.
-
-import { matchesType } from 'sql/reference/typeUtils';
-import {
-  initSharedAutocomplete,
-  initSyntaxParser,
-  identifierEquals,
-  equalIgnoreCase,
-  SIMPLE_TABLE_REF_SUGGESTIONS
-} from 'parse/sql/sqlParseUtils';
-
-const initSqlParser = function (parser) {
-  initSharedAutocomplete(parser);
-
-  parser.prepareNewStatement = function () {
-    linkTablePrimaries();
-    parser.commitLocations();
-
-    delete parser.yy.latestCommonTableExpressions;
-    delete parser.yy.correlatedSubQuery;
-    parser.yy.subQueries = [];
-    parser.yy.selectListAliases = [];
-    parser.yy.latestTablePrimaries = [];
-
-    prioritizeSuggestions();
-  };
-
-  parser.yy.parseError = function (message, error) {
-    parser.yy.errors.push(error);
-    return message;
-  };
-
-  parser.addCommonTableExpressions = function (identifiers) {
-    parser.yy.result.commonTableExpressions = identifiers;
-    parser.yy.latestCommonTableExpressions = identifiers;
-  };
-
-  parser.isInSubquery = function () {
-    return !!parser.yy.primariesStack.length;
-  };
-
-  parser.pushQueryState = function () {
-    parser.yy.resultStack.push(parser.yy.result);
-    parser.yy.locationsStack.push(parser.yy.locations);
-    parser.yy.selectListAliasesStack.push(parser.yy.selectListAliases);
-    parser.yy.primariesStack.push(parser.yy.latestTablePrimaries);
-    parser.yy.subQueriesStack.push(parser.yy.subQueries);
-
-    parser.yy.result = {};
-    parser.yy.locations = [];
-    parser.yy.selectListAliases = []; // Not allowed in correlated sub-queries
-
-    if (parser.yy.correlatedSubQuery) {
-      parser.yy.latestTablePrimaries = parser.yy.latestTablePrimaries.concat();
-      parser.yy.subQueries = parser.yy.subQueries.concat();
-    } else {
-      parser.yy.latestTablePrimaries = [];
-      parser.yy.subQueries = [];
-    }
-  };
-
-  parser.popQueryState = function (subQuery) {
-    linkTablePrimaries();
-    parser.commitLocations();
-
-    if (Object.keys(parser.yy.result).length === 0) {
-      parser.yy.result = parser.yy.resultStack.pop();
-    } else {
-      parser.yy.resultStack.pop();
-    }
-    const oldSubQueries = parser.yy.subQueries;
-    parser.yy.subQueries = parser.yy.subQueriesStack.pop();
-    if (subQuery) {
-      if (oldSubQueries.length > 0) {
-        subQuery.subQueries = oldSubQueries;
-      }
-      parser.yy.subQueries.push(subQuery);
-    }
-
-    parser.yy.latestTablePrimaries = parser.yy.primariesStack.pop();
-    parser.yy.locations = parser.yy.locationsStack.pop();
-    parser.yy.selectListAliases = parser.yy.selectListAliasesStack.pop();
-  };
-
-  parser.suggestSelectListAliases = function () {
-    if (
-      parser.yy.selectListAliases &&
-      parser.yy.selectListAliases.length > 0 &&
-      parser.yy.result.suggestColumns &&
-      (typeof parser.yy.result.suggestColumns.identifierChain === 'undefined' ||
-        parser.yy.result.suggestColumns.identifierChain.length === 0)
-    ) {
-      parser.yy.result.suggestColumnAliases = parser.yy.selectListAliases;
-    }
-  };
-
-  parser.mergeSuggestKeywords = function () {
-    let result = [];
-    Array.prototype.slice.call(arguments).forEach(suggestion => {
-      if (typeof suggestion !== 'undefined' && typeof suggestion.suggestKeywords !== 'undefined') {
-        result = result.concat(suggestion.suggestKeywords);
-      }
-    });
-    if (result.length > 0) {
-      return { suggestKeywords: result };
-    }
-    return {};
-  };
-
-  parser.suggestValueExpressionKeywords = function (valueExpression, extras) {
-    const expressionKeywords = parser.getValueExpressionKeywords(valueExpression, extras);
-    parser.suggestKeywords(expressionKeywords.suggestKeywords);
-    if (expressionKeywords.suggestColRefKeywords) {
-      parser.suggestColRefKeywords(expressionKeywords.suggestColRefKeywords);
-    }
-    if (valueExpression.lastType) {
-      parser.addColRefIfExists(valueExpression.lastType);
-    } else {
-      parser.addColRefIfExists(valueExpression);
-    }
-  };
-
-  parser.getSelectListKeywords = function (excludeAsterisk) {
-    const keywords = [{ value: 'CASE', weight: 450 }, 'FALSE', 'TRUE', 'NULL'];
-    if (!excludeAsterisk) {
-      keywords.push({ value: '*', weight: 10000 });
-    }
-    return keywords;
-  };
-
-  parser.getValueExpressionKeywords = function (valueExpression, extras) {
-    const types = valueExpression.lastType ? valueExpression.lastType.types : valueExpression.types;
-    // We could have valueExpression.columnReference to suggest based on column type
-    let keywords = [
-      '<',
-      '<=',
-      '<=>',
-      '<>',
-      '=',
-      '>',
-      '>=',
-      'BETWEEN',
-      'IN',
-      'IS NOT NULL',
-      'IS NULL',
-      'IS NOT TRUE',
-      'IS TRUE',
-      'IS NOT FALSE',
-      'IS FALSE',
-      'NOT BETWEEN',
-      'NOT IN'
-    ];
-    if (extras) {
-      keywords = keywords.concat(extras);
-    }
-    if (valueExpression.suggestKeywords) {
-      keywords = keywords.concat(valueExpression.suggestKeywords);
-    }
-    if (types.length === 1 && types[0] === 'COLREF') {
-      return {
-        suggestKeywords: keywords,
-        suggestColRefKeywords: {
-          BOOLEAN: ['AND', 'OR'],
-          NUMBER: ['+', '-', '*', '/', '%', 'DIV'],
-          STRING: ['LIKE', 'NOT LIKE', 'REGEXP', 'RLIKE']
-        }
-      };
-    }
-    if (matchesType(parser.yy.activeDialect, ['BOOLEAN'], types)) {
-      keywords = keywords.concat(['AND', 'OR']);
-    }
-    if (matchesType(parser.yy.activeDialect, ['NUMBER'], types)) {
-      keywords = keywords.concat(['+', '-', '*', '/', '%', 'DIV']);
-    }
-    if (matchesType(parser.yy.activeDialect, ['STRING'], types)) {
-      keywords = keywords.concat(['LIKE', 'NOT LIKE', 'REGEXP', 'RLIKE']);
-    }
-    return { suggestKeywords: keywords };
-  };
-
-  parser.getTypeKeywords = function () {
-    return [
-      'BIGINT',
-      'BOOLEAN',
-      'CHAR',
-      'DECIMAL',
-      'DOUBLE',
-      'FLOAT',
-      'INT',
-      'SMALLINT',
-      'TIMESTAMP',
-      'STRING',
-      'TINYINT',
-      'VARCHAR'
-    ];
-  };
-
-  parser.getColumnDataTypeKeywords = function () {
-    return parser.getTypeKeywords();
-  };
-
-  parser.addColRefIfExists = function (valueExpression) {
-    if (valueExpression.columnReference) {
-      parser.yy.result.colRef = { identifierChain: valueExpression.columnReference };
-    }
-  };
-
-  parser.selectListNoTableSuggest = function (selectListEdit, hasDistinctOrAll) {
-    if (selectListEdit.cursorAtStart) {
-      let keywords = parser.getSelectListKeywords();
-      if (!hasDistinctOrAll) {
-        keywords = keywords.concat([
-          { value: 'ALL', weight: 2 },
-          { value: 'DISTINCT', weight: 2 }
-        ]);
-      }
-      parser.suggestKeywords(keywords);
-    } else {
-      parser.checkForKeywords(selectListEdit);
-    }
-    if (selectListEdit.suggestFunctions) {
-      parser.suggestFunctions();
-    }
-    if (selectListEdit.suggestColumns) {
-      parser.suggestColumns();
-    }
-    if (
-      selectListEdit.suggestAggregateFunctions &&
-      (!hasDistinctOrAll || hasDistinctOrAll === 'ALL')
-    ) {
-      parser.suggestAggregateFunctions();
-      parser.suggestAnalyticFunctions();
-    }
-  };
-
-  parser.suggestJoinConditions = function (details) {
-    parser.yy.result.suggestJoinConditions = details || {};
-    if (parser.yy.latestTablePrimaries && !parser.yy.result.suggestJoinConditions.tablePrimaries) {
-      parser.yy.result.suggestJoinConditions.tablePrimaries = parser.yy.latestTablePrimaries.concat();
-    }
-  };
-
-  parser.suggestJoins = function (details) {
-    parser.yy.result.suggestJoins = details || {};
-  };
-
-  parser.findCaseType = function (whenThenList) {
-    const types = {};
-    whenThenList.caseTypes.forEach(valueExpression => {
-      valueExpression.types.forEach(type => {
-        types[type] = true;
-      });
-    });
-    if (Object.keys(types).length === 1) {
-      return { types: [Object.keys(types)[0]] };
-    }
-    return { types: ['T'] };
-  };
-
-  parser.applyArgumentTypesToSuggestions = function (functionName, position) {
-    if (parser.yy.result.suggestFunctions || parser.yy.result.suggestColumns) {
-      parser.yy.result.udfArgument = {
-        name: functionName.toLowerCase(),
-        position: position
-      };
-    }
-  };
-
-  parser.commitLocations = function () {
-    if (parser.yy.locations.length === 0) {
-      return;
-    }
-
-    const tablePrimaries = parser.yy.latestTablePrimaries;
-
-    let i = parser.yy.locations.length;
-
-    while (i--) {
-      const location = parser.yy.locations[i];
-      if (location.type === 'variable' && location.colRef) {
-        parser.expandIdentifierChain({
-          wrapper: location.colRef,
-          tablePrimaries: tablePrimaries,
-          isColumnWrapper: true
-        });
-        delete location.colRef.linked;
-      }
-
-      if (location.type === 'unknown') {
-        if (
-          typeof location.identifierChain !== 'undefined' &&
-          location.identifierChain.length > 0 &&
-          location.identifierChain.length <= 2 &&
-          tablePrimaries
-        ) {
-          let found = tablePrimaries.filter(primary => {
-            return (
-              equalIgnoreCase(primary.alias, location.identifierChain[0].name) ||
-              (primary.identifierChain &&
-                equalIgnoreCase(primary.identifierChain[0].name, location.identifierChain[0].name))
-            );
-          });
-          if (!found.length && location.firstInChain) {
-            found = tablePrimaries.filter(primary => {
-              return (
-                !primary.alias &&
-                primary.identifierChain &&
-                equalIgnoreCase(
-                  primary.identifierChain[primary.identifierChain.length - 1].name,
-                  location.identifierChain[0].name
-                )
-              );
-            });
-          }
-
-          if (found.length) {
-            if (
-              found[0].identifierChain.length > 1 &&
-              location.identifierChain.length === 1 &&
-              equalIgnoreCase(found[0].identifierChain[0].name, location.identifierChain[0].name)
-            ) {
-              location.type = 'database';
-            } else if (
-              found[0].alias &&
-              equalIgnoreCase(location.identifierChain[0].name, found[0].alias) &&
-              location.identifierChain.length > 1
-            ) {
-              location.type = 'column';
-              parser.expandIdentifierChain({
-                tablePrimaries: tablePrimaries,
-                wrapper: location,
-                anyOwner: true
-              });
-            } else if (
-              !found[0].alias &&
-              found[0].identifierChain &&
-              equalIgnoreCase(
-                location.identifierChain[0].name,
-                found[0].identifierChain[found[0].identifierChain.length - 1].name
-              ) &&
-              location.identifierChain.length > 1
-            ) {
-              location.type = 'column';
-              parser.expandIdentifierChain({
-                tablePrimaries: tablePrimaries,
-                wrapper: location,
-                anyOwner: true
-              });
-            } else {
-              location.type = 'table';
-              parser.expandIdentifierChain({
-                tablePrimaries: tablePrimaries,
-                wrapper: location,
-                anyOwner: true
-              });
-            }
-          } else if (parser.yy.subQueries) {
-            found = parser.yy.subQueries.filter(subQuery => {
-              return equalIgnoreCase(subQuery.alias, location.identifierChain[0].name);
-            });
-            if (found.length > 0) {
-              location.type = 'subQuery';
-              location.identifierChain = [{ subQuery: found[0].alias }];
-            }
-          }
-        }
-      }
-
-      if (location.type === 'asterisk' && !location.linked) {
-        if (tablePrimaries && tablePrimaries.length > 0) {
-          location.tables = [];
-          location.linked = false;
-          if (!location.identifierChain) {
-            location.identifierChain = [{ asterisk: true }];
-          }
-          parser.expandIdentifierChain({
-            tablePrimaries: tablePrimaries,
-            wrapper: location,
-            anyOwner: false
-          });
-          if (location.tables.length === 0) {
-            parser.yy.locations.splice(i, 1);
-          }
-        } else {
-          parser.yy.locations.splice(i, 1);
-        }
-      }
-
-      if (
-        location.type === 'table' &&
-        typeof location.identifierChain !== 'undefined' &&
-        location.identifierChain.length === 1 &&
-        location.identifierChain[0].name
-      ) {
-        // Could be a cte reference
-        parser.yy.locations.some(otherLocation => {
-          if (
-            otherLocation.type === 'alias' &&
-            otherLocation.source === 'cte' &&
-            identifierEquals(otherLocation.alias, location.identifierChain[0].name)
-          ) {
-            // TODO: Possibly add the other location if we want to show the link in the future.
-            //       i.e. highlight select definition on hover over alias, also for subquery references.
-            location.type = 'alias';
-            location.target = 'cte';
-            location.alias = location.identifierChain[0].name;
-            delete location.identifierChain;
-            return true;
-          }
-        });
-      }
-
-      if (
-        location.type === 'table' &&
-        (typeof location.identifierChain === 'undefined' || location.identifierChain.length === 0)
-      ) {
-        parser.yy.locations.splice(i, 1);
-      }
-
-      if (location.type === 'unknown') {
-        location.type = 'column';
-      }
-
-      // A column location might refer to a previously defined alias, i.e. last 'foo' in "SELECT cast(id AS int) foo FROM tbl ORDER BY foo;"
-      if (location.type === 'column') {
-        for (let j = i - 1; j >= 0; j--) {
-          const otherLocation = parser.yy.locations[j];
-          if (
-            otherLocation.type === 'alias' &&
-            otherLocation.source === 'column' &&
-            location.identifierChain &&
-            location.identifierChain.length === 1 &&
-            location.identifierChain[0].name &&
-            otherLocation.alias &&
-            location.identifierChain[0].name.toLowerCase() === otherLocation.alias.toLowerCase()
-          ) {
-            location.type = 'alias';
-            location.source = 'column';
-            location.alias = location.identifierChain[0].name;
-            delete location.identifierChain;
-            location.parentLocation = otherLocation.parentLocation;
-            break;
-          }
-        }
-      }
-
-      if (location.type === 'column') {
-        const initialIdentifierChain = location.identifierChain
-          ? location.identifierChain.concat()
-          : undefined;
-
-        parser.expandIdentifierChain({
-          tablePrimaries: tablePrimaries,
-          wrapper: location,
-          anyOwner: true,
-          isColumnWrapper: true,
-          isColumnLocation: true
-        });
-
-        if (typeof location.identifierChain === 'undefined') {
-          parser.yy.locations.splice(i, 1);
-        } else if (
-          location.identifierChain.length === 0 &&
-          initialIdentifierChain &&
-          initialIdentifierChain.length === 1
-        ) {
-          // This is for the case "SELECT tblOrColName FROM db.tblOrColName";
-          location.identifierChain = initialIdentifierChain;
-        }
-      }
-      if (location.type === 'column' && location.identifierChain) {
-        if (location.identifierChain.length > 1 && location.tables && location.tables.length > 0) {
-          location.type = 'complex';
-        }
-      }
-      delete location.firstInChain;
-      if (location.type !== 'column' && location.type !== 'complex') {
-        delete location.qualified;
-      } else if (typeof location.qualified === 'undefined') {
-        location.qualified = false;
-      }
-    }
-
-    if (parser.yy.locations.length > 0) {
-      parser.yy.allLocations = parser.yy.allLocations.concat(parser.yy.locations);
-      parser.yy.locations = [];
-    }
-  };
-
-  const prioritizeSuggestions = function () {
-    parser.yy.result.lowerCase = parser.yy.lowerCase || false;
-
-    const cteIndex = {};
-
-    if (typeof parser.yy.latestCommonTableExpressions !== 'undefined') {
-      parser.yy.latestCommonTableExpressions.forEach(cte => {
-        cteIndex[cte.alias.toLowerCase()] = cte;
-      });
-    }
-
-    SIMPLE_TABLE_REF_SUGGESTIONS.forEach(suggestionType => {
-      if (
-        suggestionType !== 'suggestAggregateFunctions' &&
-        typeof parser.yy.result[suggestionType] !== 'undefined' &&
-        parser.yy.result[suggestionType].tables.length === 0
-      ) {
-        delete parser.yy.result[suggestionType];
-      } else if (
-        typeof parser.yy.result[suggestionType] !== 'undefined' &&
-        typeof parser.yy.result[suggestionType].tables !== 'undefined'
-      ) {
-        for (let i = parser.yy.result[suggestionType].tables.length - 1; i >= 0; i--) {
-          const table = parser.yy.result[suggestionType].tables[i];
-          if (
-            table.identifierChain.length === 1 &&
-            typeof table.identifierChain[0].name !== 'undefined' &&
-            typeof cteIndex[table.identifierChain[0].name.toLowerCase()] !== 'undefined'
-          ) {
-            parser.yy.result[suggestionType].tables.splice(i, 1);
-          }
-        }
-      }
-    });
-
-    if (typeof parser.yy.result.colRef !== 'undefined') {
-      if (
-        !parser.yy.result.colRef.linked ||
-        typeof parser.yy.result.colRef.identifierChain === 'undefined' ||
-        parser.yy.result.colRef.identifierChain.length === 0
-      ) {
-        delete parser.yy.result.colRef;
-        if (typeof parser.yy.result.suggestColRefKeywords !== 'undefined') {
-          Object.keys(parser.yy.result.suggestColRefKeywords).forEach(type => {
-            parser.yy.result.suggestKeywords = parser.yy.result.suggestKeywords.concat(
-              parser.createWeightedKeywords(parser.yy.result.suggestColRefKeywords[type], -1)
-            );
-          });
-          delete parser.yy.result.suggestColRefKeywords;
-        }
-        if (
-          parser.yy.result.suggestColumns &&
-          parser.yy.result.suggestColumns.types.length === 1 &&
-          parser.yy.result.suggestColumns.types[0] === 'COLREF'
-        ) {
-          parser.yy.result.suggestColumns.types = ['T'];
-        }
-        delete parser.yy.result.suggestValues;
-      }
-    }
-
-    if (typeof parser.yy.result.colRef !== 'undefined') {
-      if (
-        !parser.yy.result.suggestValues &&
-        !parser.yy.result.suggestColRefKeywords &&
-        (!parser.yy.result.suggestColumns || parser.yy.result.suggestColumns.types[0] !== 'COLREF')
-      ) {
-        delete parser.yy.result.colRef;
-      }
-    }
-    if (
-      typeof parser.yy.result.suggestIdentifiers !== 'undefined' &&
-      parser.yy.result.suggestIdentifiers.length > 0
-    ) {
-      delete parser.yy.result.suggestTables;
-      delete parser.yy.result.suggestDatabases;
-    }
-    if (typeof parser.yy.result.suggestColumns !== 'undefined') {
-      const suggestColumns = parser.yy.result.suggestColumns;
-      if (typeof suggestColumns.tables === 'undefined' || suggestColumns.tables.length === 0) {
-        delete parser.yy.result.suggestColumns;
-        delete parser.yy.result.subQueries;
-      } else {
-        delete parser.yy.result.suggestTables;
-        delete parser.yy.result.suggestDatabases;
-
-        suggestColumns.tables.forEach(table => {
-          if (
-            typeof table.identifierChain !== 'undefined' &&
-            table.identifierChain.length === 1 &&
-            typeof table.identifierChain[0].name !== 'undefined'
-          ) {
-            const cte = cteIndex[table.identifierChain[0].name.toLowerCase()];
-            if (typeof cte !== 'undefined') {
-              delete table.identifierChain[0].name;
-              table.identifierChain[0].cte = cte.alias;
-            }
-          } else if (typeof table.identifierChain === 'undefined' && table.subQuery) {
-            table.identifierChain = [{ subQuery: table.subQuery }];
-            delete table.subQuery;
-          }
-        });
-
-        if (
-          typeof suggestColumns.identifierChain !== 'undefined' &&
-          suggestColumns.identifierChain.length === 0
-        ) {
-          delete suggestColumns.identifierChain;
-        }
-      }
-    } else {
-      delete parser.yy.result.subQueries;
-    }
-
-    if (typeof parser.yy.result.suggestJoinConditions !== 'undefined') {
-      if (
-        typeof parser.yy.result.suggestJoinConditions.tables === 'undefined' ||
-        parser.yy.result.suggestJoinConditions.tables.length === 0
-      ) {
-        delete parser.yy.result.suggestJoinConditions;
-      }
-    }
-
-    if (
-      typeof parser.yy.result.suggestTables !== 'undefined' &&
-      typeof parser.yy.result.commonTableExpressions !== 'undefined'
-    ) {
-      const ctes = [];
-      parser.yy.result.commonTableExpressions.forEach(cte => {
-        const suggestion = { name: cte.alias };
-        if (parser.yy.result.suggestTables.prependFrom) {
-          suggestion.prependFrom = true;
-        }
-        if (parser.yy.result.suggestTables.prependQuestionMark) {
-          suggestion.prependQuestionMark = true;
-        }
-        ctes.push(suggestion);
-      });
-      if (ctes.length > 0) {
-        parser.yy.result.suggestCommonTableExpressions = ctes;
-      }
-    }
-  };
-
-  parser.identifyPartials = function (beforeCursor, afterCursor) {
-    const beforeMatch = beforeCursor.match(/[0-9a-zA-Z_]*$/);
-    const afterMatch = afterCursor.match(/^[0-9a-zA-Z_]*(?:\((?:[^)]*\))?)?/);
-    return {
-      left: beforeMatch ? beforeMatch[0].length : 0,
-      right: afterMatch ? afterMatch[0].length : 0
-    };
-  };
-
-  const addCleanTablePrimary = function (tables, tablePrimary) {
-    if (tablePrimary.alias) {
-      tables.push({ alias: tablePrimary.alias, identifierChain: tablePrimary.identifierChain });
-    } else {
-      tables.push({ identifierChain: tablePrimary.identifierChain });
-    }
-  };
-
-  parser.expandIdentifierChain = function (options) {
-    const wrapper = options.wrapper;
-    const anyOwner = options.anyOwner;
-    const isColumnWrapper = options.isColumnWrapper;
-    const isColumnLocation = options.isColumnLocation;
-    let tablePrimaries = options.tablePrimaries || parser.yy.latestTablePrimaries;
-
-    if (typeof wrapper.identifierChain === 'undefined' || typeof tablePrimaries === 'undefined') {
-      return;
-    }
-    let identifierChain = wrapper.identifierChain.concat();
-
-    if (tablePrimaries.length === 0) {
-      delete wrapper.identifierChain;
-      return;
-    }
-
-    if (!anyOwner) {
-      tablePrimaries = filterTablePrimariesForOwner(tablePrimaries, wrapper.owner);
-    }
-
-    if (identifierChain.length > 0 && identifierChain[identifierChain.length - 1].asterisk) {
-      const tables = [];
-      tablePrimaries.forEach(tablePrimary => {
-        if (identifierChain.length > 1 && !tablePrimary.subQueryAlias) {
-          if (
-            identifierChain.length === 2 &&
-            equalIgnoreCase(tablePrimary.alias, identifierChain[0].name)
-          ) {
-            addCleanTablePrimary(tables, tablePrimary);
-          } else if (
-            identifierChain.length === 2 &&
-            equalIgnoreCase(tablePrimary.identifierChain[0].name, identifierChain[0].name)
-          ) {
-            addCleanTablePrimary(tables, tablePrimary);
-          } else if (
-            identifierChain.length === 3 &&
-            tablePrimary.identifierChain.length > 1 &&
-            equalIgnoreCase(tablePrimary.identifierChain[0].name, identifierChain[0].name) &&
-            equalIgnoreCase(tablePrimary.identifierChain[1].name, identifierChain[1].name)
-          ) {
-            addCleanTablePrimary(tables, tablePrimary);
-          }
-        } else if (tablePrimary.subQueryAlias) {
-          tables.push({ identifierChain: [{ subQuery: tablePrimary.subQueryAlias }] });
-        } else {
-          addCleanTablePrimary(tables, tablePrimary);
-        }
-      });
-      // Possible Joins
-      if (tables.length > 0) {
-        wrapper.tables = tables;
-        delete wrapper.identifierChain;
-        return;
-      }
-    }
-
-    // IdentifierChain contains a possibly started identifier or empty, example: a.b.c = ['a', 'b', 'c']
-    // Reduce the tablePrimaries to the one that matches the first identifier if found
-    let foundPrimary;
-    let doubleMatch = false;
-    let aliasMatch = false;
-    if (identifierChain.length > 0) {
-      for (let i = 0; i < tablePrimaries.length; i++) {
-        if (tablePrimaries[i].subQueryAlias) {
-          if (equalIgnoreCase(tablePrimaries[i].subQueryAlias, identifierChain[0].name)) {
-            foundPrimary = tablePrimaries[i];
-          }
-        } else if (equalIgnoreCase(tablePrimaries[i].alias, identifierChain[0].name)) {
-          foundPrimary = tablePrimaries[i];
-          aliasMatch = true;
-          break;
-        } else if (
-          tablePrimaries[i].identifierChain.length > 1 &&
-          identifierChain.length > 1 &&
-          equalIgnoreCase(tablePrimaries[i].identifierChain[0].name, identifierChain[0].name) &&
-          equalIgnoreCase(tablePrimaries[i].identifierChain[1].name, identifierChain[1].name)
-        ) {
-          foundPrimary = tablePrimaries[i];
-          doubleMatch = true;
-          break;
-        } else if (
-          !foundPrimary &&
-          equalIgnoreCase(tablePrimaries[i].identifierChain[0].name, identifierChain[0].name) &&
-          identifierChain.length > (isColumnLocation ? 1 : 0)
-        ) {
-          foundPrimary = tablePrimaries[i];
-          // No break as first two can still match.
-        } else if (
-          !foundPrimary &&
-          tablePrimaries[i].identifierChain.length > 1 &&
-          !tablePrimaries[i].alias &&
-          equalIgnoreCase(
-            tablePrimaries[i].identifierChain[tablePrimaries[i].identifierChain.length - 1].name,
-            identifierChain[0].name
-          )
-        ) {
-          // This is for the case SELECT baa. FROM bla.baa, blo.boo;
-          foundPrimary = tablePrimaries[i];
-          break;
-        }
-      }
-    }
-
-    if (foundPrimary) {
-      identifierChain.shift();
-      if (doubleMatch) {
-        identifierChain.shift();
-      }
-    } else if (tablePrimaries.length === 1 && !isColumnWrapper) {
-      foundPrimary = tablePrimaries[0];
-    }
-
-    if (foundPrimary) {
-      if (isColumnWrapper) {
-        wrapper.identifierChain = identifierChain;
-        if (foundPrimary.subQueryAlias) {
-          wrapper.tables = [{ subQuery: foundPrimary.subQueryAlias }];
-        } else if (foundPrimary.alias) {
-          if (!isColumnLocation && isColumnWrapper && aliasMatch) {
-            // TODO: add alias on table in suggestColumns (needs support in sqlAutocomplete3.js)
-            // the case is: SELECT cu.| FROM customers cu;
-            // This prevents alias from being added automatically in sqlAutocompleter.js
-            wrapper.tables = [{ identifierChain: foundPrimary.identifierChain }];
-          } else {
-            wrapper.tables = [
-              { identifierChain: foundPrimary.identifierChain, alias: foundPrimary.alias }
-            ];
-          }
-        } else {
-          wrapper.tables = [{ identifierChain: foundPrimary.identifierChain }];
-        }
-      } else {
-        if (foundPrimary.subQueryAlias) {
-          identifierChain.unshift({ subQuery: foundPrimary.subQueryAlias });
-        } else {
-          identifierChain = foundPrimary.identifierChain.concat(identifierChain);
-        }
-        if (wrapper.tables) {
-          wrapper.tables.push({ identifierChain: identifierChain });
-          delete wrapper.identifierChain;
-        } else {
-          wrapper.identifierChain = identifierChain;
-        }
-      }
-    } else {
-      if (isColumnWrapper) {
-        wrapper.tables = [];
-      }
-      tablePrimaries.forEach(tablePrimary => {
-        const targetTable = tablePrimary.subQueryAlias
-          ? { subQuery: tablePrimary.subQueryAlias }
-          : { identifierChain: tablePrimary.identifierChain };
-        if (tablePrimary.alias) {
-          targetTable.alias = tablePrimary.alias;
-        }
-        if (wrapper.tables) {
-          wrapper.tables.push(targetTable);
-        }
-      });
-    }
-    delete wrapper.owner;
-    wrapper.linked = true;
-  };
-
-  const filterTablePrimariesForOwner = function (tablePrimaries, owner) {
-    const result = [];
-    tablePrimaries.forEach(primary => {
-      if (typeof owner === 'undefined' && typeof primary.owner === 'undefined') {
-        result.push(primary);
-      } else if (owner === primary.owner) {
-        result.push(primary);
-      }
-    });
-    return result;
-  };
-
-  const convertTablePrimariesToSuggestions = function (tablePrimaries) {
-    const tables = [];
-    const identifiers = [];
-    tablePrimaries.forEach(tablePrimary => {
-      if (tablePrimary.identifierChain && tablePrimary.identifierChain.length > 0) {
-        const table = { identifierChain: tablePrimary.identifierChain };
-        if (tablePrimary.alias) {
-          table.alias = tablePrimary.alias;
-          identifiers.push({ name: table.alias + '.', type: 'alias' });
-        } else {
-          const lastIdentifier =
-            tablePrimary.identifierChain[tablePrimary.identifierChain.length - 1];
-          if (typeof lastIdentifier.name !== 'undefined') {
-            identifiers.push({ name: lastIdentifier.name + '.', type: 'table' });
-          } else if (typeof lastIdentifier.subQuery !== 'undefined') {
-            identifiers.push({ name: lastIdentifier.subQuery + '.', type: 'sub-query' });
-          }
-        }
-        tables.push(table);
-      } else if (tablePrimary.subQueryAlias) {
-        identifiers.push({ name: tablePrimary.subQueryAlias + '.', type: 'sub-query' });
-        tables.push({ identifierChain: [{ subQuery: tablePrimary.subQueryAlias }] });
-      }
-    });
-    if (identifiers.length > 0) {
-      if (typeof parser.yy.result.suggestIdentifiers === 'undefined') {
-        parser.yy.result.suggestIdentifiers = identifiers;
-      } else {
-        parser.yy.result.suggestIdentifiers = identifiers.concat(
-          parser.yy.result.suggestIdentifiers
-        );
-      }
-    }
-    parser.yy.result.suggestColumns.tables = tables;
-    if (
-      parser.yy.result.suggestColumns.identifierChain &&
-      parser.yy.result.suggestColumns.identifierChain.length === 0
-    ) {
-      delete parser.yy.result.suggestColumns.identifierChain;
-    }
-    parser.yy.result.suggestColumns.linked = true;
-  };
-
-  const linkTablePrimaries = function () {
-    if (!parser.yy.cursorFound || typeof parser.yy.latestTablePrimaries === 'undefined') {
-      return;
-    }
-
-    SIMPLE_TABLE_REF_SUGGESTIONS.forEach(suggestionType => {
-      if (
-        typeof parser.yy.result[suggestionType] !== 'undefined' &&
-        parser.yy.result[suggestionType].tablePrimaries &&
-        !parser.yy.result[suggestionType].linked
-      ) {
-        parser.yy.result[suggestionType].tables = [];
-        parser.yy.result[suggestionType].tablePrimaries.forEach(tablePrimary => {
-          if (!tablePrimary.subQueryAlias) {
-            parser.yy.result[suggestionType].tables.push(
-              tablePrimary.alias
-                ? {
-                    identifierChain: tablePrimary.identifierChain.concat(),
-                    alias: tablePrimary.alias
-                  }
-                : { identifierChain: tablePrimary.identifierChain.concat() }
-            );
-          }
-        });
-        delete parser.yy.result[suggestionType].tablePrimaries;
-        parser.yy.result[suggestionType].linked = true;
-      }
-    });
-
-    if (
-      typeof parser.yy.result.suggestColumns !== 'undefined' &&
-      !parser.yy.result.suggestColumns.linked
-    ) {
-      const tablePrimaries = filterTablePrimariesForOwner(
-        parser.yy.latestTablePrimaries,
-        parser.yy.result.suggestColumns.owner
-      );
-      if (!parser.yy.result.suggestColumns.tables) {
-        parser.yy.result.suggestColumns.tables = [];
-      }
-      if (parser.yy.subQueries.length > 0) {
-        parser.yy.result.subQueries = parser.yy.subQueries;
-      }
-      if (
-        typeof parser.yy.result.suggestColumns.identifierChain === 'undefined' ||
-        parser.yy.result.suggestColumns.identifierChain.length === 0
-      ) {
-        if (tablePrimaries.length > 1) {
-          convertTablePrimariesToSuggestions(tablePrimaries);
-        } else {
-          if (
-            tablePrimaries.length === 1 &&
-            (tablePrimaries[0].alias || tablePrimaries[0].subQueryAlias)
-          ) {
-            convertTablePrimariesToSuggestions(tablePrimaries);
-          }
-          parser.expandIdentifierChain({
-            wrapper: parser.yy.result.suggestColumns,
-            anyOwner: false,
-            isColumnWrapper: true
-          });
-        }
-      } else {
-        parser.expandIdentifierChain({
-          wrapper: parser.yy.result.suggestColumns,
-          anyOwner: false,
-          isColumnWrapper: true
-        });
-      }
-    }
-
-    if (typeof parser.yy.result.colRef !== 'undefined' && !parser.yy.result.colRef.linked) {
-      parser.expandIdentifierChain({ wrapper: parser.yy.result.colRef });
-
-      const primaries = filterTablePrimariesForOwner(parser.yy.latestTablePrimaries);
-      if (
-        primaries.length === 0 ||
-        (primaries.length > 1 && parser.yy.result.colRef.identifierChain.length === 1)
-      ) {
-        parser.yy.result.colRef.identifierChain = [];
-      }
-    }
-    if (
-      typeof parser.yy.result.suggestKeyValues !== 'undefined' &&
-      !parser.yy.result.suggestKeyValues.linked
-    ) {
-      parser.expandIdentifierChain({ wrapper: parser.yy.result.suggestKeyValues });
-    }
-  };
-
-  parser.addTablePrimary = function (ref) {
-    if (typeof parser.yy.latestTablePrimaries === 'undefined') {
-      parser.yy.latestTablePrimaries = [];
-    }
-    parser.yy.latestTablePrimaries.push(ref);
-  };
-
-  parser.suggestFileFormats = function () {
-    parser.suggestKeywords([
-      'AVRO',
-      'KUDU',
-      'ORC',
-      'PARQUET',
-      'RCFILE',
-      'SEQUENCEFILE',
-      'TEXTFILE'
-    ]);
-  };
-
-  parser.getKeywordsForOptionalsLR = function (optionals, keywords, override) {
-    let result = [];
-
-    for (let i = 0; i < optionals.length; i++) {
-      if (!optionals[i] && (typeof override === 'undefined' || override[i])) {
-        if (keywords[i] instanceof Array) {
-          result = result.concat(keywords[i]);
-        } else {
-          result.push(keywords[i]);
-        }
-      } else if (optionals[i]) {
-        break;
-      }
-    }
-    return result;
-  };
-
-  parser.suggestDdlAndDmlKeywords = function (extraKeywords) {
-    let keywords = [
-      'ALTER',
-      'CREATE',
-      'DESCRIBE',
-      'DROP',
-      'GRANT',
-      'INSERT',
-      'REVOKE',
-      'SELECT',
-      'SET',
-      'SHOW',
-      'TRUNCATE',
-      'UPDATE',
-      'USE',
-      'WITH'
-    ];
-
-    if (extraKeywords) {
-      keywords = keywords.concat(extraKeywords);
-    }
-
-    parser.suggestKeywords(keywords);
-  };
-
-  parser.checkForSelectListKeywords = function (selectList) {
-    if (selectList.length === 0) {
-      return;
-    }
-    const last = selectList[selectList.length - 1];
-    if (!last || !last.valueExpression) {
-      return;
-    }
-    const valueExpressionKeywords = parser.getValueExpressionKeywords(last.valueExpression);
-    let keywords = [];
-    if (last.suggestKeywords) {
-      keywords = keywords.concat(last.suggestKeywords);
-    }
-    if (valueExpressionKeywords.suggestKeywords) {
-      keywords = keywords.concat(valueExpressionKeywords.suggestKeywords);
-    }
-    if (valueExpressionKeywords.suggestColRefKeywords) {
-      parser.suggestColRefKeywords(valueExpressionKeywords.suggestColRefKeywords);
-      parser.addColRefIfExists(last.valueExpression);
-    }
-    if (!last.alias) {
-      keywords.push('AS');
-    }
-    if (keywords.length > 0) {
-      parser.suggestKeywords(keywords);
-    }
-  };
-
-  parser.checkForKeywords = function (expression) {
-    if (expression) {
-      if (expression.suggestKeywords && expression.suggestKeywords.length > 0) {
-        parser.suggestKeywords(expression.suggestKeywords);
-      }
-      if (expression.suggestColRefKeywords) {
-        parser.suggestColRefKeywords(expression.suggestColRefKeywords);
-        parser.addColRefIfExists(expression);
-      }
-    }
-  };
-
-  parser.createWeightedKeywords = function (keywords, weight) {
-    const result = [];
-    keywords.forEach(keyword => {
-      if (typeof keyword.weight !== 'undefined') {
-        keyword.weight = weight + keyword.weight / 10;
-        result.push(keyword);
-      } else {
-        result.push({ value: keyword, weight: weight });
-      }
-    });
-    return result;
-  };
-
-  parser.suggestKeywords = function (keywords) {
-    const weightedKeywords = [];
-    if (keywords.length === 0) {
-      return;
-    }
-    keywords.forEach(keyword => {
-      if (typeof keyword.weight !== 'undefined') {
-        weightedKeywords.push(keyword);
-      } else {
-        weightedKeywords.push({ value: keyword, weight: -1 });
-      }
-    });
-    weightedKeywords.sort((a, b) => {
-      if (a.weight !== b.weight) {
-        return b.weight - a.weight;
-      }
-      return a.value.localeCompare(b.value);
-    });
-    parser.yy.result.suggestKeywords = weightedKeywords;
-  };
-
-  parser.suggestColRefKeywords = function (colRefKeywords) {
-    parser.yy.result.suggestColRefKeywords = colRefKeywords;
-  };
-
-  parser.suggestTablesOrColumns = function (identifier) {
-    if (typeof parser.yy.latestTablePrimaries == 'undefined') {
-      parser.suggestTables({ identifierChain: [{ name: identifier }] });
-      return;
-    }
-    const tableRef = parser.yy.latestTablePrimaries.filter(tablePrimary => {
-      return equalIgnoreCase(tablePrimary.alias, identifier);
-    });
-    if (tableRef.length > 0) {
-      parser.suggestColumns({ identifierChain: [{ name: identifier }] });
-    } else {
-      parser.suggestTables({ identifierChain: [{ name: identifier }] });
-    }
-  };
-
-  parser.suggestFunctions = function (details) {
-    parser.yy.result.suggestFunctions = details || {};
-  };
-
-  parser.suggestAggregateFunctions = function () {
-    const primaries = [];
-    const aliases = {};
-    parser.yy.latestTablePrimaries.forEach(primary => {
-      if (typeof primary.alias !== 'undefined') {
-        aliases[primary.alias] = true;
-      }
-      // Drop if the first one refers to a table alias (...FROM tbl t, t.map tm ...)
-      if (
-        typeof primary.identifierChain !== 'undefined' &&
-        !aliases[primary.identifierChain[0].name] &&
-        typeof primary.owner === 'undefined'
-      ) {
-        primaries.push(primary);
-      }
-    });
-    parser.yy.result.suggestAggregateFunctions = { tablePrimaries: primaries };
-  };
-
-  parser.suggestAnalyticFunctions = function () {
-    parser.yy.result.suggestAnalyticFunctions = true;
-  };
-
-  parser.suggestSetOptions = function () {
-    parser.yy.result.suggestSetOptions = true;
-  };
-
-  parser.suggestIdentifiers = function (identifiers) {
-    parser.yy.result.suggestIdentifiers = identifiers;
-  };
-
-  parser.suggestColumns = function (details) {
-    if (typeof details === 'undefined') {
-      details = { identifierChain: [] };
-    } else if (typeof details.identifierChain === 'undefined') {
-      details.identifierChain = [];
-    }
-    parser.yy.result.suggestColumns = details;
-  };
-
-  parser.suggestGroupBys = function (details) {
-    parser.yy.result.suggestGroupBys = details || {};
-  };
-
-  parser.suggestOrderBys = function (details) {
-    parser.yy.result.suggestOrderBys = details || {};
-  };
-
-  parser.suggestFilters = function (details) {
-    parser.yy.result.suggestFilters = details || {};
-  };
-
-  parser.suggestKeyValues = function (details) {
-    parser.yy.result.suggestKeyValues = details || {};
-  };
-
-  parser.suggestTables = function (details) {
-    parser.yy.result.suggestTables = details || {};
-  };
-
-  parser.firstDefined = function () {
-    for (let i = 0; i + 1 < arguments.length; i += 2) {
-      if (arguments[i]) {
-        return arguments[i + 1];
-      }
-    }
-  };
-
-  parser.addColRefToVariableIfExists = function (left, right) {
-    if (
-      left &&
-      left.columnReference &&
-      left.columnReference.length &&
-      right &&
-      right.columnReference &&
-      right.columnReference.length &&
-      parser.yy.locations.length > 1
-    ) {
-      const addColRefToVariableLocation = function (variableValue, colRef) {
-        // See if colref is actually an alias
-        if (colRef.length === 1 && colRef[0].name) {
-          parser.yy.locations.some(location => {
-            if (location.type === 'column' && location.alias === colRef[0].name) {
-              colRef = location.identifierChain;
-              return true;
-            }
-          });
-        }
-
-        for (let i = parser.yy.locations.length - 1; i > 0; i--) {
-          const location = parser.yy.locations[i];
-          if (location.type === 'variable' && location.value === variableValue) {
-            location.colRef = { identifierChain: colRef };
-            break;
-          }
-        }
-      };
-
-      if (/\${[^}]*}/.test(left.columnReference[0].name)) {
-        // left is variable
-        addColRefToVariableLocation(left.columnReference[0].name, right.columnReference);
-      } else if (/\${[^}]*}/.test(right.columnReference[0].name)) {
-        // right is variable
-        addColRefToVariableLocation(right.columnReference[0].name, left.columnReference);
-      }
-    }
-  };
-
-  parser.suggestDatabases = function (details) {
-    parser.yy.result.suggestDatabases = details || {};
-  };
-
-  parser.suggestHdfs = function (details) {
-    parser.yy.result.suggestHdfs = details || {};
-  };
-
-  parser.suggestValues = function (details) {
-    parser.yy.result.suggestValues = details || {};
-  };
-
-  parser.determineCase = function (text) {
-    if (!parser.yy.caseDetermined) {
-      parser.yy.lowerCase = text.toLowerCase() === text;
-      parser.yy.caseDetermined = true;
-    }
-  };
-
-  parser.handleQuotedValueWithCursor = function (lexer, yytext, yylloc, quoteChar) {
-    if (yytext.indexOf('\u2020') !== -1 || yytext.indexOf('\u2021') !== -1) {
-      parser.yy.partialCursor = yytext.indexOf('\u2021') !== -1;
-      const cursorIndex = parser.yy.partialCursor
-        ? yytext.indexOf('\u2021')
-        : yytext.indexOf('\u2020');
-      parser.yy.cursorFound = {
-        first_line: yylloc.first_line,
-        last_line: yylloc.last_line,
-        first_column: yylloc.first_column + cursorIndex,
-        last_column: yylloc.first_column + cursorIndex + 1
-      };
-      const remainder = yytext.substring(cursorIndex + 1);
-      const remainingQuotes = (lexer.upcomingInput().match(new RegExp(quoteChar, 'g')) || [])
-        .length;
-      if (remainingQuotes > 0 && (remainingQuotes & 1) !== 0) {
-        parser.yy.missingEndQuote = false;
-        lexer.input();
-      } else {
-        parser.yy.missingEndQuote = true;
-        lexer.unput(remainder);
-      }
-      lexer.popState();
-      return true;
-    }
-    return false;
-  };
-
-  let lexerModified = false;
-
-  /**
-   * Main parser function
-   */
-  parser.parseSql = function (beforeCursor, afterCursor, debug) {
-    // Jison counts CRLF as two lines in the locations
-    beforeCursor = beforeCursor.replace(/\r\n|\n\r/gm, '\n');
-    afterCursor = afterCursor.replace(/\r\n|\n\r/gm, '\n');
-    parser.yy.result = { locations: [] };
-    parser.yy.lowerCase = false;
-    parser.yy.locations = [];
-    parser.yy.definitions = [];
-    parser.yy.allLocations = [];
-    parser.yy.subQueries = [];
-    parser.yy.errors = [];
-    parser.yy.selectListAliases = [];
-    parser.yy.activeDialect = 'generic';
-
-    parser.yy.locationsStack = [];
-    parser.yy.primariesStack = [];
-    parser.yy.subQueriesStack = [];
-    parser.yy.resultStack = [];
-    parser.yy.selectListAliasesStack = [];
-
-    delete parser.yy.caseDetermined;
-    delete parser.yy.cursorFound;
-    delete parser.yy.partialCursor;
-
-    // Fix for parser bug when switching lexer states
-    if (!lexerModified) {
-      const originalSetInput = parser.lexer.setInput;
-      parser.lexer.setInput = function (input, yy) {
-        return originalSetInput.bind(parser.lexer)(input, yy);
-      };
-      lexerModified = true;
-    }
-
-    parser.prepareNewStatement();
-
-    const REASONABLE_SURROUNDING_LENGTH = 150000; // About 3000 lines before and after
-
-    if (beforeCursor.length > REASONABLE_SURROUNDING_LENGTH) {
-      if (beforeCursor.length - beforeCursor.lastIndexOf(';') > REASONABLE_SURROUNDING_LENGTH) {
-        // Bail out if the last complete statement is more than 150000 chars before
-        return {};
-      }
-      // Cut it at the first statement found within 150000 chars before
-      const lastReasonableChunk = beforeCursor.substring(
-        beforeCursor.length - REASONABLE_SURROUNDING_LENGTH
-      );
-      beforeCursor = lastReasonableChunk.substring(lastReasonableChunk.indexOf(';') + 1);
-    }
-
-    if (afterCursor.length > REASONABLE_SURROUNDING_LENGTH) {
-      if (afterCursor.length - afterCursor.indexOf(';') > REASONABLE_SURROUNDING_LENGTH) {
-        // No need to bail out for what's comes after, we can still get keyword completion
-        afterCursor = '';
-      } else {
-        // Cut it at the last statement found within 150000 chars after
-        const firstReasonableChunk = afterCursor.substring(0, REASONABLE_SURROUNDING_LENGTH);
-        afterCursor = firstReasonableChunk.substring(0, firstReasonableChunk.lastIndexOf(';'));
-      }
-    }
-
-    parser.yy.partialLengths = parser.identifyPartials(beforeCursor, afterCursor);
-
-    if (parser.yy.partialLengths.left > 0) {
-      beforeCursor = beforeCursor.substring(0, beforeCursor.length - parser.yy.partialLengths.left);
-    }
-
-    if (parser.yy.partialLengths.right > 0) {
-      afterCursor = afterCursor.substring(parser.yy.partialLengths.right);
-    }
-
-    let result;
-    try {
-      // Add |CURSOR| or |PARTIAL_CURSOR| to represent the different cursor states in the lexer
-      result = parser.parse(
-        beforeCursor +
-          (beforeCursor.length === 0 || /[\s(]$/.test(beforeCursor) ? ' \u2020 ' : '\u2021') +
-          afterCursor
-      );
-    } catch (err) {
-      // On any error try to at least return any existing result
-      if (typeof parser.yy.result === 'undefined') {
-        throw err;
-      }
-      if (debug) {
-        console.warn(err);
-        console.warn(err.stack);
-      }
-      result = parser.yy.result;
-    }
-    if (parser.yy.errors.length > 0) {
-      parser.yy.result.errors = parser.yy.errors;
-      if (debug) {
-        console.warn(parser.yy.errors);
-      }
-    }
-    try {
-      linkTablePrimaries();
-      parser.commitLocations();
-      // Clean up and prioritize
-      prioritizeSuggestions();
-    } catch (err) {
-      if (debug) {
-        console.warn(err);
-        console.warn(err.stack);
-      }
-    }
-
-    parser.yy.allLocations.sort((a, b) => {
-      if (a.location.first_line !== b.location.first_line) {
-        return a.location.first_line - b.location.first_line;
-      }
-      if (a.location.first_column !== b.location.first_column) {
-        return a.location.first_column - b.location.first_column;
-      }
-      if (a.location.last_column !== b.location.last_column) {
-        return b.location.last_column - a.location.last_column;
-      }
-      return b.type.localeCompare(a.type);
-    });
-    parser.yy.result.locations = parser.yy.allLocations;
-    parser.yy.result.definitions = parser.yy.definitions;
-
-    parser.yy.result.locations.forEach(location => {
-      delete location.linked;
-    });
-    if (typeof parser.yy.result.suggestColumns !== 'undefined') {
-      delete parser.yy.result.suggestColumns.linked;
-    }
-
-    SIMPLE_TABLE_REF_SUGGESTIONS.forEach(suggestionType => {
-      if (typeof parser.yy.result[suggestionType] !== 'undefined') {
-        delete parser.yy.result[suggestionType].linked;
-      }
-    });
-
-    if (typeof parser.yy.result.colRef !== 'undefined') {
-      delete parser.yy.result.colRef.linked;
-    }
-    if (typeof parser.yy.result.suggestKeyValues !== 'undefined') {
-      delete parser.yy.result.suggestKeyValues.linked;
-    }
-
-    if (typeof result.error !== 'undefined' && typeof result.error.expected !== 'undefined') {
-      // Remove the cursor from expected tokens
-      result.error.expected = result.error.expected.filter(token => token.indexOf('CURSOR') === -1);
-    }
-
-    if (typeof result.error !== 'undefined' && result.error.recoverable) {
-      delete result.error;
-    }
-
-    // Adjust all the statement locations to include white space surrounding them
-    let lastStatementLocation = null;
-    result.locations.forEach(location => {
-      if (location.type === 'statement') {
-        if (lastStatementLocation === null) {
-          location.location.first_line = 1;
-          location.location.first_column = 1;
-        } else {
-          location.location.first_line = lastStatementLocation.location.last_line;
-          location.location.first_column = lastStatementLocation.location.last_column + 1;
-        }
-        lastStatementLocation = location;
-      }
-    });
-
-    return result;
-  };
-};
-
-export default {
-  initSqlParser: initSqlParser,
-  initSyntaxParser: initSyntaxParser
-};

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


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


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


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


+ 0 - 2
desktop/core/src/desktop/js/parse/sql/sqlParserRepository.js

@@ -23,7 +23,6 @@ const AUTOCOMPLETE_MODULES = {
   druid: () => import(/* webpackChunkName: "druid-parser" */ 'parse/sql/druid/druidAutocompleteParser'),
   elasticsearch: () => import(/* webpackChunkName: "elasticsearch-parser" */ 'parse/sql/elasticsearch/elasticsearchAutocompleteParser'),
   flink: () => import(/* webpackChunkName: "flink-parser" */ 'parse/sql/flink/flinkAutocompleteParser'),
-  generic2: () => import(/* webpackChunkName: "generic2-parser" */ 'parse/sql/generic2/generic2AutocompleteParser'),
   generic: () => import(/* webpackChunkName: "generic-parser" */ 'parse/sql/generic/genericAutocompleteParser'),
   hive: () => import(/* webpackChunkName: "hive-parser" */ 'parse/sql/hive/hiveAutocompleteParser'),
   impala: () => import(/* webpackChunkName: "impala-parser" */ 'parse/sql/impala/impalaAutocompleteParser'),
@@ -36,7 +35,6 @@ const SYNTAX_MODULES = {
   druid: () => import(/* webpackChunkName: "druid-parser" */ 'parse/sql/druid/druidSyntaxParser'),
   elasticsearch: () => import(/* webpackChunkName: "elasticsearch-parser" */ 'parse/sql/elasticsearch/elasticsearchSyntaxParser'),
   flink: () => import(/* webpackChunkName: "flink-parser" */ 'parse/sql/flink/flinkSyntaxParser'),
-  generic2: () => import(/* webpackChunkName: "generic2-parser" */ 'parse/sql/generic2/generic2SyntaxParser'),
   generic: () => import(/* webpackChunkName: "generic-parser" */ 'parse/sql/generic/genericSyntaxParser'),
   hive: () => import(/* webpackChunkName: "hive-parser" */ 'parse/sql/hive/hiveSyntaxParser'),
   impala: () => import(/* webpackChunkName: "impala-parser" */ 'parse/sql/impala/impalaSyntaxParser'),

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