Эх сурвалжийг харах

HUE-4725 [editor] The autocompleter should handle Impala complex types in the table list

This is a rather large refactoring of how tables and databases are represented in the suggestions. For Impala it's impossible to know, based on just the statement, whether a reference in the table list after FROM is for a database and table or table and column. Because of this It's now an array of identifiers in the suggestions instead of specific database or table.

This also improves completions throughout
Johan Ahlen 9 жил өмнө
parent
commit
49aa1cd
20 өөрчлөгдсөн 778 нэмэгдсэн , 642 устгасан
  1. 9 9
      desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_alter.jison
  2. 121 116
      desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_create.jison
  3. 13 10
      desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_drop.jison
  4. 92 21
      desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison
  5. 2 1
      desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_show.jison
  6. 0 0
      desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js
  7. 90 110
      desktop/core/src/desktop/static/desktop/js/autocomplete/sql_support.js
  8. 128 67
      desktop/core/src/desktop/static/desktop/js/sqlAutocompleter2.js
  9. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpec.js
  10. 22 22
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAlter.js
  11. 1 1
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAnalyze.js
  12. 19 6
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecCreate.js
  13. 16 22
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe.js
  14. 3 3
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDrop.js
  15. 3 3
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecError.js
  16. 22 22
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecInsert.js
  17. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecLoad.js
  18. 201 179
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSelect.js
  19. 3 9
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecShow.js
  20. 29 37
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecUpdate.js

+ 9 - 9
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_alter.jison

@@ -113,7 +113,7 @@ AlterTable_EDIT
      suggestKeywords(['COLUMNS']);
    }
  | AlterTableLeftSide AnyAdd OptionalIfNotExists_EDIT
- | AlterTableLeftSide AnyAdd OptionalIfNotExists PartitionSpec OptionalHdfsLocation_EDIT OptionalPartitionSpecs
+ | AlterTableLeftSide AnyAdd OptionalIfNotExists PartitionSpec HdfsLocation_EDIT OptionalPartitionSpecs
  | AlterTableLeftSide AnyAdd OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs_EDIT
  | AlterTableLeftSide AnyAdd OptionalIfNotExists PartitionSpec OptionalHdfsLocation OptionalPartitionSpecs 'CURSOR'
    {
@@ -186,7 +186,7 @@ AlterTable_EDIT
  ;
 
 HiveSpecificOperations
- : HiveClusteredBy
+ : ClusteredBy
  | '<hive>SKEWED' 'BY' ParenthesizedColumnList 'ON' ParenthesizedSkewedValueList OptionalStoredAsDirectories
  | HiveExchange
  | '<hive>RECOVER' '<hive>PARTITIONS'
@@ -205,7 +205,7 @@ HiveSpecificOperations_EDIT
      suggestKeywords(['PARTITION']);
    }
  | HiveArchiveOrUnArchive PartitionSpec_EDIT
- | HiveClusteredBy_EDIT
+ | ClusteredBy_EDIT
  | HiveExchange_EDIT
  | 'NOT' 'CURSOR'
    {
@@ -266,9 +266,9 @@ OptionalPartitionOperations
  : 'SET' AnyFileFormat FileFormat
  | 'SET' HdfsLocation
  | 'SET' HiveOrImpalaTblproperties ParenthesizedPropertyAssignmentList
- | 'SET' '<hive>SERDE' QuotedValue OptionalHiveWithSerdeproperties
+ | 'SET' '<hive>SERDE' QuotedValue OptionalWithSerdeproperties
  | 'SET' HiveOrImpalaSerdeproperties ParenthesizedPropertyAssignmentList
- | 'SET' ImpalaCachedIn
+ | 'SET' CachedIn
  | 'SET' '<impala>UNCACHED'
  | AddReplaceColumns
  | '<hive>CONCATENATE'
@@ -311,14 +311,14 @@ OptionalPartitionOperations_EDIT
      suggestFileFormats();
    }
  | 'SET' HdfsLocation_EDIT
- | 'SET' ImpalaCachedIn_EDIT
- | 'SET' '<hive>SERDE' QuotedValue OptionalHiveWithSerdeproperties 'CURSOR'
+ | 'SET' CachedIn_EDIT
+ | 'SET' '<hive>SERDE' QuotedValue OptionalWithSerdeproperties 'CURSOR'
    {
      if (!$4) {
        suggestKeywords(['WITH SERDEPROPERTIES']);
      }
    }
- | 'SET' '<hive>SERDE' QuotedValue OptionalHiveWithSerdeproperties_EDIT
+ | 'SET' '<hive>SERDE' QuotedValue WithSerdeproperties_EDIT
  ;
 
 AddReplaceColumns
@@ -583,7 +583,7 @@ OptionalPartitionSpecs_EDIT
  ;
 
 PartitionSpecWithLocation_EDIT
- : PartitionSpec OptionalHdfsLocation_EDIT
+ : PartitionSpec HdfsLocation_EDIT
  | PartitionSpec_EDIT OptionalHdfsLocation
  ;
 

+ 121 - 116
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_create.jison

@@ -101,7 +101,7 @@ DatabaseDefinitionOptionals
 
 DatabaseDefinitionOptionals_EDIT
  : OptionalComment_INVALID OptionalHdfsLocation OptionalHiveDbProperties
- | OptionalComment OptionalHdfsLocation_EDIT OptionalHiveDbProperties
+ | OptionalComment HdfsLocation_EDIT OptionalHiveDbProperties
  ;
 
 OptionalComment
@@ -129,10 +129,6 @@ OptionalHdfsLocation
  | HdfsLocation
  ;
 
-OptionalHdfsLocation_EDIT
- : HdfsLocation_EDIT
- ;
-
 HdfsLocation
  : HiveOrImpalaLocation HdfsPath
  ;
@@ -211,31 +207,31 @@ TableDefinition_EDIT
  ;
 
 TableDefinitionRightPart
- : TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalImpalaWithSerdeproperties OptionalHiveClusteredBy
-   OptionalHiveSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalImpalaCachedIn OptionalAsSelectStatement
+ : TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
+   OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement
  ;
 
 TableDefinitionRightPart_EDIT
- : TableIdentifierAndOptionalColumnSpecification_EDIT OptionalComment OptionalPartitionedBy OptionalImpalaWithSerdeproperties OptionalHiveClusteredBy
-   OptionalHiveSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalImpalaCachedIn OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy_EDIT OptionalImpalaWithSerdeproperties OptionalHiveClusteredBy
-   OptionalHiveSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalImpalaCachedIn OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalImpalaWithSerdeproperties_EDIT OptionalHiveClusteredBy
-   OptionalHiveSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalImpalaCachedIn OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalImpalaWithSerdeproperties OptionalHiveClusteredBy_EDIT
-   OptionalHiveSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalImpalaCachedIn OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalImpalaWithSerdeproperties OptionalHiveClusteredBy
-   OptionalHiveSkewedBy_EDIT OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalImpalaCachedIn OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalImpalaWithSerdeproperties OptionalHiveClusteredBy
-   OptionalHiveSkewedBy OptionalStoredAsOrBy_EDIT OptionalHdfsLocation OptionalTblproperties OptionalImpalaCachedIn OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalImpalaWithSerdeproperties OptionalHiveClusteredBy
-   OptionalHiveSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation_EDIT OptionalTblproperties OptionalImpalaCachedIn OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalImpalaWithSerdeproperties OptionalHiveClusteredBy
-   OptionalHiveSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalImpalaCachedIn_EDIT OptionalAsSelectStatement
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalImpalaWithSerdeproperties OptionalHiveClusteredBy
-   OptionalHiveSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalImpalaCachedIn OptionalAsSelectStatement_EDIT
- | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalImpalaWithSerdeproperties OptionalHiveClusteredBy
-   OptionalHiveSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalImpalaCachedIn 'CURSOR'
+ : TableIdentifierAndOptionalColumnSpecification_EDIT OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
+   OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment PartitionedBy_EDIT OptionalWithSerdeproperties OptionalClusteredBy
+   OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy WithSerdeproperties_EDIT OptionalClusteredBy
+   OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties ClusteredBy_EDIT
+   OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
+   SkewedBy_EDIT OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
+   OptionalSkewedBy StoredAsOrBy_EDIT OptionalHdfsLocation OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
+   OptionalSkewedBy OptionalStoredAsOrBy HdfsLocation_EDIT OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
+   OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties CachedIn_EDIT OptionalAsSelectStatement
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
+   OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedIn OptionalAsSelectStatement_EDIT
+ | TableIdentifierAndOptionalColumnSpecification OptionalComment OptionalPartitionedBy OptionalWithSerdeproperties OptionalClusteredBy
+   OptionalSkewedBy OptionalStoredAsOrBy OptionalHdfsLocation OptionalTblproperties OptionalCachedIn 'CURSOR'
    {
      // TODO: Don't always sort the keywords as order is important
      var keywords = [];
@@ -290,11 +286,12 @@ TableDefinitionRightPart_EDIT
  ;
 
 TableIdentifierAndOptionalColumnSpecification
- : SchemaQualifiedTableIdentifier OptionalColumnSpecificationsOrLike  -> $2
+ : SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike  -> $2
  ;
 
 TableIdentifierAndOptionalColumnSpecification_EDIT
- : SchemaQualifiedTableIdentifier OptionalColumnSpecificationsOrLike_EDIT
+ : SchemaQualifiedIdentifier OptionalColumnSpecificationsOrLike_EDIT
+ | SchemaQualifiedIdentifier_EDIT OptionalColumnSpecificationsOrLike
  ;
 
 OptionalColumnSpecificationsOrLike
@@ -333,17 +330,21 @@ ColumnSpecificationList
 
 ColumnSpecificationList_EDIT
  : ColumnSpecification_EDIT
+ | ColumnSpecification_EDIT ',' ColumnSpecificationList
+ | ColumnSpecificationList ',' ColumnSpecification_EDIT
+ | ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
  | ColumnSpecification 'CURSOR'
    {
      checkForKeywords($1);
    }
- | ColumnSpecification_EDIT ',' ColumnSpecificationList
  | ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
    {
      checkForKeywords($1);
    }
- | ColumnSpecificationList ',' ColumnSpecification_EDIT
- | ColumnSpecificationList ',' ColumnSpecification_EDIT ',' ColumnSpecificationList
+ | ColumnSpecificationList ',' ColumnSpecification 'CURSOR'
+   {
+     checkForKeywords($3);
+   }
  | ColumnSpecificationList ',' ColumnSpecification 'CURSOR' ',' ColumnSpecificationList
    {
      checkForKeywords($3);
@@ -521,10 +522,14 @@ GreaterThanOrError
 
 OptionalPartitionedBy
  :
- | HiveOrImpalaPartitioned 'BY' ParenthesizedColumnSpecificationList
+ | PartitionedBy
+ ;
+
+PartitionedBy
+ : HiveOrImpalaPartitioned 'BY' ParenthesizedColumnSpecificationList
  ;
 
-OptionalPartitionedBy_EDIT
+PartitionedBy_EDIT
  : HiveOrImpalaPartitioned 'CURSOR'
    {
      suggestKeywords(['BY']);
@@ -537,20 +542,16 @@ OptionalPartitionedBy_EDIT
  | HiveOrImpalaPartitioned ParenthesizedColumnSpecificationList_EDIT
  ;
 
-OptionalHiveClusteredBy
+OptionalClusteredBy
  :
- | HiveClusteredBy
+ | ClusteredBy
  ;
 
-HiveClusteredBy
+ClusteredBy
  : '<hive>CLUSTERED' 'BY' ParenthesizedColumnList OptionalHiveSortedBy 'INTO' 'UNSIGNED_INTEGER' '<hive>BUCKETS'
  ;
 
-OptionalHiveClusteredBy_EDIT
- : HiveClusteredBy_EDIT
- ;
-
-HiveClusteredBy_EDIT
+ClusteredBy_EDIT
  : '<hive>CLUSTERED' 'CURSOR'
    {
      suggestKeywords(['BY']);
@@ -622,13 +623,17 @@ SortIdentifier_EDIT
    }
  ;
 
-OptionalHiveSkewedBy
+OptionalSkewedBy
  :
- | '<hive>SKEWED' 'BY' ParenthesizedColumnList ON ParenthesizedSkewedValueList  -> { suggestKeywords: ['STORED AS DIRECTORIES'] }
+ | SkewedBy
+ ;
+
+SkewedBy
+ : '<hive>SKEWED' 'BY' ParenthesizedColumnList ON ParenthesizedSkewedValueList  -> { suggestKeywords: ['STORED AS DIRECTORIES'] }
  | '<hive>SKEWED' 'BY' ParenthesizedColumnList ON ParenthesizedSkewedValueList '<hive>STORED_AS_DIRECTORIES' // Hack otherwise ambiguous with OptionalHiveStoredAsOrBy
  ;
 
-OptionalHiveSkewedBy_EDIT
+SkewedBy_EDIT
  : '<hive>SKEWED' 'CURSOR'
    {
      suggestKeywords(['BY']);
@@ -650,12 +655,16 @@ SkewedValueList
 
 OptionalStoredAsOrBy
  :
- | StoredAs
+ | StoredAsOrBy
+ ;
+
+StoredAsOrBy
+ : StoredAs
  | 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat OptionalStoredAs
    {
      $$ = mergeSuggestKeywords($3, $4)
    }
- | '<hive>STORED' 'BY' QuotedValue OptionalHiveWithSerdeproperties
+ | '<hive>STORED' 'BY' QuotedValue OptionalWithSerdeproperties
   {
     if (!$4) {
       $$ = { suggestKeywords: ['WITH SERDEPROPERTIES'] };
@@ -663,7 +672,7 @@ OptionalStoredAsOrBy
   }
  ;
 
-OptionalStoredAsOrBy_EDIT
+StoredAsOrBy_EDIT
  : HiveOrImpalaStored 'CURSOR'
    {
      if (isHive()) {
@@ -691,7 +700,7 @@ OptionalStoredAsOrBy_EDIT
      suggestKeywords(['AS']);
    }
  | 'ROW' HiveOrImpalaFormat HiveOrImpalaRowFormat StoredAs_EDIT
- | '<hive>STORED' 'BY' QuotedValue OptionalHiveWithSerdeproperties_EDIT
+ | '<hive>STORED' 'BY' QuotedValue WithSerdeproperties_EDIT
  ;
 
 OptionalStoredAs
@@ -737,7 +746,7 @@ HiveOrImpalaRowFormat_EDIT
 
 HiveRowFormat
  : HiveDelimitedRowFormat
- | '<hive>SERDE' QuotedValue OptionalHiveWithSerdeproperties
+ | '<hive>SERDE' QuotedValue OptionalWithSerdeproperties
    {
      if (!$3) {
        $$ = { suggestKeywords: [{ value: 'WITH SERDEPROPERTIES', weight: 1 }] };
@@ -893,21 +902,17 @@ OptionalNullDefinedAs_EDIT
    }
  ;
 
-OptionalHiveWithSerdeproperties
+OptionalWithSerdeproperties
  :
- | 'WITH' '<hive>SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
+ | WithSerdeproperties
  ;
 
-OptionalHiveWithSerdeproperties_EDIT
- : OptionalImpalaWithSerdeproperties_EDIT
- ;
-
-OptionalImpalaWithSerdeproperties
- :
+WithSerdeproperties
+ : 'WITH' '<hive>SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
  | 'WITH' '<impala>SERDEPROPERTIES' ParenthesizedPropertyAssignmentList
  ;
 
-OptionalImpalaWithSerdeproperties_EDIT
+WithSerdeproperties_EDIT
  : 'WITH' 'CURSOR'
    {
      suggestKeywords(['SERDEPROPERTIES']);
@@ -920,7 +925,11 @@ OptionalImpalaWithSerdeproperties_EDIT
 
 OptionalTblproperties
  :
- | HiveOrImpalaTblproperties ParenthesizedPropertyAssignmentList
+ | TblProperties
+ ;
+ 
+TblProperties
+ : HiveOrImpalaTblproperties ParenthesizedPropertyAssignmentList
  ;
 
 OptionalHiveTblproperties
@@ -948,20 +957,16 @@ CommitLocations
    }
  ;
 
-OptionalImpalaCachedIn
+OptionalCachedIn
  :
- | ImpalaCachedIn
- ;
-
-OptionalImpalaCachedIn_EDIT
- : ImpalaCachedIn_EDIT
+ | CachedIn
  ;
 
-ImpalaCachedIn
+CachedIn
  : '<impala>CACHED' 'IN' SingleQuotedValue
  ;
 
-ImpalaCachedIn_EDIT
+CachedIn_EDIT
  : '<impala>CACHED' 'CURSOR'
    {
      suggestKeywords(['IN']);
@@ -969,7 +974,7 @@ ImpalaCachedIn_EDIT
  ;
 
 ViewDefinition
- : AnyCreate AnyView OptionalIfNotExists SchemaQualifiedTableIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs QuerySpecification
+ : AnyCreate AnyView OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs QuerySpecification
  ;
 
 ViewDefinition_EDIT
@@ -980,14 +985,14 @@ ViewDefinition_EDIT
      }
      suggestDatabases({ appendDot: true });
    }
- | AnyCreate AnyView OptionalIfNotExists 'CURSOR' SchemaQualifiedTableIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs QuerySpecification
+ | AnyCreate AnyView OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs QuerySpecification
    {
      if (!$3) {
        suggestKeywords(['IF NOT EXISTS']);
      }
    }
  | AnyCreate AnyView OptionalIfNotExists_EDIT
- | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedTableIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties 'CURSOR'
+ | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties 'CURSOR'
    {
      if (isHive() && !$6 && !$7) {
        suggestKeywords([{ value: 'COMMENT', weight: 3 }, { value: 'TBLPROPERTIES', weight: 2 }, {value: 'AS', weight: 1 }]);
@@ -997,14 +1002,14 @@ ViewDefinition_EDIT
        suggestKeywords([{value: 'AS', weight: 1 }]);
      }
    }
- | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedTableIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs 'CURSOR'
+ | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs 'CURSOR'
    {
      suggestKeywords(['SELECT']);
    }
- | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedTableIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs QuerySpecification_EDIT
+ | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedIdentifier OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs QuerySpecification_EDIT
+ | AnyCreate AnyView OptionalIfNotExists SchemaQualifiedIdentifier_EDIT OptionalParenthesizedViewColumnList OptionalComment OptionalHiveTblproperties AnyAs QuerySpecification
  ;
 
-// TODO: rename SchemaQualifiedTableIdentifier to SchemaQualifiedIdentifier
 FunctionDefinition
  : ImpalaFunctionDefinition
  | ImpalaAggregateFunctionDefinition
@@ -1020,7 +1025,7 @@ FunctionDefinition_EDIT
  ;
 
 ImpalaFunctionDefinition
- : AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation ImpalaSymbol
+ : AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation ImpalaSymbol
  ;
 
 ImpalaFunctionDefinition_EDIT
@@ -1031,36 +1036,36 @@ ImpalaFunctionDefinition_EDIT
      }
      suggestDatabases({ appendDot: true });
    }
- | AnyCreate '<impala>FUNCTION' OptionalIfNotExists 'CURSOR' SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation ImpalaSymbol
+ | AnyCreate '<impala>FUNCTION' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation ImpalaSymbol
    {
      if (!$3) {
        suggestKeywords(['IF NOT EXISTS']);
      }
    }
- | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList 'CURSOR'
+ | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList 'CURSOR'
    {
      suggestKeywords(['RETURNS']);
    }
- | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns 'CURSOR'
+ | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns 'CURSOR'
    {
      suggestKeywords(['LOCATION']);
    }
- | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation 'CURSOR'
+ | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation 'CURSOR'
    {
      suggestKeywords(['SYMBOL']);
    }
  | AnyCreate '<impala>FUNCTION' OptionalIfNotExists_EDIT
- | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList_EDIT
- | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT
- | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation_EDIT
- | AnyCreate '<impala>FUNCTION' OptionalIfNotExists_EDIT SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation ImpalaSymbol
- | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList_EDIT ImpalaReturns HdfsLocation ImpalaSymbol
- | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT HdfsLocation ImpalaSymbol
- | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation_EDIT ImpalaSymbol
+ | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList_EDIT
+ | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT
+ | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation_EDIT
+ | AnyCreate '<impala>FUNCTION' OptionalIfNotExists_EDIT SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation ImpalaSymbol
+ | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList_EDIT ImpalaReturns HdfsLocation ImpalaSymbol
+ | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT HdfsLocation ImpalaSymbol
+ | AnyCreate '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns HdfsLocation_EDIT ImpalaSymbol
  ;
 
 ImpalaAggregateFunctionDefinition
- : AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ : AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn
  ;
 
@@ -1069,7 +1074,7 @@ ImpalaAggregateFunctionDefinition_EDIT
    {
      suggestKeywords(['FUNCTION']);
    }
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists 'CURSOR' SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists 'CURSOR' SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn
    {
      if (!$4) {
@@ -1084,21 +1089,21 @@ ImpalaAggregateFunctionDefinition_EDIT
      suggestDatabases({ appendDot: true });
    }
  | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists_EDIT
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists_EDIT SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists_EDIT SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList_EDIT
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList_EDIT ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList_EDIT
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList_EDIT ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList 'CURSOR'
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList 'CURSOR'
    {
      suggestKeywords(['RETURNS']);
    }
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    'CURSOR'
    {
      suggestKeywords(['LOCATION']);
    }
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn 'CURSOR'
    {
      if (!$9) {
@@ -1107,12 +1112,12 @@ ImpalaAggregateFunctionDefinition_EDIT
        suggestKeywords([{value: 'UPDATE_FN', weight: 1 }]);
      }
    }
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn 'CURSOR'
    {
      suggestKeywords(['MERGE_FN']);
    }
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn 'CURSOR'
    {
      if (!$12 && !$13 && !$14 && !$15) {
@@ -1125,46 +1130,46 @@ ImpalaAggregateFunctionDefinition_EDIT
        suggestKeywords([{value: 'FINALIZE_FN', weight: 1 }]);
      }
    }
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation_EDIT OptionalImpalaInitFn
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn_EDIT
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn_EDIT
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn_EDIT OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn_EDIT OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn_EDIT  OptionalImpalaSerializeFn OptionalImpalaFinalizeFn
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn_EDIT OptionalImpalaFinalizeFn
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn_EDIT
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns_EDIT
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation_EDIT OptionalImpalaInitFn ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn_EDIT ImpalaUpdateFn ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn
- | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
+ | AnyCreate '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfNotExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList ImpalaReturns
    HdfsLocation OptionalImpalaInitFn ImpalaUpdateFn_EDIT ImpalaMergeFn OptionalImpalaPrepareFn OptionalImpalaCloseFn OptionalImpalaSerializeFn OptionalImpalaFinalizeFn
  ;
 
 HiveFunctionDefinition
- : AnyCreate '<hive>FUNCTION' SchemaQualifiedTableIdentifier '<hive>AS' SingleQuotedValue OptionalHiveUsing
+ : AnyCreate '<hive>FUNCTION' SchemaQualifiedIdentifier '<hive>AS' SingleQuotedValue OptionalHiveUsing
  ;
 
 HiveFunctionDefinition_EDIT
- : AnyCreate '<hive>FUNCTION' SchemaQualifiedTableIdentifier 'CURSOR'
+ : AnyCreate '<hive>FUNCTION' SchemaQualifiedIdentifier 'CURSOR'
    {
      suggestKeywords(['AS']);
    }
- | AnyCreate '<hive>FUNCTION' SchemaQualifiedTableIdentifier '<hive>AS' SingleQuotedValue OptionalHiveUsing_EDIT
- | AnyCreate '<hive>FUNCTION' SchemaQualifiedTableIdentifier '<hive>AS' SingleQuotedValue OptionalHiveUsing 'CURSOR'
+ | AnyCreate '<hive>FUNCTION' SchemaQualifiedIdentifier '<hive>AS' SingleQuotedValue OptionalHiveUsing_EDIT
+ | AnyCreate '<hive>FUNCTION' SchemaQualifiedIdentifier '<hive>AS' SingleQuotedValue OptionalHiveUsing 'CURSOR'
    {
      if (!$6) {
        suggestKeywords(['USING']);
@@ -1422,10 +1427,10 @@ IndexDefinition_EDIT
    '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable_EDIT OptionalStoredAsOrBy OptionalHdfsLocation
    OptionalTblproperties OptionalComment
  | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList
-   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy_EDIT OptionalHdfsLocation
+   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable StoredAsOrBy_EDIT OptionalHdfsLocation
    OptionalTblproperties OptionalComment
  | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList
-   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation_EDIT
+   '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy HdfsLocation_EDIT
    OptionalTblproperties OptionalComment
  | AnyCreate '<hive>INDEX' RegularOrBacktickedIdentifier 'ON' '<hive>TABLE' ExistingTable ParenthesizedIndexColumnList
    '<hive>AS' IndexType OptionalWithDeferredRebuild OptionalIdxProperties OptionalInTable OptionalStoredAsOrBy OptionalHdfsLocation

+ 13 - 10
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_drop.jison

@@ -94,8 +94,8 @@ DropFunctionStatement_EDIT
 
 // OptionalAggregate is no go for look ahead reasons
 DropImpalaFunction
- : 'DROP' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList
- | 'DROP' '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList
+ : 'DROP' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList
+ | 'DROP' '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList
  ;
 
 DropImpalaFunction_EDIT
@@ -113,34 +113,36 @@ DropImpalaFunction_EDIT
      }
      suggestDatabases({ appendDot: true });
    }
- | 'DROP' '<impala>FUNCTION' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList
+ | 'DROP' '<impala>FUNCTION' OptionalIfExists 'CURSOR' SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList
    {
      if (!$3) {
        suggestKeywords(['IF EXISTS']);
      }
    }
  | 'DROP' '<impala>FUNCTION' OptionalIfExists_EDIT
- | 'DROP' 'CURSOR' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList
+ | 'DROP' 'CURSOR' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList
    {
      suggestKeywords(['AGGREGATE']);
    }
- | 'DROP' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList_EDIT
+ | 'DROP' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList_EDIT
  | 'DROP' '<impala>AGGREGATE' 'CURSOR'
    {
      suggestKeywords(['FUNCTION']);
    }
- | 'DROP' '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList
+ | 'DROP' '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfExists 'CURSOR' SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList
    {
      if (!$4) {
        suggestKeywords(['IF EXISTS']);
      }
    }
  | 'DROP' '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfExists_EDIT
- | 'DROP' '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedTableIdentifier ParenthesizedImpalaArgumentList_EDIT
+ | 'DROP' '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedIdentifier ParenthesizedImpalaArgumentList_EDIT
+ | 'DROP' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedIdentifier_EDIT ParenthesizedImpalaArgumentList
+ | 'DROP' '<impala>AGGREGATE' '<impala>FUNCTION' OptionalIfExists SchemaQualifiedIdentifier_EDIT ParenthesizedImpalaArgumentList
  ;
 
 DropHiveFunction
- : 'DROP' '<hive>FUNCTION' OptionalIfExists SchemaQualifiedTableIdentifier
+ : 'DROP' '<hive>FUNCTION' OptionalIfExists SchemaQualifiedIdentifier
  ;
 
 DropHiveFunction_EDIT
@@ -150,14 +152,15 @@ DropHiveFunction_EDIT
        suggestKeywords(['IF EXISTS']);
      }
    }
- | 'DROP' '<hive>FUNCTION' OptionalIfExists 'CURSOR' SchemaQualifiedTableIdentifier
+ | 'DROP' '<hive>FUNCTION' OptionalIfExists 'CURSOR' SchemaQualifiedIdentifier
    {
      if (!$3) {
        suggestKeywords(['IF EXISTS']);
      }
    }
  | 'DROP' '<hive>FUNCTION' OptionalIfExists_EDIT
- | 'DROP' '<hive>FUNCTION' OptionalIfExists_EDIT SchemaQualifiedTableIdentifier
+ | 'DROP' '<hive>FUNCTION' OptionalIfExists_EDIT SchemaQualifiedIdentifier
+ | 'DROP' '<hive>FUNCTION' OptionalIfExists SchemaQualifiedIdentifier_EDIT
  ;
 
 DropRoleStatement

+ 92 - 21
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison

@@ -671,6 +671,11 @@ SchemaQualifiedTableIdentifier
      addTableLocation(@3, [ { name: $1 }, { name: $3 } ]);
      $$ = { identifierChain: [ { name: $1 }, { name: $3 } ] };
    }
+ | RegularOrBacktickedIdentifier AnyDot RegularOrBacktickedIdentifier ImpalaFields
+   {
+     // This is a special case for Impala expression like "SELECT | FROM db.table.col"
+     $$ = { identifierChain: [ { name: $1 }, { name: $3 } ].concat($4) };
+   }
  ;
 
 SchemaQualifiedTableIdentifier_EDIT
@@ -689,6 +694,54 @@ SchemaQualifiedTableIdentifier_EDIT
      // In Impala you can have statements like 'SELECT ... FROM testTable t, t.|'
      suggestTablesOrColumns($1);
    }
+ | RegularOrBacktickedIdentifier AnyDot RegularOrBacktickedIdentifier ImpalaFields_EDIT
+   {
+     // TODO: switch to suggestColumns, it's currently handled in sqlAutocompleter2.js
+     // Issue is that suggestColumns is deleted if no tables are defined and this is
+     // Impala only cases like "SELECT | FROM db.table.col"
+     suggestTables({ identifierChain: [{ name: $1 }, { name: $3 }].concat($4) });
+   }
+ ;
+
+ImpalaFields
+ : ImpalaField               -> [$1]
+ | ImpalaFields ImpalaField
+   {
+     $1.push($2);
+   }
+ ;
+
+ImpalaFields_EDIT
+ : ImpalaField_EDIT                            -> []
+ | ImpalaFields ImpalaField_EDIT               -> $1
+ | ImpalaFields ImpalaField_EDIT ImpalaFields  -> $1
+ | ImpalaField_EDIT ImpalaFields               -> []
+ ;
+
+ImpalaField
+ : '<impala>.' RegularOrBacktickedIdentifier  -> { name: $2 }
+ ;
+
+ImpalaField_EDIT
+ : '<impala>.' PartialBacktickedOrPartialCursor
+ ;
+
+SchemaQualifiedIdentifier
+ : RegularOrBacktickedIdentifier
+ | RegularOrBacktickedIdentifier AnyDot RegularOrBacktickedIdentifier
+ ;
+
+SchemaQualifiedIdentifier_EDIT
+ : PartialBacktickedIdentifier
+   {
+     suggestDatabases({ appendDot: true });
+   }
+ | PartialBacktickedIdentifier AnyDot RegularOrBacktickedIdentifier
+   {
+     suggestDatabases();
+     $$ = { identifierChain: [{ name: $1 }] };
+   }
+ | RegularOrBacktickedIdentifier AnyDot PartialBacktickedOrPartialCursor
  ;
 
 DatabaseIdentifier
@@ -1389,10 +1442,7 @@ TableExpression_EDIT
      if ($2.cursorAtEnd) {
        keywords.push({ value: 'UNION', weight: 2.11 });
      }
-
-     if (keywords.length > 0) {
-       suggestKeywords(keywords);
-     }
+     suggestKeywords(keywords);
    }
  ;
 
