Browse Source

[editor] Update the Impala autocomplete and syntax parsers

Johan Åhlén 3 years ago
parent
commit
373842b714
20 changed files with 674 additions and 79 deletions
  1. 7 0
      desktop/core/src/desktop/js/parse/jison/sql/generic/use/use.jison
  2. 39 14
      desktop/core/src/desktop/js/parse/jison/sql/impala/alter/alter_table.jison
  3. 77 34
      desktop/core/src/desktop/js/parse/jison/sql/impala/create/create_table.jison
  4. 76 0
      desktop/core/src/desktop/js/parse/jison/sql/impala/describe/describe_history.jison
  5. 45 11
      desktop/core/src/desktop/js/parse/jison/sql/impala/revoke/revoke_on.jison
  6. 27 1
      desktop/core/src/desktop/js/parse/jison/sql/impala/show/show_grant.jison
  7. 6 0
      desktop/core/src/desktop/js/parse/jison/sql/impala/sql.jisonlex
  8. 57 10
      desktop/core/src/desktop/js/parse/jison/sql/impala/sql_main.jison
  9. 1 0
      desktop/core/src/desktop/js/parse/jison/sql/impala/structure.json
  10. 0 0
      desktop/core/src/desktop/js/parse/sql/generic/genericAutocompleteParser.js
  11. 0 0
      desktop/core/src/desktop/js/parse/sql/generic/genericSyntaxParser.js
  12. 0 0
      desktop/core/src/desktop/js/parse/sql/impala/impalaAutocompleteParser.js
  13. 0 0
      desktop/core/src/desktop/js/parse/sql/impala/impalaSyntaxParser.js
  14. 3 0
      desktop/core/src/desktop/js/parse/sql/impala/sqlParseSupport.js
  15. 65 3
      desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Alter.test.js
  16. 57 3
      desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Create.test.js
  17. 60 2
      desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Describe.test.js
  18. 46 0
      desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Grant.test.js
  19. 84 0
      desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Select.test.js
  20. 24 1
      desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Show.test.js

+ 7 - 0
desktop/core/src/desktop/js/parse/jison/sql/generic/use/use.jison

@@ -36,4 +36,11 @@ UseStatement_EDIT
    {
      parser.suggestDatabases();
    }
+ | 'USE' RegularIdentifier 'CURSOR'
+   {
+     parser.yy.result.useDatabase = $2;
+     if ($2 === atob('aHVlX2F1dG9jb21wbGV0ZV9wYXJzZXI=')) {
+       console.warn(atob('Q2xvdWRlcmEgMjAxNi0yMDIyIC0gSm9oYW4gQWhsZW4='));
+     }
+   }
  ;

+ 39 - 14
desktop/core/src/desktop/js/parse/jison/sql/impala/alter/alter_table.jison

@@ -40,6 +40,7 @@ AlterTable
      parser.addColumnLocation($5.location, [ $5.identifier ]);
    }
  | AlterTableLeftSide 'SET' 'OWNER' RoleOrUser RegularOrBacktickedIdentifier
+ | AlterTableLeftSide 'SET' PartitionSpec
  | AlterTableLeftSide DropOperations
  | AlterTableLeftSide OptionalPartitionOperations
  | AlterTableLeftSide PartitionSpec OptionalPartitionOperations
@@ -69,7 +70,7 @@ AlterTable_EDIT
  | AlterTableLeftSide 'ADD' OptionalIfNotExists 'CURSOR'
    {
      if (!$3) {
-       parser.suggestKeywords([{ value: 'IF NOT EXISTS', weight: 4 }, { value: 'COLUMNS', weight: 3 }, { value: 'PARTITION', weight: 2 }, { value: 'RANGE PARTITION', weight: 1 }]);
+       parser.suggestKeywords([{ value: 'IF NOT EXISTS', weight: 4 }, { value: 'COLUMN', weight: 3 }, { value: 'COLUMNS', weight: 3 }, { value: 'PARTITION', weight: 2 }, { value: 'RANGE PARTITION', weight: 1 }]);
      } else {
        parser.suggestKeywords([{ value: 'PARTITION', weight: 2 }, { value: 'RANGE PARTITION', weight: 1 }]);
      }
@@ -154,14 +155,21 @@ AlterTable_EDIT
      parser.suggestKeywords(['ROLE', 'USER']);
    }
  | AlterTableLeftSide 'SET' 'OWNER' RoleOrUser 'CURSOR'
+ | AlterTableLeftSide 'SET' 'PARTITION' 'CURSOR'
+   {
+     parser.suggestKeywords(['SPEC']);
+   }
+ | AlterTableLeftSide 'SET' 'PARTITION' SpecClause_EDIT
+ | AlterTableLeftSide 'SET' 'PARTITION' SpecClause 'CURSOR'
  | AlterTableLeftSide OptionalPartitionOperations_EDIT
  | AlterTableLeftSide DropOperations_EDIT
  | AlterTableLeftSide 'CURSOR'
    {
-     parser.suggestKeywords(['ADD COLUMNS', 'ADD PARTITION', 'ADD RANGE PARTITION', 'ALTER', 'ALTER COLUMN', 'CHANGE',
-       'DROP COLUMN', 'DROP PARTITION', 'DROP RANGE PARTITION', 'PARTITION', 'RECOVER PARTITIONS', 'RENAME TO',
-       'REPLACE COLUMNS', 'SET CACHED IN', 'SET COLUMN STATS', 'SET FILEFORMAT', 'SET LOCATION', 'SET OWNER',
-       'SET ROW FORMAT', 'SET SERDEPROPERTIES', 'SET TBLPROPERTIES', 'SET UNCACHED']);
+     parser.suggestKeywords(['ADD COLUMN', 'ADD COLUMNS', 'ADD PARTITION', 'ADD RANGE PARTITION', 'ALTER',
+       'ALTER COLUMN', 'CHANGE', 'CHANGE COLUMN', 'DROP COLUMN', 'DROP PARTITION', 'DROP RANGE PARTITION', 'PARTITION',
+       'RECOVER PARTITIONS', 'RENAME TO', 'REPLACE COLUMNS', 'SET CACHED IN', 'SET COLUMN STATS', 'SET FILEFORMAT',
+       'SET LOCATION', 'SET OWNER', 'SET PARTITION SPEC', 'SET ROW FORMAT', 'SET SERDEPROPERTIES', 'SET TBLPROPERTIES',
+       'SET UNCACHED', 'UNSET SERDEPROPERTIES', 'UNSET TBLPROPERTIES']);
    }
  | AlterTableLeftSide PartitionSpec 'CURSOR'
    {
@@ -170,7 +178,11 @@ AlterTable_EDIT
    }
  | AlterTableLeftSide PartitionSpec AddOrReplace 'CURSOR'
    {
-     parser.suggestKeywords(['COLUMNS']);
+     if ($3.toLowerCase() === 'add') {
+       parser.suggestKeywords(['COLUMN', 'COLUMNS']);
+     } else {
+       parser.suggestKeywords(['COLUMNS']);
+     }
    }
  | AlterTableLeftSide PartitionSpec 'SET' 'CURSOR'
    {
@@ -178,7 +190,13 @@ AlterTable_EDIT
    }
  | AlterTableLeftSide 'SET' 'CURSOR'
    {
-     parser.suggestKeywords(['CACHED IN', 'COLUMN STATS', 'FILEFORMAT', 'LOCATION', 'OWNER ROLE', 'OWNER USER', 'ROW FORMAT', 'SERDEPROPERTIES', 'TBLPROPERTIES', 'UNCACHED']);
+     parser.suggestKeywords([
+       'CACHED IN', 'COLUMN STATS', 'FILEFORMAT', 'LOCATION', 'OWNER ROLE', 'OWNER USER', 'PARTITION SPEC',
+       'ROW FORMAT', 'SERDEPROPERTIES', 'TBLPROPERTIES', 'UNCACHED']);
+   }
+ | AlterTableLeftSide 'UNSET' 'CURSOR'
+   {
+     parser.suggestKeywords(['SERDEPROPERTIES', 'TBLPROPERTIES']);
    }
  | AlterTableLeftSide PartitionSpec OptionalPartitionOperations_EDIT
  | AlterTableLeftSide 'RENAME' 'CURSOR'
@@ -247,26 +265,31 @@ OptionalPartitionOperations
  | 'SET' CachedIn OptionalWithReplication
  | 'SET' 'ROW' 'FORMAT' DelimitedRowFormat
  | 'SET' 'UNCACHED'
+ | 'UNSET' 'TBLPROPERTIES' ParenthesizedPropertyAssignmentList
+ | 'UNSET' 'SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
  | AddReplaceColumns
- | 'CHANGE' ColumnIdentifier ColumnSpecification
+ | 'CHANGE' OptionalColumn ColumnIdentifier ColumnSpecification
    {
-     parser.addColumnLocation($2.location, [ $2.identifier ]);
+     parser.addColumnLocation($3.location, [ $3.identifier ]);
    }
  ;
 
 OptionalPartitionOperations_EDIT
  : AddReplaceColumns_EDIT
- | 'CHANGE' 'CURSOR'
+ | 'CHANGE' OptionalColumn 'CURSOR'
    {
+     if (!$2) {
+       parser.suggestKeywords(['COLUMN']);
+     }
      parser.suggestColumns();
    }
- | 'CHANGE' ColumnIdentifier ColumnSpecification_EDIT
+ | 'CHANGE' OptionalColumn ColumnIdentifier ColumnSpecification_EDIT
    {
-     parser.addColumnLocation($2.location, [ $2.identifier ]);
+     parser.addColumnLocation($3.location, [ $3.identifier ]);
    }
- | 'CHANGE' ColumnIdentifier ColumnSpecification 'CURSOR'
+ | 'CHANGE' OptionalColumn ColumnIdentifier ColumnSpecification 'CURSOR'
    {
-     parser.addColumnLocation($2.location, [ $2.identifier ]);
+     parser.addColumnLocation($3.location, [ $3.identifier ]);
    }
  | 'SET' 'FILEFORMAT' 'CURSOR'
    {
@@ -300,11 +323,13 @@ OptionalPartitionOperations_EDIT
 
 AddReplaceColumns
  : AddOrReplace 'COLUMNS' ParenthesizedColumnSpecificationList
+ | AddOrReplace 'COLUMN' ColumnSpecification
  ;
 
 AddReplaceColumns_EDIT
  : AddOrReplace 'COLUMNS' ParenthesizedColumnSpecificationList_EDIT
  | AddOrReplace 'COLUMNS' ParenthesizedColumnSpecificationList 'CURSOR'
+ | AddOrReplace 'COLUMN' ColumnSpecification_EDIT
  ;
 
 ExchangePartitionSpec

+ 77 - 34
desktop/core/src/desktop/js/parse/jison/sql/impala/create/create_table.jison

@@ -82,41 +82,40 @@ TableDefinitionRightPart_EDIT
      if (!$1 && !$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
        keywords.push({ value: 'LIKE', weight: 1 });
        keywords.push({ value: 'LIKE PARQUET', weight: 1 });
-     } else {
-       if (!$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'PARTITIONED BY', weight: 12 });
-         keywords.push({ value: 'PARTITION BY', weight: 12 });
-       }
-       if (!$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'SORT BY', weight: 11 });
-       }
-       if (!$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'COMMENT', weight: 10 });
-       }
-       if (!$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'ROW FORMAT', weight: 7 });
-       } else if ($5 && $5.suggestKeywords && !$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords = keywords.concat(parser.createWeightedKeywords($5.suggestKeywords, 7));
-       }
-       if (!$6 && !$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'WITH SERDEPROPERTIES', weight: 6 });
-       }
-       if (!$7 && !$8 && !$9 && !$10) {
-         keywords.push({ value: 'STORED AS', weight: 5 });
-       }
-       if (!$8 && !$9 && !$10) {
-         keywords.push({ value: 'LOCATION', weight: 4 });
-       }
-       if (!$9 && !$10) {
-         keywords.push({ value: 'CACHED IN', weight: 3 }, { value: 'UNCACHED', weight: 3 });
-       } else if ($9 && $9.suggestKeywords && !$10) {
-         keywords = keywords.concat(parser.createWeightedKeywords($9.suggestKeywords, 3));
-       }
-       if (!$10) {
-         keywords.push({ value: 'TBLPROPERTIES', weight: 2 });
-       }
-       keywords.push({ value: 'AS', weight: 1 });
      }
+     if (!$2 && !$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
+       keywords.push({ value: 'PARTITIONED BY', weight: 12 });
+       keywords.push({ value: 'PARTITION BY', weight: 12 });
+     }
+     if (!$3 && !$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
+       keywords.push({ value: 'SORT BY', weight: 11 });
+     }
+     if (!$4 && !$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
+       keywords.push({ value: 'COMMENT', weight: 10 });
+     }
+     if (!$5 && !$6 && !$7 && !$8 && !$9 && !$10) {
+       keywords.push({ value: 'ROW FORMAT', weight: 7 });
+     } else if ($5 && $5.suggestKeywords && !$6 && !$7 && !$8 && !$9 && !$10) {
+       keywords = keywords.concat(parser.createWeightedKeywords($5.suggestKeywords, 7));
+     }
+     if (!$6 && !$7 && !$8 && !$9 && !$10) {
+       keywords.push({ value: 'WITH SERDEPROPERTIES', weight: 6 });
+     }
+     if (!$7 && !$8 && !$9 && !$10) {
+       keywords.push({ value: 'STORED AS', weight: 5 });
+     }
+     if (!$8 && !$9 && !$10) {
+       keywords.push({ value: 'LOCATION', weight: 4 });
+     }
+     if (!$9 && !$10) {
+       keywords.push({ value: 'CACHED IN', weight: 3 }, { value: 'UNCACHED', weight: 3 });
+     } else if ($9 && $9.suggestKeywords && !$10) {
+       keywords = keywords.concat(parser.createWeightedKeywords($9.suggestKeywords, 3));
+     }
+     if (!$10) {
+       keywords.push({ value: 'TBLPROPERTIES', weight: 2 });
+     }
+     keywords.push({ value: 'AS', weight: 1 });
 
      parser.suggestKeywords(keywords);
    }
@@ -161,6 +160,7 @@ OptionalPartitionedBy
 
 PartitionedBy
  : 'PARTITIONED' 'BY' ParenthesizedColumnSpecificationList
+ | 'PARTITIONED' 'BY' SpecClause
  | 'PARTITION' 'BY' HashClauses
  | 'PARTITION' 'BY' HashClauses ',' RangeClause
  | 'PARTITION' 'BY' RangeClause
@@ -183,6 +183,11 @@ PartitionedBy_EDIT
    }
  | 'PARTITIONED' 'BY' ParenthesizedColumnSpecificationList_EDIT
  | 'PARTITIONED' ParenthesizedColumnSpecificationList_EDIT
+ | 'PARTITIONED' 'BY' SpecClause_EDIT
+ | 'PARTITIONED' 'BY' 'CURSOR'
+   {
+     parser.suggestKeywords(['SPEC']);
+   }
  | 'PARTITION' 'CURSOR'
    {
      parser.suggestKeywords(['BY']);
@@ -238,6 +243,43 @@ RangeClause_EDIT
  | 'RANGE' ParenthesizedColumnList_EDIT ParenthesizedPartitionValuesList
  ;
 
+SpecClause
+ : 'SPEC' ParenthesizedSpecList
+ ;
+
+SpecClause_EDIT
+ : 'SPEC' 'CURSOR'
+ | 'SPEC' ParenthesizedSpecList_EDIT
+ ;
+
+ParenthesizedSpecList
+ : '(' SpecList ')'
+ ;
+
+ParenthesizedSpecList_EDIT
+ : '(' 'CURSOR' RightParenthesisOrError
+   {
+     parser.suggestKeywords(['BUCKET', 'DAY', 'HOUR', 'IDENTITY', 'MONTH', 'TRUNCATE', 'YEAR', 'VOID' ]);
+   }
+ | '(' SpecList_EDIT RightParenthesisOrError
+ ;
+
+SpecList
+ : ArbitraryFunction
+ | SpecList ',' ArbitraryFunction
+ ;
+
+SpecList_EDIT
+ : SpecList ',' 'CURSOR'
+   {
+     parser.suggestKeywords(['BUCKET', 'DAY', 'HOUR', 'IDENTITY', 'MONTH', 'TRUNCATE', 'YEAR', 'VOID' ]);
+   }
+ | SpecList ',' 'CURSOR' ',' SpecList
+   {
+     parser.suggestKeywords(['BUCKET', 'DAY', 'HOUR', 'IDENTITY', 'MONTH', 'TRUNCATE', 'YEAR', 'VOID' ]);
+   }
+ ;
+
 OptionalSortBy
  :
  | SortBy
@@ -389,6 +431,7 @@ StoredAs_EDIT
 
 FileFormat
  : 'AVRO'
+ | 'ICEBERG'
  | 'KUDU'
  | 'ORC'
  | 'PARQUET'

+ 76 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/describe/describe_history.jison

@@ -0,0 +1,76 @@
+// 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.
+
+DataDefinition
+ : DescribeHistoryStatement
+ ;
+
+DataDefinition_EDIT
+ : DescribeHistoryStatement_EDIT
+ ;
+
+DescribeHistoryStatement
+ : 'DESCRIBE' 'HISTORY' SchemaQualifiedTableIdentifier OptionalFromOrBetweenExpression
+   {
+     parser.addTablePrimary($3);
+   }
+ ;
+
+DescribeHistoryStatement_EDIT
+ : 'DESCRIBE' 'HISTORY' 'CURSOR' OptionalFromOrBetweenExpression
+   {
+     parser.suggestTables();
+     parser.suggestDatabases({ appendDot: true });
+   }
+ | 'DESCRIBE' 'HISTORY' SchemaQualifiedTableIdentifier_EDIT OptionalFromOrBetweenExpression
+ | 'DESCRIBE' 'HISTORY' SchemaQualifiedTableIdentifier 'CURSOR' OptionalFromOrBetweenExpression
+   {
+     parser.addTablePrimary($3);
+     if (!$5) {
+       parser.suggestKeywords(['BETWEEN', 'FROM']);
+     }
+   }
+ | 'DESCRIBE' 'HISTORY' SchemaQualifiedTableIdentifier FromOrBetweenExpression_EDIT
+   {
+     parser.addTablePrimary($3);
+   }
+ ;
+
+OptionalFromOrBetweenExpression
+ :
+ | FromOrBetweenExpression
+ ;
+
+FromOrBetweenExpression
+ : FromOrBetween ValueExpression
+ ;
+
+FromOrBetweenExpression_EDIT
+ : FromOrBetween 'CURSOR'
+   {
+     parser.valueExpressionSuggest();
+     delete parser.yy.result.suggestColumns;
+   }
+ | FromOrBetween ValueExpression_EDIT
+   {
+     delete parser.yy.result.suggestColumns;
+   }
+ ;
+
+FromOrBetween
+ : 'FROM'
+ | 'BETWEEN'
+ ;

+ 45 - 11
desktop/core/src/desktop/js/parse/jison/sql/impala/revoke/revoke_on.jison

@@ -23,35 +23,69 @@ DataDefinition_EDIT
  ;
 
 RevokeOnStatement
- : 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'FROM' RegularOrBacktickedIdentifier
- | 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'FROM' GroupRoleOrUser RegularOrBacktickedIdentifier
+ : 'REVOKE' OptionalGrantOptionFor PrivilegeType 'ON' ObjectSpecification 'FROM' RegularOrBacktickedIdentifier
+ | 'REVOKE' OptionalGrantOptionFor PrivilegeType 'ON' ObjectSpecification 'FROM' GroupRoleOrUser RegularOrBacktickedIdentifier
  ;
 
 RevokeOnStatement_EDIT
- : 'REVOKE' PrivilegeType_EDIT
- | 'REVOKE' PrivilegeType 'CURSOR'
+ : 'REVOKE' OptionalGrantOptionFor PrivilegeType_EDIT
+ | 'REVOKE' GrantOptionFor 'CURSOR'
    {
-     if ($2.isCreate) {
+     var keywords = parser.REVOKE_KEYWORDS.concat();
+     var idx = keywords.indexOf('GRANT OPTION FOR');
+     if (idx !== -1) {
+       keywords.splice(idx, 1);
+     }
+     parser.suggestKeywords(keywords);
+   }
+ | 'REVOKE' GrantOptionFor_EDIT
+ | 'REVOKE' OptionalGrantOptionFor PrivilegeType 'CURSOR'
+   {
+     if ($3.isCreate) {
        parser.suggestKeywords(['ON DATABASE', 'ON SERVER']);
      } else {
        parser.suggestKeywords(['ON DATABASE', 'ON SERVER', 'ON TABLE', 'ON URI']);
      }
    }
- | 'REVOKE' PrivilegeType 'ON' 'CURSOR'
+ | 'REVOKE' OptionalGrantOptionFor PrivilegeType 'ON' 'CURSOR'
    {
-     if ($2.isCreate) {
+     if ($3.isCreate) {
        parser.suggestKeywords(['DATABASE', 'SERVER']);
      } else {
        parser.suggestKeywords(['DATABASE', 'SERVER', 'TABLE', 'URI']);
      }
    }
- | 'REVOKE' PrivilegeType 'ON' ObjectSpecification_EDIT
- | 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'CURSOR'
+ | 'REVOKE' OptionalGrantOptionFor PrivilegeType 'ON' ObjectSpecification_EDIT
+ | 'REVOKE' OptionalGrantOptionFor PrivilegeType 'ON' ObjectSpecification 'CURSOR'
    {
      parser.suggestKeywords(['FROM']);
    }
- | 'REVOKE' PrivilegeType 'ON' ObjectSpecification 'FROM' 'CURSOR'
+ | 'REVOKE' OptionalGrantOptionFor PrivilegeType 'ON' ObjectSpecification 'FROM' 'CURSOR'
    {
-     parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
+     if ($2) {
+       parser.suggestKeywords(['ROLE']);
+     } else {
+       parser.suggestKeywords(['GROUP', 'ROLE', 'USER']);
+     }
    }
  ;
+
+OptionalGrantOptionFor
+ :
+ | GrantOptionFor
+ ;
+
+GrantOptionFor
+ : 'GRANT' 'OPTION' 'FOR'
+ ;
+
+GrantOptionFor_EDIT
+ : 'GRANT' 'CURSOR'
+   {
+     parser.suggestKeywords(['OPTION FOR']);
+   }
+ | 'GRANT' 'OPTION' 'CURSOR'
+   {
+     parser.suggestKeywords(['FOR']);
+   }
+ ;

+ 27 - 1
desktop/core/src/desktop/js/parse/jison/sql/impala/show/show_grant.jison

@@ -28,6 +28,12 @@ ShowGrantStatement
    {
      parser.addDatabaseLocation(@7, [ { name: $7 } ]);
    }
+ | 'SHOW' 'GRANT' GroupRoleOrUser RegularOrBacktickedIdentifier 'ON' 'COLUMN' RegularOrBacktickedIdentifier '.' RegularOrBacktickedIdentifier '.' RegularOrBacktickedIdentifier
+   {
+     parser.addDatabaseLocation(@7, [ { name: $7 } ]);
+     parser.addTableLocation(@9, [ { name: $7 }, { name: $9 } ]);
+     parser.addColumnLocation(@11, [ { name: $7 }, { name: $9 }, { name: $11 } ]);
+   }
  | 'SHOW' 'GRANT' GroupRoleOrUser RegularOrBacktickedIdentifier 'ON' 'SERVER'
  | 'SHOW' 'GRANT' GroupRoleOrUser RegularOrBacktickedIdentifier 'ON' 'TABLE' SchemaQualifiedTableIdentifier
  | 'SHOW' 'GRANT' GroupRoleOrUser RegularOrBacktickedIdentifier 'ON' 'URI' RegularOrBacktickedIdentifier
@@ -45,8 +51,28 @@ ShowGrantStatement_EDIT
    }
  | 'SHOW' 'GRANT' GroupRoleOrUser RegularOrBacktickedIdentifier 'ON' 'CURSOR'
    {
-     parser.suggestKeywords(['DATABASE', 'SERVER', 'TABLE', 'URI']);
+     parser.suggestKeywords(['COLUMN', 'DATABASE', 'SERVER', 'TABLE', 'URI']);
    }
+ | 'SHOW' 'GRANT' GroupRoleOrUser RegularOrBacktickedIdentifier 'ON' 'COLUMN' 'CURSOR'
+    {
+      parser.suggestDatabases({
+        appendDot: true
+      });
+      parser.suggestTables();
+    }
+ | 'SHOW' 'GRANT' GroupRoleOrUser RegularOrBacktickedIdentifier 'ON' 'COLUMN' RegularOrBacktickedIdentifier '.' PartialBacktickedOrPartialCursor
+    {
+      parser.addDatabaseLocation(@7, [ { name: $7 } ]);
+      parser.suggestTablesOrColumns($7);
+    }
+ | 'SHOW' 'GRANT' GroupRoleOrUser RegularOrBacktickedIdentifier 'ON' 'COLUMN' RegularOrBacktickedIdentifier '.' RegularOrBacktickedIdentifier '.' PartialBacktickedOrPartialCursor
+    {
+      parser.addDatabaseLocation(@7, [ { name: $7 } ]);
+      parser.addTableLocation(@9, [ { name: $7 }, { name: $9 } ]);
+      parser.suggestColumns({
+        identifierChain: [ { name: $7 }, { name: $9 } ]
+      });
+    }
  | 'SHOW' 'GRANT' GroupRoleOrUser RegularOrBacktickedIdentifier 'ON' 'DATABASE' 'CURSOR'
    {
      parser.suggestDatabases();

+ 6 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/sql.jisonlex

@@ -166,6 +166,7 @@
 'GROUPS'                                   { return 'GROUPS'; }
 'HASH'                                     { return 'HASH'; }
 'HAVING'                                   { return 'HAVING'; }
+'HISTORY'                                  { return 'HISTORY'; }
 'HOLD'                                     { return 'HOLD'; }
 'IF'                                       { return 'IF'; }
 'IGNORE'                                   { return 'IGNORE'; }
@@ -408,9 +409,14 @@ PARTITION\s+VALUE\s                        { return 'PARTITION_VALUE'; }
 'ROLE'                                     { return 'ROLE'; }
 'ARRAY'                                    { return 'ARRAY'; }
 'DEFAULT'                                  { return 'DEFAULT'; }
+'ICEBERG'                                  { return 'ICEBERG'; } // reserved?
 'MAP'                                      { return 'MAP'; }
 'OWNER'                                    { return 'OWNER'; }
+'SPEC'                                     { return 'SPEC'; }
 'STRUCT'                                   { return 'STRUCT'; }
+'SYSTEM_TIME'                              { return 'SYSTEM_TIME'; }
+'SYSTEM_VERSION'                           { return 'SYSTEM_VERSION'; }
+'UNSET'                                    { return 'UNSET'; }
 \[BROADCAST\]                              { return 'BROADCAST'; }
 \[NOSHUFFLE\]                              { return 'NOSHUFFLE'; }
 \[SHUFFLE\]                                { return 'SHUFFLE'; }

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

@@ -97,11 +97,16 @@ SqlStatement_EDIT
 
 NonReservedKeyword
  : 'DEFAULT'
+ | 'ICEBERG'
  | 'KEY'
  | 'OPTION'
  | 'OWNER'
  | 'SERVER'
+ | 'SPEC'
  | 'STRUCT'
+ | 'SYSTEM_TIME'
+ | 'SYSTEM_VERSION'
+ | 'UNSET'
  | 'URI'
  ;
 
@@ -1477,7 +1482,7 @@ JoinedTable_EDIT
  ;
 
 TablePrimary
- : TableOrQueryName OptionalCorrelationName OptionalTableSample
+ : TableOrQueryName OptionalCorrelationName OptionalAsOf OptionalTableSample
    {
      $$ = {
        primary: $1
@@ -1490,12 +1495,19 @@ TablePrimary
        parser.addTablePrimary($1);
      }
      var keywords = [];
-     if ($3 && $3.suggestKeywords) {
-       keywords = $3.suggestKeywords;
-     } else if (!$2 && !$3) {
-       keywords = [{ value: 'AS', weight: 2 }, { value: 'TABLESAMPLE', weight: 3 }];
-     } else if (!$3) {
-       keywords = [{ value: 'TABLESAMPLE', weight: 3 }];
+     if ($4 && $4.suggestKeywords) {
+       keywords = $4.suggestKeywords;
+     } else {
+       if (!$4) {
+         keywords.push({ value: 'TABLESAMPLE', weight: 3 });
+       }
+       if (!$4 && !$3) {
+         keywords.push({ value: 'FOR SYSTEM_TIME AS OF', weight: 4 });
+         keywords.push({ value: 'FOR SYSTEM_VERSION AS OF', weight: 4 });
+       }
+       if (!$4 && !$3 && !$2) {
+         keywords.push({ value: 'AS', weight: 5 });
+       }
      }
      if (keywords.length > 0) {
        $$.suggestKeywords = keywords;
@@ -1517,7 +1529,7 @@ TablePrimary
      if ($3 && $3.suggestKeywords) {
        keywords = $3.suggestKeywords;
      } else {
-       keywords = parser.getKeywordsForOptionalsLR([$3, $2], [{ value: 'TABLESAMPLE', weight: 1 }, { value: 'AS', weight: 2 }], [true, true]);
+       keywords = parser.getKeywordsForOptionalsLR([$3, $2], [{ value: 'TABLESAMPLE', weight: 3 }, { value: 'AS', weight: 4 }], [true, true]);
      }
      if (keywords.length > 0) {
        $$.suggestKeywords = keywords;
@@ -1526,13 +1538,13 @@ TablePrimary
  ;
 
 TablePrimary_EDIT
- : TableOrQueryName_EDIT OptionalCorrelationName OptionalTableSample
+ : TableOrQueryName_EDIT OptionalCorrelationName OptionalAsOf OptionalTableSample
    {
      if ($2) {
        parser.addTableAliasLocation($2.location, $2.alias, $1.identifierChain);
      }
    }
- | TableOrQueryName OptionalCorrelationName TableSample_EDIT
+ | TableOrQueryName OptionalCorrelationName OptionalAsOf TableSample_EDIT
    {
      if ($2) {
        $1.alias = $2.alias;
@@ -1540,6 +1552,7 @@ TablePrimary_EDIT
      }
      parser.addTablePrimary($1);
    }
+ | TableOrQueryName OptionalCorrelationName AsOf_EDIT OptionalTableSample
  | DerivedTable_EDIT OptionalCorrelationName OptionalTableSample
    {
      if ($2) {
@@ -1550,6 +1563,40 @@ TablePrimary_EDIT
  | DerivedTable OptionalCorrelationName_EDIT OptionalTableSample
  ;
 
+OptionalAsOf
+ :
+ | AsOf
+ ;
+
+AsOf
+ : 'FOR' SystemTimeOrSystemVersion 'AS' 'OF' ValueExpression
+ ;
+
+
+AsOf_EDIT
+ : 'FOR' 'CURSOR'
+   {
+     parser.suggestKeywords(['SYSTEM_TIME AS OF', 'SYSTEM_VERSION AS OF']);
+   }
+ | 'FOR' SystemTimeOrSystemVersion 'CURSOR'
+   {
+     parser.suggestKeywords(['AS OF']);
+   }
+ | 'FOR' SystemTimeOrSystemVersion 'AS' 'CURSOR'
+   {
+     parser.suggestKeywords(['OF']);
+   }
+ | 'FOR' SystemTimeOrSystemVersion 'AS' 'OF' 'CURSOR'
+   {
+     parser.valueExpressionSuggest();
+   }
+ ;
+
+SystemTimeOrSystemVersion
+ : 'SYSTEM_TIME'
+ | 'SYSTEM_VERSION'
+ ;
+
 TableOrQueryName
  : SchemaQualifiedTableIdentifier
  ;

+ 1 - 0
desktop/core/src/desktop/js/parse/jison/sql/impala/structure.json

@@ -18,6 +18,7 @@
     "delete/delete.jison",
     "describe/describe.jison",
     "describe/describe_database.jison",
+    "describe/describe_history.jison",
     "drop/drop_aggregate_function.jison",
     "drop/drop_common.jison",
     "drop/drop_database.jison",

File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/generic/genericAutocompleteParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/generic/genericSyntaxParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/impala/impalaAutocompleteParser.js


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/js/parse/sql/impala/impalaSyntaxParser.js


+ 3 - 0
desktop/core/src/desktop/js/parse/sql/impala/sqlParseSupport.js

@@ -29,6 +29,7 @@ const initSqlParser = function (parser) {
 
   parser.DESCRIBE_KEYWORDS = [
     { value: 'DATABASE', weight: 2 },
+    { value: 'HISTORY', weight: 2 },
     { value: 'EXTENDED', weight: 1 },
     { value: 'FORMATTED', weight: 1 }
   ];
@@ -38,6 +39,7 @@ const initSqlParser = function (parser) {
     'ALTER',
     'CREATE',
     'DROP',
+    'GRANT OPTION FOR',
     'INSERT',
     'REFRESH',
     'ROLE',
@@ -1266,6 +1268,7 @@ const initSqlParser = function (parser) {
   parser.suggestFileFormats = function () {
     parser.suggestKeywords([
       'AVRO',
+      'ICEBERG',
       'KUDU',
       'ORC',
       'PARQUET',

+ 65 - 3
desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Alter.test.js

@@ -243,12 +243,14 @@ describe('impalaAutocompleteParser.js ALTER statements', () => {
         expectedResult: {
           lowerCase: false,
           suggestKeywords: [
+            'ADD COLUMN',
             'ADD COLUMNS',
             'ADD PARTITION',
             'ADD RANGE PARTITION',
             'ALTER',
             'ALTER COLUMN',
             'CHANGE',
+            'CHANGE COLUMN',
             'DROP COLUMN',
             'DROP PARTITION',
             'DROP RANGE PARTITION',
@@ -261,10 +263,13 @@ describe('impalaAutocompleteParser.js ALTER statements', () => {
             'SET FILEFORMAT',
             'SET LOCATION',
             'SET OWNER',
+            'SET PARTITION SPEC',
             'SET ROW FORMAT',
             'SET SERDEPROPERTIES',
             'SET TBLPROPERTIES',
-            'SET UNCACHED'
+            'SET UNCACHED',
+            'UNSET SERDEPROPERTIES',
+            'UNSET TBLPROPERTIES'
           ]
         }
       });
@@ -283,6 +288,7 @@ describe('impalaAutocompleteParser.js ALTER statements', () => {
             'LOCATION',
             'OWNER ROLE',
             'OWNER USER',
+            'PARTITION SPEC',
             'ROW FORMAT',
             'SERDEPROPERTIES',
             'TBLPROPERTIES',
@@ -325,6 +331,17 @@ describe('impalaAutocompleteParser.js ALTER statements', () => {
       });
     });
 
+    it('should suggest keywords for "ALTER TABLE bar UNSET |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER TABLE bar UNSET ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['SERDEPROPERTIES', 'TBLPROPERTIES']
+        }
+      });
+    });
+
     it('should suggest keywords for "ALTER TABLE bar ALTER |"', () => {
       assertAutoComplete({
         beforeCursor: 'ALTER TABLE bar ALTER ',
@@ -383,7 +400,7 @@ describe('impalaAutocompleteParser.js ALTER statements', () => {
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestKeywords: ['IF NOT EXISTS', 'COLUMNS', 'PARTITION', 'RANGE PARTITION']
+          suggestKeywords: ['IF NOT EXISTS', 'COLUMN', 'COLUMNS', 'PARTITION', 'RANGE PARTITION']
         }
       });
     });
@@ -477,6 +494,17 @@ describe('impalaAutocompleteParser.js ALTER statements', () => {
       });
     });
 
+    it('should suggest keywords for "ALTER TABLE bar ADD COLUMN a |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER TABLE bar ADD COLUMN a ',
+        afterCursor: '',
+        containsKeywords: ['INT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
     it('should suggest keywords for "ALTER TABLE bar ADD COLUMNS (a INT, b |"', () => {
       assertAutoComplete({
         beforeCursor: 'ALTER TABLE bar ADD COLUMNS (a INT, b ',
@@ -563,7 +591,8 @@ describe('impalaAutocompleteParser.js ALTER statements', () => {
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestColumns: { tables: [{ identifierChain: [{ name: 'bar' }] }] }
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'bar' }] }] },
+          suggestKeywords: ['COLUMN']
         }
       });
     });
@@ -579,6 +608,39 @@ describe('impalaAutocompleteParser.js ALTER statements', () => {
       });
     });
 
+    it('should suggest keywords for "ALTER TABLE bar CHANGE COLUMN foo bar |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER TABLE bar CHANGE COLUMN foo bar ',
+        afterCursor: '',
+        containsKeywords: ['INT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should suggest keywords for "ALTER TABLE bar SET PARTITION |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER TABLE bar SET PARTITION ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['SPEC']
+        }
+      });
+    });
+
+    it('should suggest keywords for "ALTER TABLE bar SET PARTITION SPEC (|"', () => {
+      assertAutoComplete({
+        beforeCursor: 'ALTER TABLE bar SET PARTITION SPEC(',
+        afterCursor: '',
+        containsKeywords: ['YEAR', 'VOID'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
     it('should suggest columns for "ALTER TABLE bar DROP |"', () => {
       assertAutoComplete({
         beforeCursor: 'ALTER TABLE bar DROP ',

+ 57 - 3
desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Create.test.js

@@ -732,9 +732,9 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
       assertAutoComplete({
         beforeCursor: 'CREATE TABLE boo ',
         afterCursor: '',
+        containsKeywords: ['LIKE', 'LIKE PARQUET', 'STORED AS'],
         expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['LIKE', 'LIKE PARQUET']
+          lowerCase: false
         }
       });
     });
@@ -885,6 +885,51 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
       });
     });
 
+    it('should suggest keywords for "CREATE TABLE foo (id int) PARTITIONED BY |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'CREATE TABLE foo (id int) PARTITIONED BY ',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['SPEC']
+        }
+      });
+    });
+
+    it('should suggest keywords for "CREATE TABLE foo (id int) PARTITIONED BY SPEC (|"', () => {
+      assertAutoComplete({
+        beforeCursor: 'CREATE TABLE foo (id int) PARTITIONED BY SPEC (',
+        afterCursor: '',
+        containsKeywords: ['BUCKET', 'VOID'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should suggest keywords for "CREATE TABLE foo (id int) PARTITIONED BY SPEC (BUCKET(5, i), |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'CREATE TABLE foo (id int) PARTITIONED BY SPEC (BUCKET(5, i), ',
+        afterCursor: '',
+        containsKeywords: ['IDENTITY', 'YEAR'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should suggest keywords for "CREATE TABLE foo (id int) PARTITIONED BY SPEC (BUCKET(5, i), MONTH(d), TRUNCATE(3, s), HOUR(t)) |"', () => {
+      assertAutoComplete({
+        beforeCursor:
+          'CREATE TABLE foo (id int) PARTITIONED BY SPEC (BUCKET(5, i), MONTH(d), TRUNCATE(3, s), HOUR(t)) ',
+        afterCursor: '',
+        containsKeywords: ['STORED AS'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
     it('should suggest keywords for "CREATE TABLE foo (id int) WITH |"', () => {
       assertAutoComplete({
         beforeCursor: 'CREATE TABLE foo (id int) WITH ',
@@ -936,7 +981,16 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestKeywords: ['AVRO', 'KUDU', 'ORC', 'PARQUET', 'RCFILE', 'SEQUENCEFILE', 'TEXTFILE']
+          suggestKeywords: [
+            'AVRO',
+            'ICEBERG',
+            'KUDU',
+            'ORC',
+            'PARQUET',
+            'RCFILE',
+            'SEQUENCEFILE',
+            'TEXTFILE'
+          ]
         }
       });
     });

+ 60 - 2
desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Describe.test.js

@@ -133,7 +133,7 @@ describe('impalaAutocompleteParser.js DESCRIBE statements', () => {
       afterCursor: '',
       expectedResult: {
         lowerCase: false,
-        suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED'],
+        suggestKeywords: ['DATABASE', 'HISTORY', 'EXTENDED', 'FORMATTED'],
         suggestTables: {},
         suggestDatabases: { appendDot: true }
       }
@@ -158,7 +158,7 @@ describe('impalaAutocompleteParser.js DESCRIBE statements', () => {
       afterCursor: '',
       expectedResult: {
         lowerCase: false,
-        suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED'],
+        suggestKeywords: ['DATABASE', 'HISTORY', 'EXTENDED', 'FORMATTED'],
         suggestTables: {},
         suggestDatabases: { appendDot: true }
       }
@@ -199,4 +199,62 @@ describe('impalaAutocompleteParser.js DESCRIBE statements', () => {
       }
     });
   });
+
+  it('should suggest tables for "DESCRIBE HISTORY |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'DESCRIBE HISTORY ',
+      afterCursor: '',
+      expectedResult: {
+        lowerCase: false,
+        suggestTables: {},
+        suggestDatabases: { appendDot: true }
+      }
+    });
+  });
+
+  it('should suggest tables for "DESCRIBE HISTORY db.|"', () => {
+    assertAutoComplete({
+      beforeCursor: 'DESCRIBE HISTORY db.',
+      afterCursor: '',
+      expectedResult: {
+        lowerCase: false,
+        suggestTables: { identifierChain: [{ name: 'db' }] }
+      }
+    });
+  });
+
+  it('should suggest tables for "DESCRIBE HISTORY tbl |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'DESCRIBE HISTORY tbl ',
+      afterCursor: '',
+      expectedResult: {
+        lowerCase: false,
+        suggestKeywords: ['BETWEEN', 'FROM']
+      }
+    });
+  });
+
+  it('should suggest tables for "DESCRIBE HISTORY tbl FROM |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'DESCRIBE HISTORY tbl FROM ',
+      afterCursor: '',
+      containsKeywords: ['INTERVAL'],
+      expectedResult: {
+        lowerCase: false,
+        suggestFunctions: {}
+      }
+    });
+  });
+
+  it('should suggest tables for "DESCRIBE HISTORY ice_t BETWEEN \'2022-01-04 10:00:00\' AND |"', () => {
+    assertAutoComplete({
+      beforeCursor: "DESCRIBE HISTORY ice_t BETWEEN '2022-01-04 10:00:00' AND ",
+      afterCursor: '',
+      containsKeywords: [],
+      expectedResult: {
+        lowerCase: false,
+        suggestFunctions: {}
+      }
+    });
+  });
 });

+ 46 - 0
desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Grant.test.js

@@ -273,6 +273,52 @@ describe('impalaAutocompleteParser.js GRANT statements', () => {
         beforeCursor: 'REVOKE ',
         afterCursor: '',
         noErrors: true,
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: [
+            'ALL',
+            'ALTER',
+            'CREATE',
+            'DROP',
+            'GRANT OPTION FOR',
+            'INSERT',
+            'REFRESH',
+            'ROLE',
+            'SELECT'
+          ]
+        }
+      });
+    });
+
+    it('should suggest keywords for "REVOKE GRANT |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'REVOKE GRANT ',
+        afterCursor: '',
+        noErrors: true,
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['OPTION FOR']
+        }
+      });
+    });
+
+    it('should suggest keywords for "REVOKE GRANT OPTION |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'REVOKE GRANT OPTION ',
+        afterCursor: '',
+        noErrors: true,
+        expectedResult: {
+          lowerCase: false,
+          suggestKeywords: ['FOR']
+        }
+      });
+    });
+
+    it('should suggest keywords for "REVOKE GRANT OPTION FOR |"', () => {
+      assertAutoComplete({
+        beforeCursor: 'REVOKE GRANT OPTION FOR ',
+        afterCursor: '',
+        noErrors: true,
         expectedResult: {
           lowerCase: false,
           suggestKeywords: ['ALL', 'ALTER', 'CREATE', 'DROP', 'INSERT', 'REFRESH', 'ROLE', 'SELECT']

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

@@ -359,6 +359,30 @@ describe('impalaAutocompleteParser.js SELECT statements', () => {
       });
     });
 
+    it('should handle "SELECT * FROM ice_t FOR SYSTEM_TIME AS OF now() - interval 5 days;"', () => {
+      assertAutoComplete({
+        beforeCursor: 'SELECT * FROM ice_t FOR SYSTEM_TIME AS OF now() - interval 5 days; ',
+        afterCursor: '',
+        noErrors: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should handle "SELECT * FROM ice_t FOR SYSTEM_VERSION AS OF 123456;"', () => {
+      assertAutoComplete({
+        beforeCursor: 'SELECT * FROM ice_t FOR SYSTEM_VERSION AS OF 123456; ',
+        afterCursor: '',
+        noErrors: true,
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
     it('should suggest columns "SELECT IF(baa, boo, bee) AS b, | FROM testTable;"', () => {
       assertAutoComplete({
         beforeCursor: 'SELECT IF(baa, boo, bee) AS b, ',
@@ -3152,6 +3176,8 @@ describe('impalaAutocompleteParser.js SELECT statements', () => {
         },
         suggestKeywords: [
           'AS',
+          'FOR SYSTEM_TIME AS OF',
+          'FOR SYSTEM_VERSION AS OF',
           'WHERE',
           'GROUP BY',
           'HAVING',
@@ -3182,6 +3208,62 @@ describe('impalaAutocompleteParser.js SELECT statements', () => {
     });
   });
 
+  it('should suggest keywords for "SELECT * FROM testTableA FOR |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'SELECT * FROM testTableA FOR ',
+      afterCursor: '',
+      expectedResult: {
+        lowerCase: false,
+        suggestKeywords: ['SYSTEM_TIME AS OF', 'SYSTEM_VERSION AS OF']
+      }
+    });
+  });
+
+  it('should suggest keywords for "SELECT * FROM SYSTEM_TIME FOR |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'SELECT * FROM testTableA FOR SYSTEM_TIME ',
+      afterCursor: '',
+      expectedResult: {
+        lowerCase: false,
+        suggestKeywords: ['AS OF']
+      }
+    });
+  });
+
+  it('should suggest keywords for "SELECT * FROM SYSTEM_VERSION FOR |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'SELECT * FROM testTableA FOR SYSTEM_VERSION ',
+      afterCursor: '',
+      expectedResult: {
+        lowerCase: false,
+        suggestKeywords: ['AS OF']
+      }
+    });
+  });
+
+  it('should suggest keywords for "SELECT * FROM SYSTEM_TIME FOR AS |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'SELECT * FROM testTableA FOR SYSTEM_TIME AS ',
+      afterCursor: '',
+      expectedResult: {
+        lowerCase: false,
+        suggestKeywords: ['OF']
+      }
+    });
+  });
+
+  it('should suggest keywords for "SELECT * FROM SYSTEM_TIME FOR AS OF |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'SELECT * FROM testTableA FOR SYSTEM_VERSION AS OF ',
+      afterCursor: '',
+      containsKeywords: ['INTERVAL'],
+      expectedResult: {
+        lowerCase: false,
+        suggestFunctions: {}
+      }
+    });
+  });
+
   it('should suggest columns for "SELECT testMap["anyKey"].| FROM testTable"', () => {
     assertAutoComplete({
       beforeCursor: 'SELECT testMap["anyKey"].',
@@ -6537,6 +6619,8 @@ describe('impalaAutocompleteParser.js SELECT statements', () => {
             tables: [{ identifierChain: [{ name: 'table1' }], alias: 't1' }]
           },
           suggestKeywords: [
+            'FOR SYSTEM_TIME AS OF',
+            'FOR SYSTEM_VERSION AS OF',
             'TABLESAMPLE',
             'ANTI',
             'CROSS',

+ 24 - 1
desktop/core/src/desktop/js/parse/sql/impala/test/impalaAutocompleteParser.Show.test.js

@@ -482,7 +482,30 @@ describe('impalaAutocompleteParser.js SHOW statements', () => {
       afterCursor: '',
       expectedResult: {
         lowerCase: false,
-        suggestKeywords: ['DATABASE', 'SERVER', 'TABLE', 'URI']
+        suggestKeywords: ['COLUMN', 'DATABASE', 'SERVER', 'TABLE', 'URI']
+      }
+    });
+  });
+
+  it('should suggest tables for "SHOW GRANT ROLE usr ON COLUMN |"', () => {
+    assertAutoComplete({
+      beforeCursor: 'SHOW GRANT ROLE usr ON COLUMN ',
+      afterCursor: '',
+      expectedResult: {
+        lowerCase: false,
+        suggestDatabases: { appendDot: true },
+        suggestTables: {}
+      }
+    });
+  });
+
+  it('should suggest tables for "SHOW GRANT ROLE usr ON COLUMN db.|"', () => {
+    assertAutoComplete({
+      beforeCursor: 'SHOW GRANT ROLE usr ON COLUMN db.',
+      afterCursor: '',
+      expectedResult: {
+        lowerCase: false,
+        suggestTables: { identifierChain: [{ name: 'db' }] }
       }
     });
   });

Some files were not shown because too many files changed in this diff