Преглед изворни кода

HUE-9429 [editor] Extract the generic 2 select conditions to separate jison files

Johan Ahlen пре 5 година
родитељ
комит
8e0cc1a4e2

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

@@ -0,0 +1,101 @@
+// 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.
+
+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();
+   }
+ ;

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

@@ -0,0 +1,38 @@
+// 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.
+
+OptionalHavingClause
+ :
+ | HavingClause
+ ;
+
+HavingClause
+ : 'HAVING' ValueExpression
+ ;
+
+HavingClause_EDIT
+ : 'HAVING' 'CURSOR'
+   {
+     parser.valueExpressionSuggest();
+     parser.suggestAggregateFunctions();
+     parser.suggestSelectListAliases(true);
+   }
+ | 'HAVING' ValueExpression_EDIT
+   {
+     parser.suggestAggregateFunctions();
+     parser.suggestSelectListAliases(true);
+   }
+ ;

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

@@ -0,0 +1,34 @@
+// 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.
+
+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 }])
+   }
+ ;

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

@@ -0,0 +1,81 @@
+// 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.
+
+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'
+ ;

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

@@ -0,0 +1,155 @@
+// 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.
+
+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;
+   }
+ ;

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

@@ -393,351 +393,6 @@ FromClause_EDIT
  | '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
- ;
-
-
 SelectSpecification
  : ValueExpression OptionalCorrelationName
    {

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

@@ -0,0 +1,48 @@
+// 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.
+
+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() });
+   }
+ ;
+
+SearchCondition
+ : ValueExpression
+ ;
+
+SearchCondition_EDIT
+ : ValueExpression_EDIT
+ ;

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

@@ -1515,26 +1515,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);
-   }
- ;

+ 14 - 2
desktop/core/src/desktop/js/parse/jison/sql/generic2/structure.json

@@ -8,7 +8,13 @@
     "../generic/sql_error.jison",
     "../generic/sql_insert.jison",
     "sql_main.jison",
-    "select/sql_select.jison",
+    "select/group_by_clause.jison",
+    "select/having_clause.jison",
+    "select/limit_clause.jison",
+    "select/order_by_clause.jison",
+    "select/select_conditions.jison",
+    "select/select_statement.jison",
+    "select/where_clause.jison",
     "../generic/sql_set.jison",
     "../generic/sql_udf.jison",
     "../generic/sql_update.jison",
@@ -23,7 +29,13 @@
     "../generic/sql_drop.jison",
     "../generic/sql_insert.jison",
     "sql_main.jison",
-    "select/sql_select.jison",
+    "select/group_by_clause.jison",
+    "select/having_clause.jison",
+    "select/limit_clause.jison",
+    "select/order_by_clause.jison",
+    "select/select_conditions.jison",
+    "select/select_statement.jison",
+    "select/where_clause.jison",
     "../generic/sql_set.jison",
     "../generic/sql_udf.jison",
     "../generic/sql_update.jison",

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/generic2/generic2AutocompleteParser.js


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/generic2/generic2SyntaxParser.js


Неке датотеке нису приказане због велике количине промена