@@ -2761,20 +2811,36 @@ WindowExpression
  ;
 
 WindowExpression_EDIT
- : '(' OptionalPartitionBy_EDIT  RightParenthesisOrError
- | '(' AnyCursor RightParenthesisOrError
+ : '(' PartitionBy_EDIT OptionalOrderByAndWindow RightParenthesisOrError
+ | '(' OptionalPartitionBy OptionalOrderByAndWindow_EDIT RightParenthesisOrError
+ | '(' AnyCursor OptionalPartitionBy OptionalOrderByAndWindow RightParenthesisOrError
    {
-     suggestKeywords([{ value: 'PARTITION BY', weight: 2 }, { value: 'ORDER BY', weight: 1 }]);
+     if (!$3 && !$4) {
+       suggestKeywords([{ value: 'PARTITION BY', weight: 2 }, { value: 'ORDER BY', weight: 1 }]);
+     } else if (!$3) {
+       suggestKeywords(['PARTITION BY']);
+     }
    }
- | '(' OptionalPartitionBy OptionalOrderByAndWindow_EDIT RightParenthesisOrError
- ;
+ | '(' AnyPartition 'BY' ValueExpressionList 'CURSOR' OptionalOrderByAndWindow RightParenthesisOrError
+    {
+      if (!$6) {
+        suggestValueExpressionKeywords($4, [{ value: 'ORDER BY', weight: 2 }]);
+      } else {
+        suggestValueExpressionKeywords($4);
+      }
+    }
+  ;
 
 OptionalPartitionBy
  :
- | AnyPartition 'BY' ValueExpressionList
+ | PartitionBy
  ;
 
-OptionalPartitionBy_EDIT
+PartitionBy
+ : AnyPartition 'BY' ValueExpressionList  -> $3
+ ;
+
+PartitionBy_EDIT
  : AnyPartition 'CURSOR'
    {
      suggestKeywords(['BY']);
@@ -2797,25 +2863,30 @@ OptionalOrderByAndWindow_EDIT
       // Only allowed in last order by
       delete parser.yy.result.suggestAnalyticFunctions;
     }
-  | OrderByClause OptionalWindowSpec 'CURSOR'
+  | OrderByClause 'CURSOR' OptionalWindowSpec
     {
-      if (!$2) {
-        if ($1.suggestKeywords) {
-          suggestKeywords(createWeightedKeywords($1.suggestKeywords, 2).concat([{ value: 'RANGE BETWEEN', weight: 1 }, { value: 'ROWS BETWEEN', weight: 1 }]));
-        } else {
-          suggestKeywords(['RANGE BETWEEN', 'ROWS BETWEEN']);
-        }
+      var keywords = [];
+      if ($1.suggestKeywords) {
+        keywords = createWeightedKeywords($1.suggestKeywords, 2);
+      }
+      if (!$3) {
+        keywords = keywords.concat([{ value: 'RANGE BETWEEN', weight: 1 }, { value: 'ROWS BETWEEN', weight: 1 }]);
       }
+      suggestKeywords(keywords);
     }
-  | OrderByClause OptionalWindowSpec_EDIT
+  | OrderByClause WindowSpec_EDIT
   ;
 
 OptionalWindowSpec
  :
- | RowsOrRange 'BETWEEN' PopLexerState OptionalCurrentOrPreceding OptionalAndFollowing
+ | WindowSpec
+ ;
+
+WindowSpec
+ : RowsOrRange 'BETWEEN' PopLexerState OptionalCurrentOrPreceding OptionalAndFollowing
  ;
 
-OptionalWindowSpec_EDIT
+WindowSpec_EDIT
  : RowsOrRange 'CURSOR'
    {
      suggestKeywords(['BETWEEN']);

+ 2 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_show.jison

@@ -64,6 +64,7 @@ ShowStatement_EDIT
      // ROLES is considered a non-reserved keywords so we can't match it in ShowCurrentRolesStatement_EDIT
      if ($3.identifierChain && $3.identifierChain.length === 1 && $3.identifierChain[0].name.toLowerCase() === 'roles') {
        suggestKeywords(['CURRENT']);
+       parser.yy.locations.pop();
      } else {
        addTablePrimary($3);
        if (isImpala()) {
@@ -340,7 +341,7 @@ ShowIndexStatement_EDIT
    }
  | AnyShow OptionallyFormattedIndex 'ON' 'CURSOR' AnyFromOrIn RegularOrBacktickedIdentifier
    {
-     suggestTablesOrColumns($6);
+     suggestTables({identifierChain: [{name: $6}]});
    }
  ;
 

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js


+ 90 - 110
desktop/core/src/desktop/static/desktop/js/autocomplete/sql_support.js

@@ -203,10 +203,10 @@ var applyTypeToSuggestions = function (types) {
   if (types[0] === 'BOOLEAN') {
     return;
   }
-  if (parser.yy.result.suggestFunctions) {
+  if (parser.yy.result.suggestFunctions && !parser.yy.result.suggestFunctions.types) {
     parser.yy.result.suggestFunctions.types = types;
   }
-  if (parser.yy.result.suggestColumns) {
+  if (parser.yy.result.suggestColumns && !parser.yy.result.suggestColumns.types) {
     parser.yy.result.suggestColumns.types = types;
   }
 };
@@ -246,16 +246,26 @@ var commitLocations = function () {
   var i = parser.yy.locations.length;
   while (i--) {
     var location = parser.yy.locations[i];
-    expandIdentifierChain(location, true);
+
     // Impala can have references to previous tables after FROM, i.e. FROM testTable t, t.testArray
     // In this testArray would be marked a type table so we need to switch it to column.
-    if (location.type === 'table' && location.table && typeof location.identifierChain !== 'undefined' && location.identifierChain.length > 0) {
-      location.type = 'column';
+    if (location.type === 'table' && typeof location.identifierChain !== 'undefined' && location.identifierChain.length > 1 && parser.yy.latestTablePrimaries) {
+      var found = parser.yy.latestTablePrimaries.filter(function (primary) {
+        return primary.alias === location.identifierChain[0].name;
+      });
+      if (found.length > 0) {
+        location.type = 'column';
+      }
+    }
+
+    if (location.type === 'column') {
+      expandIdentifierChain(location, true);
     }
-    if (location.type === 'table' && typeof location.table === 'undefined') {
+
+    if (location.type === 'table' && (typeof location.identifierChain === 'undefined' || location.identifierChain.length === 0)) {
       parser.yy.locations.splice(i, 1);
     }
-    if (location.type === 'column' && (typeof location.table === 'undefined' || typeof location.identifierChain === 'undefined')) {
+    if (location.type === 'column' && (typeof location.identifierChain === 'undefined' || location.identifierChain.length < 2)) {
       parser.yy.locations.splice(i, 1);
     }
   }
@@ -268,7 +278,7 @@ var commitLocations = function () {
 var prioritizeSuggestions = function () {
   parser.yy.result.lowerCase = parser.yy.lowerCase || false;
   if (typeof parser.yy.result.colRef !== 'undefined') {
-    if (typeof parser.yy.result.colRef.table === '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(function (type) {
@@ -293,7 +303,8 @@ var prioritizeSuggestions = function () {
   if (typeof parser.yy.result.suggestIdentifiers !== 'undefined' && parser.yy.result.suggestIdentifiers.length > 0) {
     delete parser.yy.result.suggestTables;
     delete parser.yy.result.suggestDatabases;
-  } else if (typeof parser.yy.result.suggestColumns !== 'undefined') {
+  }
+  if (typeof parser.yy.result.suggestColumns !== 'undefined') {
     if (typeof parser.yy.result.suggestColumns.tables === 'undefined' || parser.yy.result.suggestColumns.tables.length === 0) {
       delete parser.yy.result.suggestColumns;
       delete parser.yy.result.subQueries;
@@ -349,7 +360,6 @@ parser.expandImpalaIdentifierChain = function (tablePrimaries, identifierChain)
   if (typeof expandedChain === 'undefined' || expandedChain.length === 0) {
     return identifierChain;
   }
-
   var expand = function (identifier, expandedChain) {
     var foundPrimary = tablePrimaries.filter(function (tablePrimary) {
       return tablePrimary.alias === identifier;
@@ -441,38 +451,31 @@ var expandIdentifierChain = function (wrapper, anyOwner) {
   var identifierChain = wrapper.identifierChain.concat();
   var tablePrimaries = parser.yy.latestTablePrimaries;
 
-  if (!anyOwner) {
-    tablePrimaries = filterTablePrimariesForOwner(wrapper.owner);
+  if (tablePrimaries.length === 0) {
+    delete wrapper.identifierChain;
+    return;
   }
 
   if (identifierChain.length > 0 && identifierChain[identifierChain.length - 1].asterisk) {
     var tables = [];
     tablePrimaries.forEach(function (tablePrimary) {
-      if (tablePrimary.identifierChain && tablePrimary.identifierChain.length == 1) {
-        tables.push({table: tablePrimary.identifierChain[0].name});
-      } else if (tablePrimary.identifierChain && tablePrimary.identifierChain.length == 2) {
-        tables.push({database: tablePrimary.identifierChain[0].name, table: tablePrimary.identifierChain[1].name});
+      if (tablePrimary.subQueryAlias) {
+        tables.push({ identifierChain: [{ subQuery: tablePrimary.subQueryAlias }]})
+      } else {
+        tables.push({ identifierChain: tablePrimary.identifierChain });
       }
     });
     // Possible Joins
-    if (tables.length > 1) {
+    if (tables.length > 0) {
       wrapper.tables = tables;
       delete wrapper.identifierChain;
       return;
-    } else if (tables.length === 1) {
-      if (wrapper.tables) {
-        wrapper.tables.push(tables[0]);
-      } else {
-        if (tables[0].database) {
-          wrapper.database = tables[0].database;
-        }
-        wrapper.table = tables[0].table;
-      }
-      delete wrapper.identifierChain;
-      return;
     }
   }
 
+  if (!anyOwner) {
+    tablePrimaries = filterTablePrimariesForOwner(wrapper.owner);
+  }
   // Impala can have references to maps or array, i.e. FROM table t, t.map m
   // We need to replace those in the identifierChain
   if (isImpala()) {
@@ -488,91 +491,65 @@ var expandIdentifierChain = function (wrapper, anyOwner) {
   // 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
   if (identifierChain.length > 0) {
-    var foundTable = tablePrimaries.filter(function (tablePrimary) {
-      return identifierChain[0].name === tablePrimary.alias || identifierChain[0].name === tablePrimary.subQueryAlias;
-    });
-
-    var dbAndTable = false;
-    if (foundTable.length === 0) {
-      // Give priority to the ones that match both DB and table
-      if (identifierChain.length > 1) {
-        foundTable = tablePrimaries.filter(function (tablePrimary) {
-          return tablePrimary.identifierChain && tablePrimary.identifierChain.length > 1 &&
-              tablePrimary.identifierChain[0].name === identifierChain[0].name &&
-              tablePrimary.identifierChain[1].name === identifierChain[1].name;
-        });
-        dbAndTable = foundTable.length > 0;
-      }
-      if (foundTable.length == 0) {
-        foundTable = tablePrimaries.filter(function (tablePrimary) {
-          return tablePrimary.identifierChain && tablePrimary.identifierChain.length > 0 &&
-              tablePrimary.identifierChain[0].name === identifierChain[0].name;
-        });
+    var foundPrimary;
+    var doubleMatch = false;
+    for (var i = 0; i < tablePrimaries.length; i++) {
+      if (tablePrimaries[i].subQueryAlias) {
+        if (tablePrimaries[i].subQueryAlias === identifierChain[0].name) {
+          foundPrimary = tablePrimaries[i];
+        }
+      } else if (tablePrimaries[i].alias === identifierChain[0].name) {
+        foundPrimary = tablePrimaries[i];
+        break;
+      } else if (tablePrimaries[i].identifierChain.length > 1 && identifierChain.length > 1 &&
+          tablePrimaries[i].identifierChain[0].name === identifierChain[0].name &&
+          tablePrimaries[i].identifierChain[1].name === identifierChain[1].name) {
+        foundPrimary = tablePrimaries[i];
+        doubleMatch = true;
+        break;
+      } else if (!foundPrimary && tablePrimaries[i].identifierChain[0].name === identifierChain[0].name) {
+        foundPrimary = tablePrimaries[i];
+        // No break as first two can still match.
       }
     }
-
-    if (foundTable.length === 1) {
-      tablePrimaries = foundTable;
+    if (foundPrimary) {
       identifierChain.shift();
-      if (dbAndTable) {
+      if (doubleMatch) {
         identifierChain.shift();
       }
-      wrapper.identifierChain = identifierChain;
+    } else if (tablePrimaries.length === 1) {
+      foundPrimary = tablePrimaries[0];
     }
-  }
-
-  if (identifierChain.length == 0) {
-    delete wrapper.identifierChain;
-  }
-
-  if (tablePrimaries.length === 1) {
-    var targetTable = wrapper;
-    if (wrapper.tables) {
-      if (wrapper.identifierChain && wrapper.identifierChain.length > 0) {
-        targetTable = { identifierChain: wrapper.identifierChain };
+    if (foundPrimary) {
+      if (foundPrimary.subQueryAlias) {
+        identifierChain.unshift({ subQuery: foundPrimary.subQueryAlias });
       } else {
-        targetTable = {};
+        identifierChain = foundPrimary.identifierChain.concat(identifierChain);
       }
-      wrapper.tables.push(targetTable);
-    }
-    if (typeof tablePrimaries[0].identifierChain !== 'undefined') {
-      if (tablePrimaries[0].identifierChain.length == 2) {
-        targetTable.database = tablePrimaries[0].identifierChain[0].name;
-        targetTable.table = tablePrimaries[0].identifierChain[1].name;
+      if (wrapper.tables) {
+        wrapper.tables.push({ identifierChain: identifierChain });
+        delete wrapper.identifierChain;
       } else {
-        targetTable.table = tablePrimaries[0].identifierChain[0].name;
+        wrapper.identifierChain = identifierChain;
       }
-    } else if (tablePrimaries[0].subQueryAlias !== 'undefined') {
-      targetTable.subQuery = tablePrimaries[0].subQueryAlias;
     }
+  } else {
+    tablePrimaries.forEach(function (tablePrimary) {
+      var targetTable = { identifierChain: tablePrimary.identifierChain };
+      if (tablePrimary.alias) {
+        targetTable.alias = tablePrimary.alias;
+      }
+      if (wrapper.tables) {
+        wrapper.tables.push(targetTable)
+      }
+
+    });
   }
+
   delete wrapper.owner;
   wrapper.linked = true;
 };
 
-var suggestTablePrimariesAsIdentifiers = function () {
-  if (typeof parser.yy.result.suggestIdentifiers === 'undefined') {
-    parser.yy.result.suggestIdentifiers = [];
-  }
-  parser.yy.latestTablePrimaries.forEach(function (tablePrimary) {
-    if (typeof tablePrimary.alias !== 'undefined') {
-      parser.yy.result.suggestIdentifiers.push({name: tablePrimary.alias + '.', type: 'alias'});
-    } else if (typeof tablePrimary.identifierChain !== 'undefined' && tablePrimary.identifierChain.length == 2) {
-      parser.yy.result.suggestIdentifiers.push({
-        name: tablePrimary.identifierChain[0].name + '.' + tablePrimary.identifierChain[1].name + '.',
-        type: 'table'
-      });
-    } else if (typeof tablePrimary.identifierChain !== 'undefined') {
-      parser.yy.result.suggestIdentifiers.push({name: tablePrimary.identifierChain[0].name + '.', type: 'table'});
-    } else if (typeof tablePrimary.subQueryAlias !== 'undefined') {
-      parser.yy.result.suggestIdentifiers.push({name: tablePrimary.subQueryAlias + '.', type: 'sub-query'});
-    }
-  });
-  if (parser.yy.result.suggestIdentifiers.length === 0) {
-    delete parser.yy.result.suggestIdentifiers;
-  }
-};
-
 var suggestLateralViewAliasesAsIdentifiers = function () {
   if (typeof parser.yy.lateralViews === 'undefined' || parser.yy.lateralViews.length === 0) {
     return;
@@ -610,13 +587,7 @@ var convertTablePrimariesToSuggestions = function (tablePrimaries) {
   var impalaIdentifiers = [];
   tablePrimaries.forEach(function (tablePrimary) {
     if (tablePrimary.identifierChain && tablePrimary.identifierChain.length > 0) {
-      var table = {};
-      if (tablePrimary.identifierChain.length > 1) {
-        table.database = tablePrimary.identifierChain[0].name;
-        table.table = tablePrimary.identifierChain[1].name;
-      } else {
-        table.table = tablePrimary.identifierChain[0].name;
-      }
+      var table = { identifierChain: tablePrimary.identifierChain };
       if (tablePrimary.alias) {
         table.alias = tablePrimary.alias;
         if (isImpala()) {
@@ -630,7 +601,7 @@ var convertTablePrimariesToSuggestions = function (tablePrimaries) {
       }
       tables.push(table);
     } else if (tablePrimary.subQueryAlias) {
-      tables.push({ subQuery: tablePrimary.subQueryAlias });
+      tables.push({ identifierChain: [{ subQuery: tablePrimary.subQueryAlias }] });
     }
   });
   if (impalaIdentifiers.length > 0) {
@@ -671,8 +642,14 @@ var linkTablePrimaries = function () {
       expandIdentifierChain(parser.yy.result.suggestColumns);
     }
   }
+
   if (typeof parser.yy.result.colRef !== 'undefined' && !parser.yy.result.colRef.linked) {
     expandIdentifierChain(parser.yy.result.colRef);
+
+    var primaries = filterTablePrimariesForOwner();
+    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) {
     expandIdentifierChain(parser.yy.result.suggestKeyValues);
@@ -812,6 +789,9 @@ var createWeightedKeywords = function (keywords, weight) {
 
 var suggestKeywords = function (keywords) {
   var weightedKeywords = [];
+  if (keywords.length == 0) {
+    return;
+  }
   keywords.forEach(function (keyword) {
     if (typeof keyword.weight !== 'undefined') {
       weightedKeywords.push(keyword);
@@ -834,16 +814,16 @@ var suggestColRefKeywords = function (colRefKeywords) {
 
 var suggestTablesOrColumns = function (identifier) {
   if (typeof parser.yy.latestTablePrimaries == 'undefined') {
-    suggestTables({database: identifier});
+    suggestTables({ identifierChain: [{ name: identifier }] });
     return;
   }
   var tableRef = parser.yy.latestTablePrimaries.filter(function (tablePrimary) {
     return tablePrimary.alias === identifier;
   });
   if (tableRef.length > 0) {
-    suggestColumns({identifierChain: [{name: identifier}]});
+    suggestColumns({identifierChain: [{ name: identifier }]});
   } else {
-    suggestTables({database: identifier});
+    suggestTables({ identifierChain: [{ name: identifier }] });
   }
 };
 
@@ -1028,6 +1008,8 @@ parser.parseSql = function (beforeCursor, afterCursor, dialect, sqlFunctions, de
   commitLocations();
 
   // Clean up and prioritize
+  prioritizeSuggestions();
+
   parser.yy.allLocations.sort(function (a, b) {
     if (a.location.first_line !== b.location.first_line) {
       return a.location.first_line - b.location.first_line;
@@ -1049,8 +1031,6 @@ parser.parseSql = function (beforeCursor, afterCursor, dialect, sqlFunctions, de
     delete parser.yy.result.suggestKeyValues.linked;
   }
 
-  prioritizeSuggestions();
-
   if (typeof result.error !== 'undefined' && typeof result.error.expected !== 'undefined') {
     // Remove any expected tokens from other dialects, jison doesn't remove tokens from other lexer states.
     var actualExpected = {};

+ 128 - 67
desktop/core/src/desktop/static/desktop/js/sqlAutocompleter2.js

@@ -112,7 +112,7 @@
       if (foundVarRef.length > 0) {
         colRefCallback({ type: 'T' });
       } else {
-        self.fetchFieldsForIdentifiers(parseResult.colRef.table, parseResult.colRef.database || database, parseResult.colRef.identifierChain, colRefCallback, colRefDeferral.resolve);
+        self.fetchFieldsForIdentifiers(database, parseResult.colRef.identifierChain, colRefCallback, colRefDeferral.resolve);
       }
 
     } else {
@@ -205,7 +205,34 @@
     }
 
     if (parseResult.suggestTables) {
-      deferrals.push(self.addTables(parseResult, database, completions))
+      if (self.snippet.type() == 'impala' && parseResult.suggestTables.identifierChain && parseResult.suggestTables.identifierChain.length === 1) {
+        var checkDbDeferral = $.Deferred();
+        self.snippet.getApiHelper().loadDatabases({
+          sourceType: self.snippet.type(),
+          successCallback: function (data) {
+            var foundDb = data.filter(function (db) {
+              return db === parseResult.suggestTables.identifierChain[0].name;
+            });
+            if (foundDb.length > 0) {
+              deferrals.push(self.addTables(parseResult, database, completions));
+            } else {
+              parseResult.suggestColumns = { tables: [{ identifierChain: parseResult.suggestTables.identifierChain }] };
+              delete parseResult.suggestTables;
+              deferrals.push(self.addColumns(parseResult, parseResult.suggestColumns.tables[0], database, parseResult.suggestColumns.types || ['T'], columnSuggestions));
+            }
+            checkDbDeferral.resolve();
+          },
+          silenceErrors: true,
+          errorCallback: checkDbDeferral.resolve
+        });
+        deferrals.push(checkDbDeferral);
+      } else if (self.snippet.type() == 'impala' && parseResult.suggestTables.identifierChain && parseResult.suggestTables.identifierChain.length > 1) {
+        parseResult.suggestColumns = { tables: [{ identifierChain: parseResult.suggestTables.identifierChain }] };
+        delete parseResult.suggestTables;
+        deferrals.push(self.addColumns(parseResult, parseResult.suggestColumns.tables[0], database, parseResult.suggestColumns.types || ['T'], columnSuggestions));
+      } else {
+        deferrals.push(self.addTables(parseResult, database, completions))
+      }
     }
 
     $.when.apply($, deferrals).done(function () {
@@ -264,78 +291,112 @@
     });
   };
 
-  SqlAutocompleter2.prototype.fetchFieldsForIdentifiers = function (tableName, databaseName, identifierChain, callback, errorCallback, fetchedFields) {
+  SqlAutocompleter2.prototype.fetchFieldsForIdentifiers = function (defaultDatabase, identifierChain, callback, errorCallback) {
     var self = this;
-    if (!fetchedFields) {
-      fetchedFields = [];
-    }
-    if (!identifierChain) {
-      identifierChain = [];
-    }
-    if (identifierChain.length > 0) {
-      fetchedFields.push(identifierChain[0].name);
-      identifierChain = identifierChain.slice(1);
-    }
 
-    // Parser sometimes knows if it's a map or array.
-    if (identifierChain.length > 0 && (identifierChain[0].name === 'item' || identifierChain[0].name === 'value')) {
-      fetchedFields.push(identifierChain[0].name);
-      identifierChain = identifierChain.slice(1);
-    }
+    var fetchFieldsInternal =  function (table, database, identifierChain, callback, errorCallback, fetchedFields) {
+      if (!identifierChain) {
+        identifierChain = [];
+      }
+      if (identifierChain.length > 0) {
+        fetchedFields.push(identifierChain[0].name);
+        identifierChain = identifierChain.slice(1);
+      }
 
-    self.snippet.getApiHelper().fetchFields({
-      sourceType: self.snippet.type(),
-      databaseName: databaseName,
-      tableName: tableName,
-      fields: fetchedFields,
-      timeout: self.timeout,
-      successCallback: function (data) {
-        if (identifierChain.length > 0) {
-          if (data.type === 'array') {
-            fetchedFields.push('item')
-          }
-          if (data.type === 'map') {
-            fetchedFields.push('value')
+      // Parser sometimes knows if it's a map or array.
+      if (identifierChain.length > 0 && (identifierChain[0].name === 'item' || identifierChain[0].name === 'value')) {
+        fetchedFields.push(identifierChain[0].name);
+        identifierChain = identifierChain.slice(1);
+      }
+
+      self.snippet.getApiHelper().fetchFields({
+        sourceType: self.snippet.type(),
+        databaseName: database,
+        tableName: table,
+        fields: fetchedFields,
+        timeout: self.timeout,
+        successCallback: function (data) {
+          if (identifierChain.length > 0) {
+            if (data.type === 'array') {
+              fetchedFields.push('item')
+            }
+            if (data.type === 'map') {
+              fetchedFields.push('value')
+            }
+            fetchFieldsInternal(table, database, identifierChain, callback, errorCallback, fetchedFields)
+          } else {
+            callback(data);
           }
-          self.fetchFieldsForIdentifiers(tableName, databaseName, identifierChain, callback, errorCallback, fetchedFields)
-        } else {
-          callback(data);
-        }
-      },
-      silenceErrors: true,
-      errorCallback: errorCallback
-    });
+        },
+        silenceErrors: true,
+        errorCallback: errorCallback
+      });
+    };
+
+    // For Impala the first parts of the identifier chain could be either database or table, either:
+    // SELECT | FROM database.table -or- SELECT | FROM table.column
+    if (self.snippet.type() === 'impala') {
+      if (identifierChain.length > 1) {
+        self.snippet.getApiHelper().loadDatabases({
+          sourceType: self.snippet.type(),
+          successCallback: function (data) {
+            var foundDb = data.filter(function (db) {
+              return db === identifierChain[0].name;
+            });
+            var databaseName = foundDb.length > 0 ? identifierChain.shift().name : defaultDatabase;
+            var tableName = identifierChain.shift().name;
+            fetchFieldsInternal(tableName, databaseName, identifierChain, callback, errorCallback, []);
+          },
+          silenceErrors: true,
+          errorCallback: errorCallback
+        });
+      } else {
+        var databaseName = defaultDatabase;
+        var tableName = identifierChain.shift().name;
+        fetchFieldsInternal(tableName, databaseName, identifierChain, callback, errorCallback, []);
+      }
+    } else {
+      var databaseName = identifierChain.length > 1 ? identifierChain.shift().name : defaultDatabase;
+      var tableName = identifierChain.shift().name;
+      fetchFieldsInternal(tableName, databaseName, identifierChain, callback, errorCallback, []);
+    }
   };
 
-  SqlAutocompleter2.prototype.addTables = function (parseResult, database, completions) {
+  SqlAutocompleter2.prototype.addTables = function (parseResult, defaultDatabase, completions) {
     var self = this;
     var tableDeferred = $.Deferred();
-    var prefix = parseResult.suggestTables.prependQuestionMark ? '? ' : '';
-    if (parseResult.suggestTables.prependFrom) {
-      prefix += parseResult.lowerCase ? 'from ' : 'FROM ';
-    }
 
-    self.snippet.getApiHelper().fetchTables({
-      sourceType: self.snippet.type(),
-      databaseName: parseResult.suggestTables.database || database,
-      successCallback: function (data) {
-        data.tables_meta.forEach(function (tablesMeta) {
-          if (parseResult.suggestTables.onlyTables && tablesMeta.type.toLowerCase() !== 'table' ||
-              parseResult.suggestTables.onlyViews && tablesMeta.type.toLowerCase() !== 'view') {
-            return;
-          }
-          completions.push({
-            value: prefix + self.backTickIfNeeded(tablesMeta.name),
-            meta: tablesMeta.type.toLowerCase(),
-            weight: DEFAULT_WEIGHTS.TABLE
-          })
-        });
-        tableDeferred.resolve();
-      },
-      silenceErrors: true,
-      errorCallback: tableDeferred.resolve,
-      timeout: self.timeout
-    });
+    var fetchTablesInternal = function (databaseName) {
+      var prefix = parseResult.suggestTables.prependQuestionMark ? '? ' : '';
+      if (parseResult.suggestTables.prependFrom) {
+        prefix += parseResult.lowerCase ? 'from ' : 'FROM ';
+      }
+
+      self.snippet.getApiHelper().fetchTables({
+        sourceType: self.snippet.type(),
+        databaseName: databaseName,
+        successCallback: function (data) {
+          data.tables_meta.forEach(function (tablesMeta) {
+            if (parseResult.suggestTables.onlyTables && tablesMeta.type.toLowerCase() !== 'table' ||
+                parseResult.suggestTables.onlyViews && tablesMeta.type.toLowerCase() !== 'view') {
+              return;
+            }
+            completions.push({
+              value: prefix + self.backTickIfNeeded(tablesMeta.name),
+              meta: tablesMeta.type.toLowerCase(),
+              weight: DEFAULT_WEIGHTS.TABLE
+            })
+          });
+          tableDeferred.resolve();
+        },
+        silenceErrors: true,
+        errorCallback: tableDeferred.resolve,
+        timeout: self.timeout
+      });
+    };
+
+    var database = parseResult.suggestTables.identifierChain && parseResult.suggestTables.identifierChain.length === 1 ? parseResult.suggestTables.identifierChain[0].name : defaultDatabase;
+    fetchTablesInternal(database);
     return tableDeferred;
   };
 
@@ -414,7 +475,7 @@
         } else if (data.type === 'map' && (data.value && data.value.fields)) {
           data.value.fields.forEach(function (field) {
             if (sqlFunctions.matchesType(self.snippet.type(), types, [field.type.toUpperCase()]) ||
-                sqlFunctions.matchesType(self.snippet.type(), [column.type.toUpperCase()], types)) {
+                sqlFunctions.matchesType(self.snippet.type(), [field.type.toUpperCase()], types)) {
               columnSuggestions.push({value: self.backTickIfNeeded(field.name), meta: field.type, weight: DEFAULT_WEIGHTS.COLUMN, table: table });
             }
           });
@@ -435,7 +496,7 @@
         addColumnsDeferred.resolve();
       };
 
-      self.fetchFieldsForIdentifiers(table.table, table.database || database, table.identifierChain, callback, addColumnsDeferred.resolve);
+      self.fetchFieldsForIdentifiers(database, table.identifierChain, callback, addColumnsDeferred.resolve);
     }
     return addColumnsDeferred;
   };

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpec.js

@@ -361,7 +361,7 @@ define([
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false,
-          locations: [{ type: 'table', location: { first_line:2, last_line:2, first_column:15, last_column:25 }, table: 'testTable1' }]
+          locations: [{ type: 'table', location: { first_line:2, last_line:2, first_column:15, last_column:25 }, identifierChain: [{ name: 'testTable1' }] }]
         }
       });
     });
@@ -373,7 +373,7 @@ define([
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false,
-          locations: [{ type: 'table', location: { first_line:4, last_line:4, first_column:15, last_column:25 }, table: 'testTable1' }]
+          locations: [{ type: 'table', location: { first_line:4, last_line:4, first_column:15, last_column:25 }, identifierChain: [{ name: 'testTable1' }] }]
         }
       });
     });

+ 22 - 22
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAlter.js

@@ -139,7 +139,7 @@ define([
           afterCursor: '',
           expectedResult: {
             lowerCase: false,
-            suggestTables: { database: 'foo', onlyTables: true  }
+            suggestTables: { identifierChain: [{ name: 'foo' }], onlyTables: true  }
           }
         });
       });
@@ -325,7 +325,7 @@ define([
             dialect: 'hive',
             hasLocations: true,
             expectedResult: {
-              suggestColumns: { tables: [{ table: 'bar' }] },
+              suggestColumns: { tables: [{ identifierChain: [{ name: 'bar' }] }] } ,
               lowerCase: false
             }
           });
@@ -339,7 +339,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] }
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -391,7 +391,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] },
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] },
               suggestKeywords: ['COLUMN']
             }
           });
@@ -444,7 +444,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar'}] }
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -457,7 +457,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar'}] }
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -509,7 +509,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] }
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -522,7 +522,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] }
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -574,7 +574,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ database: 'foo', table: 'bar' }] }
+              suggestColumns: { tables: [{ identifierChain: [{ name: 'foo' }, { name: 'bar' }] }] }
             }
           });
         });
@@ -653,7 +653,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] }
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -864,7 +864,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] },
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] },
               suggestKeywords: ['COLUMN']
             }
           });
@@ -930,7 +930,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar'}] }
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -943,7 +943,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar'}] }
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -1281,7 +1281,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] }
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -1294,7 +1294,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] }
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -1320,7 +1320,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] }
+              suggestColumns:  { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -1333,7 +1333,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ database: 'foo', table: 'bar' }] }
+              suggestColumns: { tables: [{ identifierChain: [{ name: 'foo' }, { name: 'bar' }] }] }
             }
           });
         });
@@ -1519,7 +1519,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] }
+              suggestColumns: { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -1532,7 +1532,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] }
+              suggestColumns: { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -1558,7 +1558,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] },
+              suggestColumns: { tables: [{ identifierChain: [{ name: 'bar' }] }] },
               suggestKeywords: ['COLUMN', 'PARTITION']
             }
           });
@@ -1573,7 +1573,7 @@ define([
             hasLocations: true,
             expectedResult: {
               lowerCase: false,
-              suggestColumns: { tables: [{ table: 'bar' }] }
+              suggestColumns: { tables: [{ identifierChain: [{ name: 'bar' }] }] }
             }
           });
         });
@@ -1689,7 +1689,7 @@ define([
           afterCursor: '',
           expectedResult: {
             lowerCase: false,
-            suggestTables: { database: 'boo', onlyViews: true }
+            suggestTables: { identifierChain: [{ name: 'boo' }], onlyViews: true }
           }
         });
       });

+ 1 - 1
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAnalyze.js

@@ -93,7 +93,7 @@ define([
           noErrors:true,
           expectedResult: {
             lowerCase: false,
-            suggestTables: { database: 'boo', onlyTables: true }
+            suggestTables: { identifierChain: [{ name: 'boo' }], onlyTables: true }
           }
         });
       });

+ 19 - 6
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecCreate.js

@@ -735,7 +735,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ database: 'foo', table: 'bar' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'foo' }, { name: 'bar' }] }] }
           }
         });
       });
@@ -748,7 +748,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ database: 'foo', table: 'bar' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'foo' }, { name: 'bar' }] }] }
           }
         });
       });
@@ -1155,7 +1155,7 @@ define([
             dialect: 'impala',
             expectedResult: {
               lowerCase: false,
-              suggestTables: { database: 'dbOne' }
+              suggestTables: { identifierChain: [{ name: 'dbOne' }] }
             }
           });
         });
@@ -1460,6 +1460,7 @@ define([
             beforeCursor: 'CREATE EXTERNAL TABLE IF NOT EXISTS dbOne.tableName LIKE boo.baa COMMENT \'Table comment...\' STORED ',
             afterCursor: '',
             dialect: 'impala',
+            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['AS']
@@ -1554,7 +1555,7 @@ define([
             dialect: 'hive',
             expectedResult: {
               lowerCase: false,
-              suggestTables: { database: 'dbOne' }
+              suggestTables: { identifierChain: [{ name: 'dbOne' }] }
             }
           });
         });
@@ -2103,6 +2104,18 @@ define([
           });
         });
 
+        it('should suggest keywords for "CREATE TABLE foo (bla BIGINT, blabla INT |"', function () {
+          assertAutoComplete({
+            beforeCursor: 'CREATE TABLE foo (bla BIGINT, blabla INT ',
+            afterCursor: '',
+            dialect: 'hive',
+            expectedResult: {
+              lowerCase: false,
+              suggestKeywords: ['COMMENT']
+            }
+          });
+        });
+
         it('should suggest keywords for "CREATE TABLE foo (bla MAP<|, STRUCT<boo: INT, foo:STRUCT<blo:DOUBLE, doo:VARCHAR, bla:DOUBLE>"', function () {
           assertAutoComplete({
             beforeCursor: 'CREATE TABLE foo (bla MAP<',
@@ -2268,7 +2281,7 @@ define([
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
             suggestFunctions: {},
-            suggestColumns: { tables: [{ table: 'tableOne' }] },
+            suggestColumns:  { tables: [{ identifierChain: [{ name: 'tableOne' }] }] },
             suggestKeywords: ['*']
           }
         });
@@ -2354,7 +2367,7 @@ define([
               suggestAggregateFunctions: true,
               suggestAnalyticFunctions: true,
               suggestFunctions: {},
-              suggestColumns: { tables: [{ table: 'tableOne' }] },
+              suggestColumns: { tables: [{ identifierChain: [{ name: 'tableOne' }] }] },
               suggestKeywords: ['*']
             }
           });

+ 16 - 22
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe.js

@@ -41,7 +41,7 @@ define([
           expectedResult: {
             lowerCase: false,
             locations: [
-              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13 }, table:'tbl' }
+              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13 }, identifierChain: [{ name: 'tbl' }] }
             ]
           }
         });
@@ -56,8 +56,8 @@ define([
           expectedResult: {
             lowerCase: false,
             locations: [
-              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13 }, table:'tbl' },
-              {type: 'column', location: { first_line: 1, last_line: 1, first_column: 14, last_column: 23 }, identifierChain: [{ name: 'col' }, { name: 'field'}], table:'tbl' }
+              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13 }, identifierChain: [{ name: 'tbl' }] },
+              {type: 'column', location: { first_line: 1, last_line: 1, first_column: 14, last_column: 23 }, identifierChain: [{ name: 'tbl' }, { name: 'col' }, { name: 'field'}] }
             ]
           }
         });
@@ -72,7 +72,7 @@ define([
           expectedResult: {
             lowerCase: false,
             locations: [
-              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 19, last_column: 22 }, table:'tbl' }
+              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 19, last_column: 22 }, identifierChain: [{ name: 'tbl' }] }
             ]
           }
         });
@@ -228,7 +228,7 @@ define([
           dialect: 'hive',
           expectedResult: {
             lowerCase: false,
-            suggestTables: { database: 'db' }
+            suggestTables: { identifierChain: [{ name: 'db' }] }
           }
         });
       });
@@ -241,7 +241,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ table: 'tbl', database: 'db' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
           }
         });
       });
@@ -366,7 +366,7 @@ define([
           dialect: 'hive',
           expectedResult: {
             lowerCase: true,
-            suggestTables: { database: 'db' }
+            suggestTables: { identifierChain: [{ name: 'db' }] }
           }
         });
       });
@@ -379,7 +379,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ database: 'db', table: 'tbl' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
           }
         });
       });
@@ -405,7 +405,7 @@ define([
           expectedResult: {
             lowerCase: false,
             suggestTables: {
-              database: 'db'
+              identifierChain: [{ name: 'db' }]
             }
           }
         });
@@ -419,7 +419,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ database: 'db', table: 'tbl' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
           }
         });
       });
@@ -432,7 +432,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ identifierChain: [{ name: 'col' }], database: 'db', table: 'tbl' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }, { name: 'col' }] }] }
           }
         });
       });
@@ -448,7 +448,7 @@ define([
           expectedResult: {
             lowerCase: false,
             locations: [
-              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13}, table:'tbl' }
+              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13}, identifierChain: [{ name: 'tbl' }] }
             ]
           }
         });
@@ -463,7 +463,7 @@ define([
           expectedResult: {
             lowerCase: false,
             locations: [
-              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 13, last_column: 16}, database:'db', table:'tbl' }
+              {type: 'table', location: { first_line: 1, last_line: 1, first_column: 13, last_column: 16}, identifierChain: [{ name: 'db' }, { name: 'tbl' }] }
             ]
           }
         });
@@ -491,9 +491,7 @@ define([
             lowerCase: false,
             suggestKeywords: ['FORMATTED'],
             suggestTables: {},
-            suggestDatabases: {
-              appendDot: true
-            }
+            suggestDatabases: { appendDot: true }
           }
         });
       });
@@ -507,9 +505,7 @@ define([
             lowerCase: false,
             suggestKeywords: ['FORMATTED'],
             suggestTables: {},
-            suggestDatabases: {
-              appendDot: true
-            }
+            suggestDatabases: { appendDot: true }
           }
         });
       });
@@ -521,9 +517,7 @@ define([
           dialect: 'impala',
           expectedResult: {
             lowerCase: false,
-            suggestTables: {
-              database: 'db'
-            }
+            suggestTables: { identifierChain: [{ name: 'db' }] }
           }
         });
       });

+ 3 - 3
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDrop.js

@@ -428,7 +428,7 @@ define([
           afterCursor: '',
           expectedResult: {
             lowerCase: false,
-            suggestTables: { onlyTables: true, database: 'db' }
+            suggestTables: { identifierChain: [{ name: 'db' }], onlyTables: true }
           }
         });
       });
@@ -468,7 +468,7 @@ define([
               lowerCase: false,
               suggestKeywords: ['PURGE'],
               locations: [
-                {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15}, table: 'foo'}
+                {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15}, identifierChain: [{ name: 'foo' }]}
               ]
             }
           });
@@ -600,7 +600,7 @@ define([
           noErrors: true,
           expectedResult: {
             lowerCase: false,
-            suggestTables: { database: 'boo', onlyViews: true }
+            suggestTables: { identifierChain: [{ name: 'boo' }], onlyViews: true }
           }
         });
       });

+ 3 - 3
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecError.js

@@ -38,7 +38,7 @@ define([
         expectedResult: {
           lowerCase: false,
           suggestFunctions: {},
-          suggestColumns: { tables: [{ table: 'testTable' }] }
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'testTable' }] }] }
         }
       });
     });
@@ -51,7 +51,7 @@ define([
         expectedResult: {
           lowerCase: false,
           suggestFunctions: {},
-          suggestColumns: { tables: [{ table: 'testTable' }] }
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'testTable' }] }] }
         }
       });
     });
@@ -64,7 +64,7 @@ define([
         expectedResult: {
           lowerCase: false,
           suggestFunctions: {},
-          suggestColumns: { tables: [{ table: 'testTable' }] }
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'testTable' }] }] }
         }
       });
     });

+ 22 - 22
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecInsert.js

@@ -88,7 +88,7 @@ define([
         noErrors: true,
         expectedResult: {
           lowerCase: false,
-          suggestTables: { database: 'baa' }
+          suggestTables: { identifierChain: [{ name: 'baa' }] }
         }
       });
     });
@@ -100,7 +100,7 @@ define([
         noErrors: true,
         expectedResult: {
           lowerCase: false,
-          suggestTables: { database: 'baa' }
+          suggestTables: { identifierChain: [{ name: 'baa' }] }
         }
       });
     });
@@ -297,7 +297,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestTables: { database: 'baa' }
+            suggestTables: { identifierChain: [{ name: 'baa' }] }
           }
         });
       });
@@ -324,7 +324,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ table: 'baa' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }] }] }
           }
         });
       });
@@ -337,7 +337,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ table: 'baa' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }] }] }
           }
         });
       });
@@ -369,7 +369,7 @@ define([
             suggestFunctions: {},
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
-            suggestColumns: { tables: [{ table: 'boo', database: 'baa' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }, { name: 'boo' }] }] }
           }
         });
       });
@@ -386,7 +386,7 @@ define([
             suggestFunctions: {},
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
-            suggestColumns: { tables: [{ table: 'boo', database: 'baa' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }, { name: 'boo' }] }] }
           }
         });
       });
@@ -403,7 +403,7 @@ define([
           doesNotContainKeywords: ['FROM'],
           expectedResult: {
             lowerCase: false,
-            colRef: { identifierChain: [{ name: 'd' }], table: 'boo', database: 'baa' }
+            colRef: { identifierChain: [{ name: 'baa' }, { name: 'boo' }, { name: 'd' }] }
           }
         });
       });
@@ -444,7 +444,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ table: 'ble', database: 'bla' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'bla' }, { name: 'ble' }] }] }
           }
         });
       });
@@ -518,7 +518,7 @@ define([
             suggestFunctions: {},
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
-            suggestColumns: { tables: [{ table: 'boo', database: 'baa' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }, { name: 'boo' }] }] }
           }
         });
       });
@@ -535,7 +535,7 @@ define([
           doesNotContainKeywords: ['FROM'],
           expectedResult: {
             lowerCase: false,
-            colRef: { identifierChain: [{ name: 'd' }], table: 'boo', database: 'baa' }
+            colRef: { identifierChain: [{ name: 'baa' }, { name: 'boo' }, { name: 'd' }] }
           }
         });
       });
@@ -552,7 +552,7 @@ define([
           doesNotContainKeywords: ['FROM'],
           expectedResult: {
             lowerCase: false,
-            colRef: { identifierChain: [{ name: 'a' }], table: 'boo', database: 'baa' }
+            colRef: { identifierChain: [{ name: 'baa' }, { name: 'boo' }, { name: 'a' }] }
           }
         });
       });
@@ -570,7 +570,7 @@ define([
             suggestFunctions: {},
             suggestAggregateFunctions: true,
             suggestAnalyticFunctions: true,
-            suggestColumns: { tables: [{ table: 'boo', database: 'baa' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }, { name: 'boo' }] }] }
           }
         });
       });
@@ -587,7 +587,7 @@ define([
           doesNotContainKeywords: ['FROM'],
           expectedResult: {
             lowerCase: false,
-            colRef: { identifierChain: [{ name: 'd' }], table: 'boo', database: 'baa' }
+            colRef: { identifierChain: [{ name: 'baa' }, { name: 'boo' }, { name: 'd' }] }
           }
         });
       });
@@ -628,7 +628,7 @@ define([
           noErrors: true,
           expectedResult: {
             lowerCase: false,
-            suggestTables: { database: 'baa' }
+            suggestTables: { identifierChain: [{ name: 'baa' }] }
           }
         });
       });
@@ -655,7 +655,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ table: 'baa' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }] }] }
           }
         });
       });
@@ -668,7 +668,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ table: 'baa' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }] }] }
           }
         });
       });
@@ -776,7 +776,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ table: 'ble', database: 'bla' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'bla' }, { name: 'ble' }] }] }
           }
         });
       });
@@ -981,7 +981,7 @@ define([
           noErrors: true,
           expectedResult: {
             lowerCase: false,
-            suggestTables: { database: 'boo' }
+            suggestTables: { identifierChain: [{ name: 'boo' }] }
           }
         });
       });
@@ -1037,7 +1037,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ database: 'boo', table: 'baa' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'boo' }, { name: 'baa' }] }] }
           }
         });
       });
@@ -1050,7 +1050,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ database: 'boo', table: 'baa' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'boo' }, { name: 'baa' }] }] }
           }
         });
       });
@@ -1077,7 +1077,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ database: 'boo', table: 'baa' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'boo' }, { name: 'baa' }] }] }
           }
         });
       });

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecLoad.js

@@ -148,7 +148,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ table: 'boo' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'boo' }] }] }
           }
         });
       });
@@ -313,7 +313,7 @@ define([
           hasLocations: true,
           expectedResult: {
             lowerCase: false,
-            suggestColumns: { tables: [{ table: 'baa', database: 'boo' }] }
+            suggestColumns: { tables: [{ identifierChain: [{ name: 'boo' }, { name: 'baa' }] }] }
           }
         });
       });

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 201 - 179
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSelect.js


+ 3 - 9
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecShow.js

@@ -335,9 +335,7 @@ define([
           dialect: 'hive',
           expectedResult: {
             lowerCase: false,
-            suggestTables: {
-              database: 'databaseOne'
-            }
+            suggestTables: { identifierChain: [{ name: 'databaseOne' }] }
           }
         });
       });
@@ -349,9 +347,7 @@ define([
           dialect: 'hive',
           expectedResult: {
             lowerCase: false,
-            suggestTables: {
-              database: 'databaseOne'
-            }
+            suggestTables: { identifierChain: [{ name: 'databaseOne' }] }
           }
         });
       });
@@ -459,9 +455,7 @@ define([
           dialect: 'hive',
           expectedResult: {
             lowerCase: false,
-            suggestTables: {
-              database: 'databaseOne'
-            }
+            suggestTables: { identifierChain: [{ name: 'databaseOne' }] }
           }
         });
       });

+ 29 - 37
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecUpdate.js

@@ -49,7 +49,7 @@ define([
           lowerCase: false,
           suggestKeywords: ['SET'],
           locations: [
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, table: 'bar'}
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar'}]}
           ]
         }
       });
@@ -63,9 +63,9 @@ define([
           lowerCase: false,
           suggestKeywords: ['WHERE'],
           locations: [
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, table: 'bar'},
-            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 16, last_column: 18}, table: 'bar', identifierChain: [{ name: 'id' }]},
-            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 22, last_column: 25}, table: 'bar', identifierChain: [{ name: 'foo' }]}
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar'}]},
+            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 16, last_column: 18}, identifierChain: [{ name: 'bar'}, { name: 'id' }]},
+            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 22, last_column: 25}, identifierChain: [{ name: 'bar'}, { name: 'foo' }]}
           ]
         }
       });
@@ -79,8 +79,8 @@ define([
           lowerCase: false,
           suggestKeywords: ['='],
           locations: [
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, table: 'bar'},
-            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 16, last_column: 18}, table: 'bar', identifierChain: [{ name: 'id' }]}
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar'}]},
+            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 16, last_column: 18}, identifierChain: [{ name: 'bar'}, { name: 'id' }]}
           ]
         }
       });
@@ -120,9 +120,7 @@ define([
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestTables: {
-            database: 'bar'
-          }
+          suggestTables: { identifierChain: [{ name: 'bar' }] }
         }
       });
     });
@@ -133,9 +131,7 @@ define([
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestTables: {
-            database: 'bar'
-          }
+          suggestTables: { identifierChain: [{ name: 'bar' }] }
         }
       });
     });
@@ -146,9 +142,9 @@ define([
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestColumns: { tables: [{ database: 'bar', table: 'foo' }] },
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'bar'}, { name: 'foo' }] }] },
           locations: [
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15}, database: 'bar', table: 'foo'}
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15}, identifierChain: [{ name: 'bar'}, { name: 'foo' }]}
           ]
         }
       });
@@ -160,11 +156,11 @@ define([
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestColumns: { tables: [{ database: 'bar', table: 'foo' }] },
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'bar'}, { name: 'foo' }] }] },
           locations: [
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15}, database: 'bar', table: 'foo'},
-            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 20, last_column: 22}, database: 'bar', table: 'foo', identifierChain: [{ name: 'id' }]},
-            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 28, last_column: 31}, database: 'bar', table: 'foo', identifierChain: [{ name: 'bla' }]}
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15}, identifierChain: [{ name: 'bar'}, { name: 'foo' }]},
+            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 20, last_column: 22}, identifierChain: [{ name: 'bar'}, { name: 'foo' }, { name: 'id' }]},
+            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 28, last_column: 31}, identifierChain: [{ name: 'bar'}, { name: 'foo' }, { name: 'bla' }]}
           ]
         }
       });
@@ -177,11 +173,11 @@ define([
         expectedResult: {
           lowerCase: false,
           suggestFunctions: {},
-          suggestColumns: { tables: [{ database: 'bar', table: 'foo' }] },
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'bar'}, { name: 'foo' }] }] },
           suggestKeywords: ['EXISTS', 'NOT EXISTS'],
           locations: [
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15}, database: 'bar', table: 'foo'},
-            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 20, last_column: 23}, database: 'bar', table: 'foo', identifierChain: [{ name: 'bla' }]}
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15}, identifierChain: [{ name: 'bar'}, { name: 'foo' }]},
+            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 20, last_column: 23}, identifierChain: [{ name: 'bar'}, { name: 'foo' }, { name: 'bla' }]}
           ]
         }
       });
@@ -193,20 +189,16 @@ define([
         afterCursor: '',
         containsKeywords: ['CASE'],
         expectedResult: {
-          lowerCase: false,
+          locations: [
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 }, identifierChain: [{ name: 'bar'}, { name: 'foo' }]},
+            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 20, last_column: 23 }, identifierChain: [{ name: 'bar'}, { name: 'foo' }, { name: 'bla'}]},
+            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 38, last_column: 40 }, identifierChain: [{ name: 'bar'}, { name: 'foo' }, { name: 'id'}]}
+          ],
           suggestFunctions: { types: ['COLREF'] },
           suggestValues: true,
-          colRef: {
-            database: 'bar',
-            table: 'foo',
-            identifierChain: [{ name: 'id' }]
-          },
-          suggestColumns: { types: ['COLREF'], tables: [{ database: 'bar', table: 'foo' }] },
-          locations: [
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 }, database:'bar', table: 'foo'},
-            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 20, last_column: 23 }, identifierChain: [{ name: 'bla'}], database: 'bar', table: 'foo'},
-            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 38, last_column: 40 }, identifierChain: [{ name: 'id'}], database: 'bar', table: 'foo'}
-          ]
+          colRef: { identifierChain: [{ name: 'bar' }, { name: 'foo' }, { name: 'id' }] },
+          suggestColumns: { types: ['COLREF'], tables: [{ identifierChain: [{ name: 'bar'}, { name: 'foo' }] }] },
+          lowerCase: false
         }
       });
     });
@@ -221,11 +213,11 @@ define([
         expectedResult: {
           lowerCase: false,
           suggestFunctions: {},
-          suggestColumns: { tables: [{ database: 'bar', table: 'foo' }] },
+          suggestColumns: { tables: [{ identifierChain: [{ name: 'bar'}, { name: 'foo' }] }] },
           locations: [
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 }, database:'bar', table: 'foo'},
-            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 20, last_column: 23 }, identifierChain: [{ name: 'bla'}], database: 'bar', table: 'foo'},
-            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 38, last_column: 40 }, identifierChain: [{ name: 'id'}], database: 'bar', table: 'foo'}
+            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15 }, identifierChain: [{ name: 'bar'}, { name: 'foo' }]},
+            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 20, last_column: 23 }, identifierChain: [{ name: 'bar'}, { name: 'foo' }, { name: 'bla'}]},
+            {type: 'column', location: { first_line: 1, last_line: 1, first_column: 38, last_column: 40 }, identifierChain: [{ name: 'bar'}, { name: 'foo' }, { name: 'id'}]}
           ]
         }
       });

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно