Browse Source

HUE-5826 [editor] Adjust parser to also report statement locations

Johan Ahlen 8 năm trước cách đây
mục cha
commit
19e696c
20 tập tin đã thay đổi với 163 bổ sung540 xóa
  1. 1 1
      desktop/core/src/desktop/static/desktop/js/aceSqlWorker.js
  2. 26 7
      desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison
  3. 30 0
      desktop/core/src/desktop/static/desktop/js/autocomplete/sql_support.js
  4. 1 1
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js
  5. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpec.js
  6. 0 126
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAlter.js
  7. 0 27
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAnalyze.js
  8. 0 50
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecCreate.js
  9. 6 16
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe_hive.js
  10. 5 6
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe_impala.js
  11. 1 16
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDrop.js
  12. 0 8
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecError.js
  13. 0 20
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecGrant.js
  14. 0 62
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecInsert.js
  15. 0 33
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecLoad.js
  16. 30 3
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecLocations.js
  17. 20 127
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSelect.js
  18. 0 3
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecShow.js
  19. 31 23
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecUpdate.js
  20. 10 9
      desktop/core/src/desktop/static/desktop/spec/autocompleterTestUtils.js

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/aceSqlWorker.js

@@ -14,7 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-var version = 11;
+var version = 12;
 importScripts('/static/desktop/js/autocomplete/sql.js?version=' + version);
 importScripts('/static/desktop/js/sqlFunctions.js?version=' + version);
 

+ 26 - 7
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison

@@ -190,21 +190,40 @@ Sql
 
 SqlStatements
  :
- | DataDefinition
- | DataManipulation
- | QuerySpecification
- | SetSpecification
- | ExplainClause DataDefinition
- | ExplainClause DataManipulation
- | ExplainClause QuerySpecification
+ | SqlStatement
+   {
+     addStatementLocation(@1);
+   }
  | SqlStatements ';' NewStatement SqlStatements
  ;
 
 SqlStatements_EDIT
  : SqlStatement_EDIT
+   {
+     addStatementLocation(@1);
+   }
  | SqlStatement_EDIT ';' NewStatement SqlStatements
+   {
+     addStatementLocation(@1);
+   }
  | SqlStatements ';' NewStatement SqlStatement_EDIT
+   {
+     addStatementLocation(@4);
+   }
  | SqlStatements ';' NewStatement SqlStatement_EDIT ';' NewStatement SqlStatements
+   {
+     addStatementLocation(@4);
+   }
+ ;
+
+SqlStatement
+ : DataDefinition
+ | DataManipulation
+ | QuerySpecification
+ | SetSpecification
+ | ExplainClause DataDefinition
+ | ExplainClause DataManipulation
+ | ExplainClause QuerySpecification
  ;
 
 SqlStatement_EDIT

+ 30 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sql_support.js

@@ -1118,6 +1118,36 @@ var addFunctionLocation = function (location, functionName) {
   });
 };
 
+var addStatementLocation = function (location) {
+  // Don't report lonely cursor as a statement
+  if (location.first_line === location.last_line && Math.abs(location.last_column - location.first_column) === 1) {
+    return;
+  }
+  var adjustedLocation;
+  if (parser.yy.cursorFound && parser.yy.cursorFound.last_line === location.last_line &&
+      parser.yy.cursorFound.first_column >= location.first_column && parser.yy.cursorFound.last_column <= location.last_column) {
+    var additionalSpace = parser.yy.partialLengths.left + parser.yy.partialLengths.right;
+    adjustedLocation = {
+      first_line: location.first_line,
+      last_line: location.last_line,
+      first_column: location.first_column + 1,
+      last_column: location.last_column + additionalSpace - (parser.yy.partialCursor ? 0 : 2)
+    }
+  } else {
+    adjustedLocation = {
+      first_line: location.first_line,
+      last_line: location.last_line,
+      first_column: location.first_column + 1,
+      last_column: location.last_column + 1
+    }
+  }
+
+  parser.yy.locations.push({
+    type: 'statement',
+    location: adjustedLocation
+  });
+};
+
 var addHdfsLocation = function (location, path) {
   parser.yy.locations.push({
     type: 'hdfs',

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -3299,7 +3299,7 @@
           }
 
           e.data.locations.forEach(function (location) {
-            if ((location.type === 'table' || location.type === 'column') && typeof location.identifierChain === 'undefined') {
+            if (location.type === 'statement' || ((location.type === 'table' || location.type === 'column') && typeof location.identifierChain === 'undefined')) {
               return;
             }
             if ((location.type === 'table' && location.identifierChain.length > 1) || (location.type === 'column' && location.identifierChain.length > 2)) {

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

@@ -211,7 +211,6 @@
             beforeCursor: 'EXPLAIN DEPENDENCY SELECT key, count(1) FROM srcpart WHERE ds IS NOT NULL GROUP BY key;',
             afterCursor: '',
             dialect: 'hive',
-            hasLocations: true,
             noErrors: true,
             containsKeywords: ['SELECT'],
             expectedResult: {
@@ -278,7 +277,6 @@
             beforeCursor: 'EXPLAIN SELECT key, count(1) FROM srcpart WHERE ds IS NOT NULL GROUP BY key;',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             noErrors: true,
             containsKeywords: ['SELECT'],
             expectedResult: {
@@ -440,6 +438,7 @@
         containsKeywords: ['SELECT'],
         expectedResult: {
           locations: [
+            { type: 'statement', location: { first_line: 2, last_line: 2, first_column: 1, last_column: 25 } },
             { type: 'asterisk', location: { first_line: 2, last_line: 2, first_column: 8, last_column: 9 }, tables: [{ identifierChain: [{ name: 'testTable1' }] }] },
             { type: 'table', location: { first_line:2, last_line:2, first_column:15, last_column:25 }, identifierChain: [{ name: 'testTable1' }] }
           ],
@@ -455,6 +454,7 @@
         containsKeywords: ['SELECT'],
         expectedResult: {
           locations: [
+            { type: 'statement', location: { first_line: 4, last_line: 4, first_column: 1, last_column: 25 } },
             { type: 'asterisk', location: { first_line: 4, last_line: 4, first_column: 8, last_column: 9 }, tables: [{ identifierChain: [{ name: 'testTable1' }] }] },
             { type: 'table', location: { first_line:4, last_line:4, first_column:15, last_column:25 }, identifierChain: [{ name: 'testTable1' }] }
           ],

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 126
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAlter.js


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

@@ -34,7 +34,6 @@
           dialect: 'hive',
           noErrors:true,
           containsKeywords: ['SELECT'],
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }
@@ -73,7 +72,6 @@
           afterCursor: ' tbl',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: true,
             suggestKeywords: ['TABLE']
@@ -87,7 +85,6 @@
           afterCursor: ' tbl',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: true,
             suggestKeywords: ['TABLE']
@@ -128,7 +125,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION', 'COMPUTE STATISTICS']
@@ -142,7 +138,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['COMPUTE STATISTICS']
@@ -156,7 +151,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['STATISTICS']
@@ -170,7 +164,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['FOR COLUMNS', 'CACHE METADATA', 'NOSCAN']
@@ -184,7 +177,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['COLUMNS']
@@ -198,7 +190,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['CACHE METADATA', 'NOSCAN']
@@ -212,7 +203,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['METADATA']
@@ -226,7 +216,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['NOSCAN']
@@ -240,7 +229,6 @@
           afterCursor: ' NOSCAN',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['FOR COLUMNS', 'CACHE METADATA']
@@ -254,7 +242,6 @@
           afterCursor: ' NOSCAN',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['METADATA']
@@ -268,7 +255,6 @@
           afterCursor: ' NOSCAN',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['CACHE METADATA']
@@ -284,7 +270,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -298,7 +283,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -312,7 +296,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -352,7 +335,6 @@
           afterCursor: ' tbl',
           dialect: 'impala',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['INCREMENTAL STATS', 'STATS']
@@ -366,7 +348,6 @@
           afterCursor: ' tbl',
           dialect: 'impala',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['INCREMENTAL STATS', 'STATS']
@@ -380,7 +361,6 @@
           afterCursor: ' tbl',
           dialect: 'impala',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['STATS']
@@ -461,7 +441,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION']
@@ -474,7 +453,6 @@
           beforeCursor: 'COMPUTE INCREMENTAL STATS db.tbl PARTITION (',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }]} ]}
@@ -487,7 +465,6 @@
           beforeCursor: 'COMPUTE INCREMENTAL STATS db.tbl PARTITION (bla = 1, ',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }]} ]}
@@ -517,7 +494,6 @@
           dialect: 'impala',
           noErrors:true,
           containsKeywords: ['SELECT'],
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }
@@ -556,7 +532,6 @@
           afterCursor: ' tbl',
           dialect: 'impala',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['METADATA']
@@ -570,7 +545,6 @@
           afterCursor: ' tbl',
           dialect: 'impala',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['METADATA']
@@ -614,7 +588,6 @@
           dialect: 'impala',
           noErrors:true,
           containsKeywords: ['SELECT'],
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }

+ 0 - 50
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecCreate.js

@@ -178,7 +178,6 @@
             beforeCursor: 'CREATE DATABASE foo COMMENT \'bla\' LOCATION \'/bla\' ',
             afterCursor: '',
             dialect: 'hive',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['WITH DBPROPERTIES']
@@ -304,7 +303,6 @@
             beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'/boo\' SYMBOL=\'baaa\'; ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             containsKeywords: ['SELECT'],
             expectedResult: {
               lowerCase: false
@@ -318,7 +316,6 @@
             beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' MERGE_FN=\'cos\' PREPARE_FN=\'cos\' CLOSE_FN=\'cos\' SERIALIZE_FN=\'cos\' FINALIZE_FN=\'cos\'; ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             containsKeywords: ['SELECT'],
             expectedResult: {
               lowerCase: false
@@ -428,7 +425,6 @@
             beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['INIT_FN', 'UPDATE_FN']
@@ -441,7 +437,6 @@
             beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestAnalyticFunctions: true,
@@ -456,7 +451,6 @@
             beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['UPDATE_FN']
@@ -469,7 +463,6 @@
             beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestAnalyticFunctions: true,
@@ -484,7 +477,6 @@
             beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['MERGE_FN']
@@ -498,7 +490,6 @@
             beforeCursor: 'CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION \'/boo\' INIT_FN=\'cos\' UPDATE_FN=\'sin\' MERGE_FN=\'tan\' PREPARE_FN=\'boo\' SERIALIZE_FN=\'baa\' ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['FINALIZE_FN']
@@ -657,7 +648,6 @@
             beforeCursor: 'CREATE FUNCTION boo(INT, BOOLEAN) RETURNS INT LOCATION \'/boo\' ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['SYMBOL']
@@ -675,7 +665,6 @@
           'TBLPROPERTIES ("bla"=1) COMMENT \"booo\"; ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -688,7 +677,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE db.tbl (a, b, c) AS \'boo.baa.bitmap\'; ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -738,7 +726,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE foo.bar (',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'foo' }, { name: 'bar' }] }] }
@@ -751,7 +738,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE foo.bar (a, b, c, ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'foo' }, { name: 'bar' }] }] }
@@ -764,7 +750,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['AS']
@@ -777,7 +762,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['\'BITMAP\'', '\'COMPACT\'']
@@ -790,7 +774,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BIT',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['\'BITMAP\'', '\'COMPACT\'']
@@ -803,7 +786,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['WITH DEFERRED REBUILD', 'IDXPROPERTIES', 'IN TABLE', 'ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
@@ -816,7 +798,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['DEFERRED REBUILD']
@@ -829,7 +810,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH DEFERRED ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['REBUILD']
@@ -842,7 +822,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' WITH DEFERRED REBUILD ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['IDXPROPERTIES', 'IN TABLE', 'ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
@@ -855,7 +834,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IDXPROPERTIES ("baa"="boo") ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['IN TABLE', 'ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
@@ -868,7 +846,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['TABLE']
@@ -881,7 +858,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN TABLE ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestTables: {},
@@ -895,7 +871,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' IN TABLE boo ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['ROW FORMAT', 'STORED AS', 'STORED BY', 'LOCATION', 'TBLPROPERTIES', 'COMMENT']
@@ -908,7 +883,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['FORMAT']
@@ -921,7 +895,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['DELIMITED', 'SERDE']
@@ -936,7 +909,6 @@
           dialect: 'hive',
           containsKeywords: ['MAP KEYS TERMINATED BY', 'NULL DEFINED AS', 'LOCATION', 'TBLPROPERTIES', 'COMMENT'],
           doesNotContainKeywords: ['AS'],
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }
@@ -948,7 +920,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'BITMAP\' ROW FORMAT DELIMITED NULL ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['DEFINED AS']
@@ -961,7 +932,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' ROW FORMAT DELIMITED STORED ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['AS']
@@ -974,7 +944,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' STORED ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['AS', 'BY']
@@ -988,7 +957,6 @@
           afterCursor: '',
           dialect: 'hive',
           containsKeywords: ['ORC', 'PARQUET'],
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }
@@ -1000,7 +968,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' LOCATION \'',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestHdfs: { path: '' }
@@ -1013,7 +980,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' LOCATION \'/baa\' ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['TBLPROPERTIES', 'COMMENT']
@@ -1026,7 +992,6 @@
           beforeCursor: 'CREATE INDEX bla ON TABLE boo (a, b, c) AS \'COMPACT\' TBLPROPERTIES ("baa"="boo") ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['COMMENT']
@@ -1195,7 +1160,6 @@
             beforeCursor: 'CREATE TABLE foo LIKE PARQUET \'/blabla/\' ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             containsKeywords: ['COMMENT', 'CACHED IN'],
             expectedResult: {
               lowerCase: false
@@ -1208,7 +1172,6 @@
             beforeCursor: 'CREATE TABLE foo (id int) LOCATION \'/baa\' ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['TBLPROPERTIES', 'CACHED IN', 'AS']
@@ -1257,7 +1220,6 @@
             beforeCursor: 'CREATE TABLE foo (id int) PARTITIONED BY (boo INT, baa BIGINT ',
             afterCursor: ', boo INT) AS SELECT * FROM baa;',
             dialect: 'impala',
-            hasLocations: true,
             containsKeywords: ['COMMENT'],
             expectedResult: {
               lowerCase: false
@@ -1423,7 +1385,6 @@
             'CACHED ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['IN']
@@ -1441,7 +1402,6 @@
             'CACHED ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['IN']
@@ -1470,7 +1430,6 @@
             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']
@@ -1488,7 +1447,6 @@
             'CACHED IN \'boo\' AS ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['SELECT']
@@ -1836,7 +1794,6 @@
             beforeCursor: 'CREATE TABLE foo (i INT PRIMARY KEY, j INT PRIMARY KEY) PARTITION BY RANGE (i) (PARTITION cos(10) < VALUES, PARTITION VALUES ',
             afterCursor: '',
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['<', '<=']
@@ -1986,7 +1943,6 @@
             beforeCursor: 'CREATE TABLE foo (id int) LOCATION \'/baa\' ',
             afterCursor: '',
             dialect: 'hive',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['TBLPROPERTIES', 'AS']
@@ -2283,7 +2239,6 @@
               'STORED AS ORC LOCATION \'/asdf/boo/\' TBLPROPERTIES ("comment"="boo") AS ',
             afterCursor: '',
             dialect: 'hive',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['SELECT']
@@ -2298,7 +2253,6 @@
               'LOCATION \'/asdf/boo/\' TBLPROPERTIES ("comment"="boo") AS ',
             afterCursor: '',
             dialect: 'hive',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['SELECT']
@@ -2311,7 +2265,6 @@
             beforeCursor: 'CREATE TEMPORARY EXTERNAL TABLE IF NOT EXISTS db.boo LIKE ',
             afterCursor: ' LOCATION \'/some/loc\';',
             dialect: 'hive',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestTables: {},
@@ -2549,7 +2502,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -2622,7 +2574,6 @@
           beforeCursor: 'CREATE TEMPORARY MACRO boo(x INT, y STRING) cos(x) + y - ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           containsKeywords: ['CASE'],
           expectedResult: {
             lowerCase: false,
@@ -2665,7 +2616,6 @@
         assertAutoComplete({
           beforeCursor: 'CREATE VIEW ',
           afterCursor: ' boo AS SELECT * FROM baa;',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['IF NOT EXISTS']

+ 6 - 16
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe_hive.js

@@ -37,7 +37,8 @@
         expectedResult: {
           lowerCase: false,
           locations: [
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13 }, identifierChain: [{ name: 'tbl' }] }
+            { type: 'statement', location: { 'first_line': 1, 'last_line': 1, 'first_column': 1, 'last_column': 13 } },
+            { type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13 }, identifierChain: [{ name: 'tbl' }] }
           ]
         }
       });
@@ -51,8 +52,9 @@
         expectedResult: {
           lowerCase: false,
           locations: [
-            {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'}] }
+            { type: 'statement', location: { 'first_line': 1, 'last_line': 1, 'first_column': 1, 'last_column': 23 } },
+            { 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'}] }
           ]
         }
       });
@@ -66,6 +68,7 @@
         expectedResult: {
           lowerCase: false,
           locations: [
+            { type: 'statement', location: { 'first_line': 1, 'last_line': 1, 'first_column': 1, 'last_column': 22 } },
             {type: 'table', location: { first_line: 1, last_line: 1, first_column: 19, last_column: 22 }, identifierChain: [{ name: 'tbl' }] }
           ]
         }
@@ -76,7 +79,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE EXTENDED tbl col.field;',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -88,7 +90,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE ',
         afterCursor: ' tbl;',
-        hasLocations: true,
         containsKeywords: ['EXTENDED', 'FORMATTED'],
         expectedResult: {
           lowerCase: false
@@ -100,7 +101,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE ext',
         afterCursor: ' db.tbl;',
-        hasLocations: true,
         containsKeywords: ['EXTENDED', 'FORMATTED'],
         expectedResult: {
           lowerCase: false
@@ -112,7 +112,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE FORMATTED tbl;',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -124,7 +123,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE FORMATTED tbl col.field;',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -158,7 +156,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE DATABASE db;',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -170,7 +167,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE DATABASE EXTENDED db;',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -182,7 +178,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE SCHEMA db;',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -194,7 +189,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE SCHEMA EXTENDED db;',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -243,7 +237,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE db.tbl ',
         afterCursor: '',
-        hasLocations: true,
         expectedResult: {
           lowerCase: false,
           suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
@@ -370,7 +363,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE EXTENDED db.tbl ',
         afterCursor: '',
-        hasLocations: true,
         expectedResult: {
           lowerCase: false,
           suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
@@ -407,7 +399,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE FORMATTED db.tbl ',
         afterCursor: '',
-        hasLocations: true,
         expectedResult: {
           lowerCase: false,
           suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }] }] }
@@ -419,7 +410,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE FORMATTED db.tbl col.',
         afterCursor: '',
-        hasLocations: true,
         expectedResult: {
           lowerCase: false,
           suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }, { name: 'col' }] }] }

+ 5 - 6
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe_impala.js

@@ -37,7 +37,8 @@
         expectedResult: {
           lowerCase: false,
           locations: [
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13}, identifierChain: [{ name: 'tbl' }] }
+            { type: 'statement', location: { 'first_line': 1, 'last_line': 1, 'first_column': 1, 'last_column': 13 } },
+            { type: 'table', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 13}, identifierChain: [{ name: 'tbl' }] }
           ]
         }
       });
@@ -51,8 +52,9 @@
         expectedResult: {
           lowerCase: false,
           locations: [
-            {type: 'database', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 12 }, identifierChain: [{ name: 'db' }]},
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 13, last_column: 16}, identifierChain: [{ name: 'db' }, { name: 'tbl' }] }
+            { type: 'statement', location: { 'first_line': 1, 'last_line': 1, 'first_column': 1, 'last_column': 16 } },
+            { type: 'database', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 12 }, identifierChain: [{ name: 'db' }]},
+            { type: 'table', location: { first_line: 1, last_line: 1, first_column: 13, last_column: 16}, identifierChain: [{ name: 'db' }, { name: 'tbl' }] }
           ]
         }
       });
@@ -62,7 +64,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE DATABASE db;',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -74,7 +75,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE EXTENDED db.tbl;',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -86,7 +86,6 @@
       assertAutoComplete({
         beforeCursor: 'DESCRIBE FORMATTED db.tbl;',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false

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

@@ -97,7 +97,6 @@
           dialect: 'hive',
           noErrors:true,
           containsKeywords: ['SELECT'],
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }
@@ -111,7 +110,6 @@
           dialect: 'hive',
           noErrors:true,
           containsKeywords: ['SELECT'],
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }
@@ -177,7 +175,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['WHERE']
@@ -191,7 +188,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           containsKeywords: ['EXISTS'],
           expectedResult: {
             lowerCase: false,
@@ -207,7 +203,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors:true,
-          hasLocations: true,
           containsKeywords: ['EXISTS'],
           expectedResult: {
             lowerCase: false,
@@ -462,7 +457,6 @@
           dialect: 'hive',
           noErrors: true,
           containsKeywords: ['SELECT'],
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }
@@ -540,7 +534,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -554,7 +547,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -648,7 +640,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors:true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION']
@@ -661,7 +652,6 @@
           beforeCursor: 'DROP INCREMENTAL STATS db.tbl PARTITION (',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }]} ]}
@@ -674,7 +664,6 @@
           beforeCursor: 'DROP INCREMENTAL STATS db.tbl PARTITION (bla = 1, ',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'db' }, { name: 'tbl' }]} ]}
@@ -745,6 +734,7 @@
               lowerCase: false,
               suggestKeywords: ['PURGE'],
               locations: [
+                { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 15 } },
                 {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15}, identifierChain: [{ name: 'foo' }]}
               ]
             }
@@ -824,7 +814,6 @@
           afterCursor: '',
           containsKeywords: ['SELECT'],
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }
@@ -837,7 +826,6 @@
           afterCursor: '',
           containsKeywords: ['SELECT'],
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }
@@ -891,7 +879,6 @@
           dialect: 'generic',
           containsKeywords: ['SELECT'],
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }
@@ -931,7 +918,6 @@
             dialect: 'hive',
             containsKeywords: ['SELECT'],
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false
             }
@@ -968,7 +954,6 @@
             beforeCursor: 'TRUNCATE TABLE boo ',
             afterCursor: '',
             dialect: 'hive',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['PARTITION']

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

@@ -30,7 +30,6 @@
       assertAutoComplete({
         beforeCursor: 'SELECT BAABO BOOAA BLARGH, ',
         afterCursor: ' FROM testTable',
-        hasLocations: true,
         expectedResult: {
           lowerCase: false,
           suggestFunctions: {},
@@ -45,7 +44,6 @@
       assertAutoComplete({
         beforeCursor: 'SELECT foo, bar, SELECT, ',
         afterCursor: ' FROM testTable',
-        hasLocations: true,
         expectedResult: {
           lowerCase: false,
           suggestFunctions: {},
@@ -60,7 +58,6 @@
       assertAutoComplete({
         beforeCursor: 'SELECT foo, baa baa baa baa, SELECT, ',
         afterCursor: ' FROM testTable',
-        hasLocations: true,
         expectedResult: {
           lowerCase: false,
           suggestFunctions: {},
@@ -75,7 +72,6 @@
       assertAutoComplete({
         beforeCursor: 'SELECT * FROM testTable WHERE baa baaa boo',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['GROUP BY', 'ORDER BY'],
         expectedResult: {
           lowerCase: false
@@ -87,7 +83,6 @@
       assertAutoComplete({
         beforeCursor: 'SELECT * FROM testTable WHERE baa baaa boo GROUP ',
         afterCursor: '',
-        hasLocations: true,
         expectedResult: {
           lowerCase: false,
           suggestKeywords: ['BY'],
@@ -100,7 +95,6 @@
       assertAutoComplete({
         beforeCursor: 'SELECT * FROM testTable WHERE baa baaa boo ORDER ',
         afterCursor: '',
-        hasLocations: true,
         expectedResult: {
           lowerCase: false,
           suggestKeywords: ['BY'],
@@ -113,7 +107,6 @@
       assertAutoComplete({
         beforeCursor: 'SELECT * FROM testTable ORDER BY bla bla bla boo ',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['LIMIT', 'UNION'],
         expectedResult: {
           lowerCase: false
@@ -125,7 +118,6 @@
       assertAutoComplete({
         beforeCursor: 'SELECT * FROM testTable ORDER BY bla bla bla boo ',
         afterCursor: '',
-        hasLocations: true,
         containsKeywords: ['LIMIT', 'UNION'],
         expectedResult: {
           lowerCase: false

+ 0 - 20
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecGrant.js

@@ -142,7 +142,6 @@
             afterCursor: '',
             dialect: 'hive',
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['TO']
@@ -156,7 +155,6 @@
             afterCursor: '',
             dialect: 'hive',
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['GROUP', 'ROLE', 'USER']
@@ -170,7 +168,6 @@
             afterCursor: '',
             dialect: 'hive',
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['GROUP', 'ROLE', 'USER']
@@ -184,7 +181,6 @@
             afterCursor: '',
             dialect: 'hive',
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['WITH GRANT OPTION']
@@ -198,7 +194,6 @@
             afterCursor: '',
             dialect: 'hive',
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['GRANT OPTION']
@@ -395,7 +390,6 @@
             dialect: 'hive',
             noErrors: true,
             containsKeywords: ['SELECT'],
-            hasLocations: true,
             expectedResult: {
               lowerCase: false
             }
@@ -502,7 +496,6 @@
             afterCursor: '',
             noErrors: true,
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['TO']
@@ -516,7 +509,6 @@
             afterCursor: '',
             noErrors: true,
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['ROLE']
@@ -530,7 +522,6 @@
             afterCursor: '',
             noErrors: true,
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['WITH GRANT OPTION']
@@ -544,7 +535,6 @@
             afterCursor: '',
             noErrors: true,
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['GRANT OPTION']
@@ -558,7 +548,6 @@
             afterCursor: '',
             noErrors: true,
             dialect: 'impala',
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['OPTION']
@@ -586,7 +575,6 @@
             dialect: 'impala',
             noErrors: true,
             containsKeywords: ['SELECT'],
-            hasLocations: true,
             expectedResult: {
               lowerCase: false
             }
@@ -866,7 +854,6 @@
             afterCursor: '',
             dialect: 'hive',
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['FROM']
@@ -893,7 +880,6 @@
             afterCursor: '',
             dialect: 'hive',
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['GROUP', 'ROLE', 'USER']
@@ -907,7 +893,6 @@
             afterCursor: '',
             dialect: 'hive',
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['GROUP', 'ROLE', 'USER']
@@ -948,7 +933,6 @@
             dialect: 'hive',
             noErrors: true,
             containsKeywords: ['SELECT'],
-            hasLocations: true,
             expectedResult: {
               lowerCase: false
             }
@@ -1068,7 +1052,6 @@
             afterCursor: '',
             dialect: 'impala',
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['FROM']
@@ -1082,7 +1065,6 @@
             afterCursor: '',
             dialect: 'impala',
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['ROLE']
@@ -1096,7 +1078,6 @@
             afterCursor: '',
             dialect: 'impala',
             noErrors: true,
-            hasLocations: true,
             expectedResult: {
               lowerCase: false,
               suggestKeywords: ['ROLE']
@@ -1164,7 +1145,6 @@
             dialect: 'impala',
             noErrors: true,
             containsKeywords: ['SELECT'],
-            hasLocations: true,
             expectedResult: {
               lowerCase: false
             }

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

@@ -31,7 +31,6 @@
         beforeCursor: 'INSERT INTO bla.boo VALUES (1, 2, \'a\', 3); ',
         afterCursor: '',
         noErrors: true,
-        hasLocations: true,
         containsKeywords: ['SELECT'],
         expectedResult: {
           lowerCase: false
@@ -107,7 +106,6 @@
         afterCursor: '',
         containsKeywords: ['VALUES'],
         noErrors: true,
-        hasLocations: true,
         expectedResult: {
           lowerCase: false
         }
@@ -120,7 +118,6 @@
         afterCursor: '',
         containsKeywords: ['VALUES'],
         noErrors: true,
-        hasLocations: true,
         expectedResult: {
           lowerCase: false
         }
@@ -134,7 +131,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -148,7 +144,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -162,7 +157,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -176,7 +170,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -192,7 +185,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -206,7 +198,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -260,7 +251,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: true,
             suggestKeywords: ['INSERT INTO', 'INSERT OVERWRITE', 'SELECT']
@@ -274,7 +264,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['INTO', 'OVERWRITE']
@@ -288,7 +277,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestTables: {},
@@ -304,7 +292,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestTables: { identifierChain: [{ name: 'baa' }] }
@@ -318,7 +305,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION', 'SELECT']
@@ -331,7 +317,6 @@
           beforeCursor: 'FROM baa.boo INSERT INTO TABLE baa PARTITION (',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }] }] }
@@ -344,7 +329,6 @@
           beforeCursor: 'FROM baa.boo INSERT INTO TABLE baa PARTITION (a,b) (',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }] }] }
@@ -358,7 +342,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['SELECT']
@@ -372,7 +355,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['ALL', 'DISTINCT'],
           expectedResult: {
             lowerCase: false,
@@ -390,7 +372,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['*'],
           expectedResult: {
             lowerCase: false,
@@ -408,7 +389,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsColRefKeywords: true,
           containsKeywords: ['WHERE', 'ORDER BY'],
           doesNotContainKeywords: ['FROM'],
@@ -425,7 +405,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION', 'SELECT']
@@ -439,7 +418,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION', 'SELECT']
@@ -452,7 +430,6 @@
           beforeCursor: 'FROM baa.boo INSERT OVERWRITE bla.ble PARTITION (',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'bla' }, { name: 'ble' }] }] }
@@ -466,7 +443,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['IF NOT EXISTS', 'SELECT']
@@ -480,7 +456,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['NOT EXISTS']
@@ -494,7 +469,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['EXISTS']
@@ -508,7 +482,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['SELECT']
@@ -522,7 +495,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['*'],
           expectedResult: {
             lowerCase: false,
@@ -540,7 +512,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsColRefKeywords: true,
           containsKeywords: ['WHERE', 'ORDER BY'],
           doesNotContainKeywords: ['FROM'],
@@ -557,7 +528,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsColRefKeywords: true,
           containsKeywords: ['WHERE', 'ORDER BY'],
           doesNotContainKeywords: ['FROM'],
@@ -574,7 +544,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['*'],
           expectedResult: {
             lowerCase: false,
@@ -592,7 +561,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsColRefKeywords: true,
           containsKeywords: ['WHERE', 'ORDER BY'],
           doesNotContainKeywords: ['FROM'],
@@ -650,7 +618,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION', 'VALUES', 'SELECT']
@@ -663,7 +630,6 @@
           beforeCursor: 'INSERT INTO TABLE baa PARTITION (',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }] }] }
@@ -676,7 +642,6 @@
           beforeCursor: 'INSERT INTO TABLE baa PARTITION (a,b) (x, ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'baa' }] }] }
@@ -690,7 +655,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: true,
             suggestKeywords: ['SELECT']
@@ -704,7 +668,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['*'],
           expectedResult: {
             lowerCase: false,
@@ -723,7 +686,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestFunctions: {},
@@ -741,7 +703,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['AS', 'IN'],
           expectedResult: {
             lowerCase: false,
@@ -798,7 +759,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['SELECT']
@@ -812,7 +772,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION', 'SELECT']
@@ -826,7 +785,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION', 'SELECT']
@@ -839,7 +797,6 @@
           beforeCursor: 'INSERT OVERWRITE bla.ble PARTITION (',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'bla' }, { name: 'ble' }] }] }
@@ -853,7 +810,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['IF NOT EXISTS', 'SELECT']
@@ -867,7 +823,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['NOT EXISTS']
@@ -881,7 +836,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['EXISTS']
@@ -895,7 +849,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['SELECT']
@@ -909,7 +862,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['*'],
           expectedResult: {
             lowerCase: false,
@@ -927,7 +879,6 @@
           beforeCursor: 'INSERT OVERWRITE bla.ble SELECT c, d ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           noErrors: true,
           containsKeywords: ['AS', 'IN'],
           expectedResult: {
@@ -944,7 +895,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestTables: {},
@@ -961,7 +911,6 @@
           beforeCursor: 'INSERT INTO TABLE boo.baa (a, b) PARTITION (a=1) VALUES (1, 2);',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           noErrors: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
@@ -975,7 +924,6 @@
           beforeCursor: 'INSERT OVERWRITE boo.baa [SHUFFLE] SELECT * FROM bla;',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           noErrors: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
@@ -989,7 +937,6 @@
           beforeCursor: 'WITH t1 AS (SELECT 1), t2 AS (SELECT 2) INSERT OVERWRITE tab SELECT * FROM t1, t2;',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           noErrors: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
@@ -1058,7 +1005,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION', '[NOSHUFFLE]', '[SHUFFLE]', 'SELECT', 'VALUES']
@@ -1072,7 +1018,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['SELECT']
@@ -1086,7 +1031,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestTables: {},
@@ -1100,7 +1044,6 @@
           beforeCursor: 'INSERT INTO boo.baa (',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'boo' }, { name: 'baa' }] }] }
@@ -1113,7 +1056,6 @@
           beforeCursor: 'INSERT INTO boo.baa (a, ',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'boo' }, { name: 'baa' }] }] }
@@ -1127,7 +1069,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION', '[NOSHUFFLE]', '[SHUFFLE]', 'SELECT', 'VALUES']
@@ -1140,7 +1081,6 @@
           beforeCursor: 'INSERT INTO TABLE boo.baa (a, b) PARTITION(a = 1, ',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'boo' }, { name: 'baa' }] }] }
@@ -1153,7 +1093,6 @@
           beforeCursor: 'INSERT INTO TABLE boo.baa (a, b) VALUES (1, 2) |',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false
           }
@@ -1181,7 +1120,6 @@
           afterCursor: '',
           dialect: 'impala',
           noErrors: true,
-          hasLocations: true,
           expectedResult: {
             lowerCase: true,
             suggestTables: {},

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

@@ -80,7 +80,6 @@
           beforeCursor: 'LOAD DATA INPATH \'/',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestHdfs: { path: '/'}
@@ -93,7 +92,6 @@
           beforeCursor: 'LOAD DATA INPATH \'/some/path\' ',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['INTO TABLE', 'OVERWRITE INTO TABLE']
@@ -106,7 +104,6 @@
           beforeCursor: 'LOAD DATA INPATH \'/some/path\' OVERWRITE ',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['INTO TABLE']
@@ -119,7 +116,6 @@
           beforeCursor: 'LOAD DATA INPATH \'some/path\' INTO ',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['TABLE']
@@ -132,7 +128,6 @@
           beforeCursor: 'LOAD DATA INPATH \'some/path\' INTO TABLE boo ',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION']
@@ -145,7 +140,6 @@
           beforeCursor: 'LOAD DATA INPATH \'some/path\' INTO TABLE boo PARTITION (',
           afterCursor: '',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'boo' }] }] }
@@ -159,7 +153,6 @@
           beforeCursor: 'LOAD DATA INPATH \'/',
           afterCursor: '/bar\' INTO TABLE foo',
           dialect: 'impala',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestHdfs: { path: '/'}
@@ -175,7 +168,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -236,7 +228,6 @@
           beforeCursor: 'LOAD DATA INPATH \'/',
           afterCursor: '\'',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestHdfs: { path: '/'}
@@ -249,7 +240,6 @@
           beforeCursor: 'LOAD DATA INPATH \'baa\' ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['INTO TABLE', 'OVERWRITE INTO TABLE']
@@ -262,7 +252,6 @@
           beforeCursor: 'LOAD DATA INPATH \'baa\' OVERWRITE ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['INTO TABLE']
@@ -275,7 +264,6 @@
           beforeCursor: 'LOAD DATA INPATH \'baa\' INTO ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['TABLE']
@@ -288,7 +276,6 @@
           beforeCursor: 'LOAD DATA INPATH \'baa\' OVERWRITE INTO TABLE ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestTables: {},
@@ -302,7 +289,6 @@
           beforeCursor: 'LOAD DATA INPATH \'baa\' INTO TABLE baa ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION']
@@ -315,7 +301,6 @@
           beforeCursor: 'LOAD DATA INPATH \'baa\' INTO TABLE boo.baa PARTITION (',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestColumns: { tables: [{ identifierChain: [{ name: 'boo' }, { name: 'baa' }] }] }
@@ -343,7 +328,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -357,7 +341,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -371,7 +354,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -385,7 +367,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -399,7 +380,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -474,7 +454,6 @@
           beforeCursor: 'IMPORT TABLE bla ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION', 'FROM']
@@ -487,7 +466,6 @@
           beforeCursor: 'IMPORT EXTERNAL TABLE bla PARTITION (bla=1) ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['FROM']
@@ -500,7 +478,6 @@
           beforeCursor: 'IMPORT EXTERNAL TABLE bla PARTITION (bla=1) FROM \'',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestHdfs: { path: '' }
@@ -513,7 +490,6 @@
           beforeCursor: 'IMPORT FROM \'/bla/bla\' ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['LOCATION']
@@ -526,7 +502,6 @@
           beforeCursor: 'IMPORT EXTERNAL TABLE bla PARTITION (bla=1) FROM \'/bla/bla\' LOCATION \'/bla/',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestHdfs: { path: '/bla/' }
@@ -540,7 +515,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -554,7 +528,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -568,7 +541,6 @@
           afterCursor: '',
           dialect: 'hive',
           noErrors: true,
-          hasLocations: true,
           containsKeywords: ['SELECT'],
           expectedResult: {
             lowerCase: false
@@ -606,7 +578,6 @@
           beforeCursor: 'EXPORT TABLE db.tbl ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION', 'TO']
@@ -619,7 +590,6 @@
           beforeCursor: 'EXPORT TABLE db.tbl PARTITION (bla=1) ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['TO']
@@ -632,7 +602,6 @@
           beforeCursor: 'EXPORT TABLE db.tbl PARTITION (bla=1) TO \'',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestHdfs: { path: '' }
@@ -645,7 +614,6 @@
           beforeCursor: 'EXPORT TABLE db.tbl TO \'/bla/bla\' ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['FOR replication()']
@@ -658,7 +626,6 @@
           beforeCursor: 'EXPORT TABLE db.tbl TO \'/bla/bla\' FOR ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['replication()']

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

@@ -39,6 +39,7 @@
       assertLocations({
         beforeCursor: 'SELECT * FROM testTable1 JOIN db1.table2; ',
         expectedLocations: [
+          { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 41 } },
           { type: 'asterisk', location: { first_line:1, last_line:1, first_column: 8, last_column: 9 }, tables: [{ identifierChain: [{ name: 'testTable1' }] }, { identifierChain: [{ name: 'db1' }, { name: 'table2' }] }] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 25 }, identifierChain: [{ name: 'testTable1' }] },
           { type: 'database', location: { first_line: 1, last_line: 1, first_column: 31, last_column: 34}, identifierChain: [{ name: 'db1' }]},
@@ -52,6 +53,7 @@
         dialect: 'impala',
         beforeCursor: 'SELECT db.tbl.col FROM db.tbl; ',
         expectedLocations: [
+          { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 30 } },
           { type: 'database', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 10 }, identifierChain: [{ name: 'db' }]},
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 11, last_column: 14 }, identifierChain: [{ name: 'db' }, { name: 'tbl' }]},
           { type: 'column', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 18 }, identifierChain: [{ name: 'db' }, { name: 'tbl' },{ name: 'col'}]},
@@ -65,6 +67,7 @@
       assertLocations({
         beforeCursor: 'SELECT t3.id, id FROM testTable1, db.testTable2, testTable3 t3;',
         expectedLocations: [
+          { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 63 } },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 10 }, identifierChain: [{ name: 'testTable3' }] },
           { type:'column', location: { first_line: 1, last_line: 1, first_column: 11, last_column: 13 }, identifierChain: [{ name: 'testTable3' },{ name: 'id' }] },
           { type:'column', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 17 }, identifierChain: [{ name: 'id' }], tables: [{ identifierChain: [{ name: 'testTable1' }]}, { identifierChain: [{ name: 'db' }, { name: 'testTable2' }]}, { identifierChain: [{ name: 'testTable3' }], alias: 't3'}] },
@@ -80,6 +83,7 @@
       assertLocations({
         beforeCursor: 'SELECT * FROM foo WHERE bar IN (1+1, 2+2);',
         expectedLocations: [
+          { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 42 } },
           { type: 'asterisk', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 9 }, tables: [{ identifierChain: [{ name: 'foo' }] }] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 18 }, identifierChain: [{ name: 'foo' }]},
           { type: 'column', location: { first_line: 1, last_line: 1, first_column: 25, last_column: 28 }, identifierChain:[{ name: 'foo' }, { name: 'bar'}]}
@@ -91,6 +95,7 @@
       assertLocations({
         beforeCursor: 'SELECT * FROM foo WHERE bar IN (id+1-1, id+1-2);',
         expectedLocations: [
+          { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 48 } },
           { type: 'asterisk', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 9 }, tables: [{ identifierChain: [{ name: 'foo' }] }] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 18 }, identifierChain: [{ name: 'foo' }]},
           { type: 'column', location: { first_line: 1, last_line: 1, first_column: 25, last_column: 28 }, identifierChain:[{ name: 'foo' }, { name: 'bar'}]},
@@ -120,6 +125,7 @@
         'ORDER BY s08.salary-s07.salary DESC\r\n' +
         'LIMIT 1000;',
         expectedLocations: [
+          { type: 'statement', location: { first_line: 1, last_line: 9, first_column: 1, last_column: 11 } },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 }, identifierChain: [{ name: 'sample_07' }] },
           { type: 'column', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 23 }, identifierChain: [{ name: 'sample_07' }, { name: 'description' }] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 25, last_column: 28 }, identifierChain: [{ name: 'sample_07' }] },
@@ -148,12 +154,11 @@
       });
     });
 
-
-
     it('should report locations for "SELECT * FROM foo WHERE bar IN (id+1-1, id+1-2);|"', function() {
       assertLocations({
         beforeCursor: 'SELECT * FROM foo WHERE bar IN (id+1-1, id+1-2);',
         expectedLocations: [
+          { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 48 } },
           { type: 'asterisk', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 9 }, tables: [{ identifierChain: [{ name: 'foo' }] }] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 18 }, identifierChain: [{ name: 'foo' }]},
           { type: 'column', location: { first_line: 1, last_line: 1, first_column: 25, last_column: 28 }, identifierChain:[{ name: 'foo' }, { name: 'bar'}]},
@@ -172,6 +177,7 @@
       assertLocations({
         beforeCursor: 'SELECT CASE cos(boo.a) > baa.boo \n\tWHEN baa.b THEN true \n\tWHEN boo.c THEN false \n\tWHEN baa.blue THEN boo.d \n\tELSE baa.e END \n\t FROM db1.foo boo, bar baa WHERE baa.bla IN (SELECT ble FROM bla);',
         expectedLocations: [
+          { type: 'statement', location: { first_line: 1, last_line: 6, first_column: 1, last_column: 67 } },
           { type: 'function', location: { first_line: 1, last_line: 1, first_column: 13, last_column: 15 }, function: 'cos'},
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 17, last_column: 20 }, identifierChain: [{ name: 'db1' },{ name: 'foo' }]},
           { type: 'column', location: { first_line: 1, last_line: 1, first_column: 21, last_column: 22 }, identifierChain: [{ name: 'db1' }, { name: 'foo' }, { name: 'a' }]},
@@ -202,6 +208,7 @@
       assertLocations({
         beforeCursor: 'SELECT tta.* FROM testTableA tta, testTableB; ',
         expectedLocations: [
+          { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 45 } },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'testTableA' }]},
           { type: 'asterisk', location:{ first_line: 1, last_line: 1, first_column: 12, last_column: 13 }, tables: [{ alias: 'tta', identifierChain: [{ name: 'testTableA' }] }] },
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 19, last_column: 29}, identifierChain: [{ name: 'testTableA' }]},
@@ -214,6 +221,7 @@
       assertLocations({
         beforeCursor: 'SELECT COUNT(*) FROM testTable;',
         expectedLocations: [
+          { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 31 } },
           { type: 'function', location:{ first_line: 1, last_line: 1, first_column: 8, last_column: 12}, function: 'count'},
           { type: 'table', location: { first_line: 1, last_line: 1, first_column: 22, last_column: 31}, identifierChain: [{ name: 'testTable' }]}
         ]
@@ -226,6 +234,7 @@
           dialect: 'hive',
           beforeCursor: 'LOAD DATA LOCAL INPATH \'/some/path/file.ble\' OVERWRITE INTO TABLE bla;',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 70 } },
             { type: 'hdfs', location: {first_line: 1, last_line: 1, first_column: 25, last_column: 44}, path: '/some/path/file.ble' },
             { type: 'table', location: {first_line: 1, last_line: 1, first_column: 67, last_column: 70}, identifierChain: [{name: 'bla'}] }
           ]
@@ -237,6 +246,7 @@
           dialect: 'impala',
           beforeCursor: 'CREATE TABLE bla (id INT) LOCATION \'/bla/bla/\';',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 47 } },
             { type: 'hdfs', location: {first_line: 1, last_line: 1, first_column: 37, last_column: 46}, path: '/bla/bla/' }
           ]
         });
@@ -249,6 +259,7 @@
           dialect: 'hive',
           beforeCursor: 'SELECT * FROM testTable t1 ORDER BY t1.a ASC, t1.b, t1.c DESC, t1.d;\nSELECT t1.bla FROM testTable2 t1;\nSELECT * FROM testTable3 t3, testTable4 t4; ',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 68 } },
             { type: 'asterisk', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 9 }, tables: [{ alias: 't1', identifierChain: [{ name: 'testTable' }] }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 24 }, identifierChain: [{ name: 'testTable' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 37, last_column: 39 }, identifierChain: [{ name: 'testTable' }]},
@@ -259,9 +270,11 @@
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 56, last_column: 57 }, identifierChain: [{ name: 'testTable' }, { name: 'c' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 64, last_column: 66 }, identifierChain: [{ name: 'testTable' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 67, last_column: 68 }, identifierChain: [{ name: 'testTable' }, { name: 'd' }]},
+            { type: 'statement', location: { first_line: 2, last_line: 2, first_column: 1, last_column: 33 } },
             { type: 'table', location: { first_line: 2, last_line: 2, first_column: 8, last_column: 10 }, identifierChain: [{ name: 'testTable2' }]},
             { type: 'column', location: { first_line: 2, last_line: 2, first_column: 11, last_column: 14 }, identifierChain: [{ name: 'testTable2' }, { name: 'bla' }]},
             { type: 'table', location: { first_line: 2, last_line: 2, first_column: 20, last_column: 30 }, identifierChain: [{ name: 'testTable2' }]},
+            { type: 'statement', location: { first_line: 3, last_line: 3, first_column: 1, last_column: 43 } },
             { type: 'asterisk', location: { first_line: 3, last_line: 3, first_column: 8, last_column: 9 }, tables: [{ alias: 't3', identifierChain: [{ name: 'testTable3' }]}, { alias: 't4', identifierChain: [{ name: 'testTable4' }] }] },
             { type: 'table', location: { first_line: 3, last_line: 3, first_column: 15, last_column: 25 }, identifierChain: [{ name: 'testTable3' }]},
             { type: 'table', location: { first_line: 3, last_line: 3, first_column: 30, last_column: 40 }, identifierChain: [{ name: 'testTable4' }]}
@@ -274,6 +287,7 @@
           dialect: 'hive',
           beforeCursor: 'SELECT t1.foo FROM table1 t1 CROSS JOIN table2 LEFT OUTER JOIN table3 JOIN table4 t4 ON (t1.c1 = table2.c2); ',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 108 } },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 10 }, identifierChain: [{ name: 'table1' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 11, last_column: 14 }, identifierChain: [{ name: 'table1' },{ name: 'foo' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 20, last_column: 26 }, identifierChain: [{ name: 'table1' }]},
@@ -293,6 +307,7 @@
           dialect: 'hive',
           beforeCursor: 'SELECT * FROM foo WHERE bar IN (SELECT * FROM bla);',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 51 } },
             { type: 'asterisk', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 9 }, tables: [{ identifierChain: [{ name: 'foo' }] }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 18 }, identifierChain: [{ name: 'foo' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 25, last_column: 28 }, identifierChain:[{ name: 'foo' }, { name: 'bar'}]},
@@ -308,6 +323,7 @@
           beforeCursor: 'SELECT   ',
           afterCursor: '    FROM    testTableA',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 32 } },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 22, last_column: 32}, identifierChain: [{ name: 'testTableA' }]}
           ]
         });
@@ -319,6 +335,7 @@
           beforeCursor: 'SELECT   a.',
           afterCursor: '    FROM    testTableA',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 34 } },
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 10, last_column: 11 }, identifierChain: [{ name: 'testTableA' },{ name: 'a' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 24, last_column: 34}, identifierChain: [{ name: 'testTableA' }]}
           ]
@@ -331,6 +348,7 @@
           beforeCursor: 'SELECT aaa',
           afterCursor: ' FROM testTableA',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 27 } },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 17, last_column: 27}, identifierChain: [{ name: 'testTableA' }]}
           ]
         });
@@ -342,6 +360,7 @@
           beforeCursor: 'SELECT aaa',
           afterCursor: ' \nFROM testTableA',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 2, first_column: 1, last_column: 16 } },
             { type: 'table', location: { first_line: 2, last_line: 2, first_column: 6, last_column: 16}, identifierChain: [{ name: 'testTableA' }]}
           ]
         });
@@ -353,17 +372,19 @@
           beforeCursor: 'SELECT ',
           afterCursor: 'bbbb FROM testTableA',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 28 } },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 18, last_column: 28}, identifierChain: [{ name: 'testTableA' }]}
           ]
         });
       });
 
-      it('should report locations for "SELECT a.aaaaa|bbbb FROM testTableA"', function() {
+      it('should report locations for "SELECT aaaaa|bbbb FROM testTableA"', function() {
         assertLocations({
           dialect: 'hive',
           beforeCursor: 'SELECT aaaaa',
           afterCursor: 'bbbb FROM testTableA',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 33 } },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 23, last_column: 33}, identifierChain: [{ name: 'testTableA' }]}
           ]
         });
@@ -375,6 +396,7 @@
           beforeCursor: 'SELECT foo.aaaaa',
           afterCursor: 'bbbb FROM testTableA',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 37 } },
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'testTableA' },{ name: 'foo' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 27, last_column: 37}, identifierChain: [{ name: 'testTableA' }]}
           ]
@@ -387,6 +409,7 @@
           beforeCursor: 'SELECT b, foo.aaaaa',
           afterCursor: 'bbbb FROM testTableA',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 40 } },
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 9}, identifierChain: [{ name: 'testTableA' }, { name: 'b' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 11, last_column: 14}, identifierChain: [{ name: 'testTableA' },{ name: 'foo' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 30, last_column: 40}, identifierChain: [{ name: 'testTableA' }]}
@@ -400,6 +423,7 @@
           beforeCursor: 'SELECT foo, aaaaa',
           afterCursor: 'bbbb FROM testTableA',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 38 } },
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'testTableA' }, { name: 'foo' }]},
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 28, last_column: 38}, identifierChain: [{ name: 'testTableA' }]}
           ]
@@ -412,6 +436,7 @@
           beforeCursor: 'SELECT testTableB.a, cos(1), tta.abcdefg',
           afterCursor: 'hijk, tta.bla, cos(1) FROM testTableA tta, testTableB;',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 94 } },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 18 }, identifierChain: [{ name: 'testTableB' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 19, last_column: 20 }, identifierChain: [{ name: 'testTableB' },{ name: 'a' }]},
             { type: 'function', location: { first_line: 1, last_line: 1, first_column: 22, last_column: 24 }, function: 'cos' },
@@ -433,6 +458,7 @@
           beforeCursor: 'SELECT tmp.bc, ROUND(tmp.r, 2) AS r FROM ( SELECT tstDb1.b1.cat AS bc, SUM(tstDb1.b1.price * tran.qua) AS r FROM tstDb1.b1 JOIN [SHUFFLE] tran ON ( tran.b_id = tstDb1.b1.id AND YEAR(tran.tran_d) BETWEEN 2008 AND 2010) GROUP BY tstDb1.b1.cat) tmp ORDER BY r DESC LIMIT 60;',
           afterCursor: '',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 271 } },
             { type: 'subQuery', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11 }, identifierChain: [{ subQuery: 'tmp' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 14 }, identifierChain: [{ subQuery: 'tmp' },{name: 'bc' }]},
             { type: 'function', location: { first_line: 1, last_line: 1, first_column: 16, last_column: 20 }, function: 'round' },
@@ -472,6 +498,7 @@
           beforeCursor: 'SELECT * FROM testTable ORDER BY a ASC, b, c DESC, d; ',
           afterCursor: '',
           expectedLocations: [
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 53 } },
             { type: 'asterisk', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 9 }, tables: [{ identifierChain: [{ name: 'testTable' }] }] },
             { type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 24 }, identifierChain: [{ name: 'testTable' }]},
             { type: 'column', location: { first_line: 1, last_line: 1, first_column: 34, last_column: 35 }, identifierChain: [{ name: 'testTable' }, { name: 'a'}]},

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 20 - 127
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSelect.js


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

@@ -833,7 +833,6 @@
           beforeCursor: 'SHOW LOCKS tableName ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['EXTENDED', 'PARTITION']
@@ -846,7 +845,6 @@
           beforeCursor: 'SHOW LOCKS tableName PARTITION (ds=\'2010-03-03\', hr=\'12\') ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['EXTENDED']
@@ -889,7 +887,6 @@
           beforeCursor: 'SHOW PARTITIONS foo ',
           afterCursor: '',
           dialect: 'hive',
-          hasLocations: true,
           expectedResult: {
             lowerCase: false,
             suggestKeywords: ['PARTITION']

+ 31 - 23
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecUpdate.js

@@ -45,7 +45,8 @@
           lowerCase: false,
           suggestKeywords: ['SET'],
           locations: [
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar'}]}
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 12 } },
+            { type: 'table', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar'}] }
           ]
         }
       });
@@ -59,9 +60,10 @@
           lowerCase: false,
           suggestKeywords: ['WHERE'],
           locations: [
-            {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' }]}
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 27 } },
+            { 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' }] }
           ]
         }
       });
@@ -75,8 +77,9 @@
           lowerCase: false,
           suggestKeywords: ['='],
           locations: [
-            {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: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 18 } },
+            { 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' }] }
           ]
         }
       });
@@ -140,8 +143,9 @@
           lowerCase: false,
           suggestColumns: { tables: [{ identifierChain: [{ name: 'bar'}, { name: 'foo' }] }] },
           locations: [
-            {type: 'database', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar' }]},
-            {type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15}, identifierChain: [{ name: 'bar'}, { name: 'foo' }]}
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 19 } },
+            { type: 'database', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar' }] },
+            { type: 'table', location: { first_line: 1, last_line: 1, first_column: 12, last_column: 15}, identifierChain: [{ name: 'bar'}, { name: 'foo' }] }
           ]
         }
       });
@@ -155,10 +159,11 @@
           lowerCase: false,
           suggestColumns: { tables: [{ identifierChain: [{ name: 'bar'}, { name: 'foo' }] }] },
           locations: [
-            {type: 'database', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar' }]},
-            {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' }]}
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 40 } },
+            { type: 'database', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar' }] },
+            { 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' }] }
           ]
         }
       });
@@ -174,9 +179,10 @@
           suggestColumns: { tables: [{ identifierChain: [{ name: 'bar'}, { name: 'foo' }] }] },
           suggestKeywords: ['EXISTS', 'NOT EXISTS'],
           locations: [
-            {type: 'database', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar' }]},
-            {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: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 37 } },
+            { type: 'database', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar' }] },
+            { 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' }] }
           ]
         }
       });
@@ -189,10 +195,11 @@
         containsKeywords: ['CASE'],
         expectedResult: {
           locations: [
-            {type: 'database', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar' }]},
-            {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'}]}
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 42 } },
+            { type: 'database', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar' }] },
+            { 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: {},
@@ -213,10 +220,11 @@
           suggestFunctions: {},
           suggestColumns: { tables: [{ identifierChain: [{ name: 'bar'}, { name: 'foo' }] }] },
           locations: [
-            {type: 'database', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar' }]},
-            {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'}]}
+            { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 48 } },
+            { type: 'database', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 11}, identifierChain: [{ name: 'bar' }] },
+            { 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'}] }
           ]
         }
       });

+ 10 - 9
desktop/core/src/desktop/static/desktop/spec/autocompleterTestUtils.js

@@ -19,7 +19,8 @@ var SqlTestUtils = (function() {
   var jsonStringToJsString = function (jsonString) {
     return jsonString.replace(/'([a-zA-Z]+)':/g, function (all, group) {
       return group + ':';
-    }).replace(/([:{,])/g, function (all, group) { return group + ' ' }).replace(/[}]/g, ' }');
+    }).replace(/([:{,])/g, function (all, group) { return group + ' ' }).replace(/[}]/g, ' }').replace(/["]/g, '\'')
+        .replace(/'([a-z_]+)':/gi, '$1:');
   };
 
   return {
@@ -61,8 +62,8 @@ var SqlTestUtils = (function() {
                 pass: jasmine.matchersUtil.equals(actualResponse.locations, testDefinition.expectedLocations),
                 message: '\n        Statement: ' + testDefinition.beforeCursor + '|' + testDefinition.afterCursor + '\n' +
                 '          Dialect: ' + testDefinition.dialect + '\n' +
-                'Expected locations: ' + JSON.stringify(testDefinition.expectedLocations).replace(/["]/g, '\'') + '\n' +
-                '  Parser locations: ' + JSON.stringify(actualResponse.locations).replace(/["]/g, '\'') +   '\n'
+                'Expected locations: ' + jsonStringToJsString(JSON.stringify(testDefinition.expectedLocations)) + '\n' +
+                '  Parser locations: ' + jsonStringToJsString(JSON.stringify(actualResponse.locations)) +   '\n'
               };
             }
 
@@ -74,17 +75,17 @@ var SqlTestUtils = (function() {
               actualResponse.suggestKeywords = weightFreeKeywords;
             }
 
-            if (testDefinition.hasLocations) {
-              if (actualResponse.locations.length === 0) {
+            if (!!testDefinition.noLocations) {
+              if (actualResponse.locations.length > 0) {
                 return {
                   pass: false,
                   message: '\nStatement: ' + testDefinition.beforeCursor + '|' + testDefinition.afterCursor + '\n' +
                   '  Dialect: ' + testDefinition.dialect + '\n' +
-                  '           No locations found'
+                  '           Expected no locations, found ' + actualResponse.locations.length
                 }
               }
             }
-            if (testDefinition.hasLocations || actualResponse.locations.length === 0) {
+            if (typeof testDefinition.expectedResult.locations === 'undefined') {
               delete actualResponse.locations;
             }
             var deleteKeywords = false;
@@ -149,8 +150,8 @@ var SqlTestUtils = (function() {
               pass: jasmine.matchersUtil.equals(actualResponse, testDefinition.expectedResult),
               message: '\n        Statement: ' + testDefinition.beforeCursor + '|' + testDefinition.afterCursor + '\n' +
                          '          Dialect: ' + testDefinition.dialect + '\n' +
-                         'Expected response: ' + jsonStringToJsString(JSON.stringify(testDefinition.expectedResult).replace(/["]/g, '\'') + '\n') +
-                         '  Parser response: ' + jsonStringToJsString(JSON.stringify(actualResponse).replace(/["]/g, '\'') +   '\n')
+                         'Expected response: ' + jsonStringToJsString(JSON.stringify(testDefinition.expectedResult) + '\n') +
+                         '  Parser response: ' + jsonStringToJsString(JSON.stringify(actualResponse) +   '\n')
             };
           }
         }

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác