Explorar o código

HUE-4306 [editor] The new autocompleter should complete CASE functions

Some other minor things fixed:

- It now supports empty statements i.e. ";;;|;;"
- Added DESCRIBE FUNCTION completion
- Overall structure of parser and jasmine tests improved
- Fixed issue with odd keywords with "select 1 < |..."
- Fixed issue with negation for "select -1 > ..."
Johan Ahlen %!s(int64=9) %!d(string=hai) anos
pai
achega
567d8f2

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 476 - 169
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.jison


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js


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

@@ -38,8 +38,52 @@ define([
 
     var assertAutoComplete = testUtils.assertAutocomplete;
 
+    it('should suggest keywords for ";;|"', function() {
+      assertAutoComplete({
+        beforeCursor: ';;',
+        afterCursor: '',
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should suggest keywords for ";|;"', function() {
+      assertAutoComplete({
+        beforeCursor: ';',
+        afterCursor: ';',
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should suggest keywords for "|;;;;', function() {
+      assertAutoComplete({
+        beforeCursor: '',
+        afterCursor: ';;;;',
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
+    it('should suggest keywords for "foo|bar"', function() {
+      assertAutoComplete({
+        beforeCursor: 'foo',
+        afterCursor: 'bar',
+        containsKeywords: ['SELECT'],
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
     describe('Impala specific', function () {
-      it('should suggest keywords for empty statement', function() {
+      it('should suggest keywords for "|"', function() {
         assertAutoComplete({
           beforeCursor: '',
           afterCursor: '',
@@ -52,24 +96,10 @@ define([
           }
         });
       });
-
-      it('should suggest keywords for partial statement', function() {
-        assertAutoComplete({
-          beforeCursor: 'foo',
-          afterCursor: 'bar',
-          dialect: 'impala',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['ALTER', 'COMPUTE', 'CREATE', 'DELETE', 'DESCRIBE',
-              'DROP', 'EXPLAIN', 'INSERT', 'INVALIDATE', 'LOAD', 'REFRESH',
-              'REVOKE', 'SELECT', 'SET', 'SHOW', 'TRUNCATE', 'UPDATE', 'USE']
-          }
-        });
-      });
     });
 
     describe('Hive specific', function () {
-      it('should suggest keywords for empty statement', function() {
+      it('should suggest keywords for "|"', function() {
         assertAutoComplete({
           beforeCursor: '',
           afterCursor: '',
@@ -82,32 +112,15 @@ define([
           }
         });
       });
-
-      it('should suggest keywords for partial statement', function() {
-        assertAutoComplete({
-          beforeCursor: 'foo',
-          afterCursor: 'bar',
-          dialect: 'hive',
-          expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['ALTER', 'ANALYZE', 'CREATE', 'DELETE', 'DESCRIBE',
-              'DROP', 'EXPLAIN', 'EXPORT', 'IMPORT', 'INSERT', 'LOAD', 'MSCK',
-              'REVOKE', 'SELECT', 'SET', 'SHOW', 'TRUNCATE', 'UPDATE', 'USE']
-          }
-        });
-      });
     });
 
     it('should ignore line comments for local suggestions', function () {
       assertAutoComplete({
         beforeCursor: '-- line comment\nSELECT * from testTable1;\n',
         afterCursor: '\n-- other line comment',
-        dialect: 'generic',
+        containsKeywords: ['SELECT'],
         expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['ALTER', 'CREATE', 'DELETE', 'DESCRIBE', 'DROP',
-            'EXPLAIN', 'INSERT', 'REVOKE', 'SELECT', 'SET', 'SHOW', 'TRUNCATE',
-            'UPDATE', 'USE']
+          lowerCase: false
         }
       });
     });
@@ -116,12 +129,9 @@ define([
       assertAutoComplete({
         beforeCursor: '/* line 1\nline 2\n*/\nSELECT * from testTable1;\n',
         afterCursor: '',
-        dialect: 'generic',
+        containsKeywords: ['SELECT'],
         expectedResult: {
-          lowerCase: false,
-          suggestKeywords: ['ALTER', 'CREATE', 'DELETE', 'DESCRIBE', 'DROP',
-            'EXPLAIN', 'INSERT', 'REVOKE', 'SELECT', 'SET', 'SHOW', 'TRUNCATE',
-            'UPDATE', 'USE']
+          lowerCase: false
         }
       });
     });

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

@@ -30,7 +30,7 @@ define([
 
     var assertAutoComplete = testUtils.assertAutocomplete;
 
-    it('should suggest keywords for empty statement', function() {
+    it('should suggest keywords for "|"', function() {
       assertAutoComplete({
         beforeCursor: '',
         afterCursor: '',
@@ -41,7 +41,7 @@ define([
       });
     });
 
-    it('should suggest keywords after CREATE', function () {
+    it('should suggest keywords for "CREATE |"', function () {
       assertAutoComplete({
         beforeCursor: 'CREATE ',
         afterCursor: '',
@@ -53,7 +53,7 @@ define([
       });
     });
 
-    it('should suggest keywords after CREATE DATABASE ', function () {
+    it('should suggest keywords for "CREATE DATABASE |"', function () {
       assertAutoComplete({
         beforeCursor: 'CREATE DATABASE ',
         afterCursor: '',
@@ -64,7 +64,7 @@ define([
       });
     });
 
-    it('should suggest keywords after CREATE DATABASE IF ', function () {
+    it('should suggest keywords for "CREATE DATABASE IF |"', function () {
       assertAutoComplete({
         beforeCursor: 'CREATE DATABASE IF ',
         afterCursor: '',
@@ -75,7 +75,7 @@ define([
       });
     });
 
-    it('should suggest keywords after CREATE SCHEMA ', function () {
+    it('should suggest keywords for "CREATE SCHEMA |"', function () {
       assertAutoComplete({
         beforeCursor: 'CREATE SCHEMA ',
         afterCursor: '',
@@ -86,7 +86,7 @@ define([
       });
     });
 
-    it('should suggest keywords after CREATE DATABASE and before Identifier', function () {
+    it('should suggest keywords for "CREATE DATABASE | bla;"', function () {
       assertAutoComplete({
         beforeCursor: 'CREATE DATABASE ',
         afterCursor: ' bla;',
@@ -97,7 +97,7 @@ define([
       });
     });
 
-    it('should suggest keywords after CREATE TABLE identifier (identifier ', function () {
+    it('should suggest keywords for "CREATE TABLE foo (id |"', function () {
       assertAutoComplete({
         beforeCursor: 'CREATE TABLE foo (id ',
         afterCursor: '',
@@ -109,7 +109,7 @@ define([
       });
     });
 
-    it('should suggest keywords after CREATE TABLE identifier (identifier INT, identifier FLOAT, identifier ', function () {
+    it('should suggest keywords for "CREATE TABLE foo (id INT, some FLOAT, bar |"', function () {
       assertAutoComplete({
         beforeCursor: 'CREATE TABLE foo (id INT, some FLOAT, bar ',
         afterCursor: '',
@@ -122,7 +122,7 @@ define([
     });
 
     describe('Impala specific', function () {
-      it('should suggest keywords after CREATE DATABASE foo ', function () {
+      it('should suggest keywords for "CREATE DATABASE foo |"', function () {
         assertAutoComplete({
           beforeCursor: 'CREATE DATABASE foo ',
           afterCursor: '',
@@ -136,7 +136,7 @@ define([
     });
 
     describe('Hive specific', function () {
-      it ('should suggest keywords after CREATE', function () {
+      it ('should suggest keywords for "CREATE |"', function () {
         assertAutoComplete({
           beforeCursor: 'CREATE ',
           afterCursor: '',
@@ -148,7 +148,7 @@ define([
         });
       });
 
-      it ('should suggest keywords after CREATE EXTERNAL TABLE identifier tableElementList', function () {
+      it ('should suggest keywords for "CREATE EXTERNAL TABLE foo (id int) |"', function () {
         assertAutoComplete({
           beforeCursor: 'CREATE EXTERNAL TABLE foo (id int) ',
           afterCursor: '',
@@ -160,7 +160,7 @@ define([
         });
       });
 
-      it('should suggest keywords in after CREATE TABLE identifier (identifier ', function () {
+      it('should suggest keywords for "CREATE TABLE foo (id |"', function () {
         assertAutoComplete({
           beforeCursor: 'CREATE TABLE foo (id ',
           afterCursor: '',
@@ -172,7 +172,7 @@ define([
         });
       });
 
-      it('should suggest keywords after CREATE DATABASE foo ', function () {
+      it('should suggest keywords for "CREATE DATABASE foo |"', function () {
         assertAutoComplete({
           beforeCursor: 'CREATE DATABASE foo ',
           afterCursor: '',
@@ -184,7 +184,7 @@ define([
         });
       });
 
-      it('should suggest keywords after CREATE DATABASE foo COMMENT ', function () {
+      it('should suggest keywords for "CREATE DATABASE foo COMMENT \'bla\' |"', function () {
         assertAutoComplete({
           beforeCursor: 'CREATE DATABASE foo COMMENT \'bla\' ',
           afterCursor: '',
@@ -196,7 +196,7 @@ define([
         });
       });
 
-      it('should suggest keywords after CREATE DATABASE foo COMMENT and LOCATION', function () {
+      it('should suggest keywords for "CREATE DATABASE foo COMMENT \'bla\' LOCATION \'/bla\' |"', function () {
         assertAutoComplete({
           beforeCursor: 'CREATE DATABASE foo COMMENT \'bla\' LOCATION \'/bla\' ',
           afterCursor: '',

+ 110 - 62
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe.js

@@ -32,7 +32,7 @@ define([
 
 
     describe('hive specific', function () {
-      it('should handle DESCRIBE tbl', function() {
+      it('should handle "DESCRIBE tbl;|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE tbl;',
           afterCursor: '',
@@ -44,7 +44,7 @@ define([
         });
       });
 
-      it('should handle DESCRIBE tbl.col.field', function() {
+      it('should handle "DESCRIBE tbl.col.field;|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE tbl col.field;',
           afterCursor: '',
@@ -56,7 +56,7 @@ define([
         });
       });
 
-      it('should handle EXTENDED tbl', function() {
+      it('should handle "DESCRIBE EXTENDED tbl;|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE EXTENDED tbl;',
           afterCursor: '',
@@ -68,7 +68,7 @@ define([
         });
       });
 
-      it('should handle EXTENDED tbl col.field', function() {
+      it('should handle "DESCRIBE EXTENDED tbl col.field;|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE EXTENDED tbl col.field;',
           afterCursor: '',
@@ -80,7 +80,7 @@ define([
         });
       });
 
-      it('should handle FORMATTED tbl', function() {
+      it('should handle "DESCRIBE FORMATTED tbl;|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE FORMATTED tbl;',
           afterCursor: '',
@@ -92,7 +92,7 @@ define([
         });
       });
 
-      it('should handle FORMATTED tbl.col.field', function() {
+      it('should handle "DESCRIBE FORMATTED tbl col.field;|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE FORMATTED tbl col.field;',
           afterCursor: '',
@@ -104,64 +104,57 @@ define([
         });
       });
 
-      it('should suggest keywords and tables after DESCRIBE', function() {
+      it('should handle "DESCRIBE FUNCTION cos;|"', function() {
         assertAutoComplete({
-          beforeCursor: 'DESCRIBE ',
+          beforeCursor: 'DESCRIBE FUNCTION cos;',
           afterCursor: '',
           dialect: 'hive',
+          containsKeywords: ['SELECT'],
           expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED', 'SCHEMA'],
-            suggestTables: {},
-            suggestDatabases: { appendDot: true }
+            lowerCase: false
           }
         });
       });
 
-      it('should suggest keywords and tables after DESCRIBE partial', function() {
+      it('should handle "DESCRIBE FUNCTION EXTENDED cos;|"', function() {
         assertAutoComplete({
-          beforeCursor: 'DESCRIBE tbl',
+          beforeCursor: 'DESCRIBE FUNCTION EXTENDED cos;',
           afterCursor: '',
           dialect: 'hive',
+          containsKeywords: ['SELECT'],
           expectedResult: {
-            lowerCase: false,
-            suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED', 'SCHEMA'],
-            suggestTables: {},
-            suggestDatabases: { appendDot: true }
+            lowerCase: false
           }
         });
       });
 
-      it('should suggest tables after DESCRIBE db.', function() {
+      it('should handle "DESCRIBE DATABASE db;|"', function() {
         assertAutoComplete({
-          beforeCursor: 'DESCRIBE db.',
+          beforeCursor: 'DESCRIBE DATABASE db;',
           afterCursor: '',
           dialect: 'hive',
+          containsKeywords: ['SELECT'],
           expectedResult: {
-            lowerCase: false,
-            suggestTables: { database: 'db' }
+            lowerCase: false
           }
         });
       });
 
-      it('should suggest columns after DESCRIBE db.tb ', function() {
+      it('should handle "DESCRIBE DATABASE EXTENDED db;|"', function() {
         assertAutoComplete({
-          beforeCursor: 'DESCRIBE db.tbl ',
+          beforeCursor: 'DESCRIBE DATABASE EXTENDED db;',
           afterCursor: '',
           dialect: 'hive',
+          containsKeywords: ['SELECT'],
           expectedResult: {
-            lowerCase: false,
-            suggestColumns: {
-              table: 'tbl',
-              database: 'db'
-            }
+            lowerCase: false
           }
         });
       });
 
-      it('should handle DESCRIBE DATABASE db', function() {
+      it('should handle "DESCRIBE SCHEMA db;|"', function() {
         assertAutoComplete({
-          beforeCursor: 'DESCRIBE DATABASE db;',
+          beforeCursor: 'DESCRIBE SCHEMA db;',
           afterCursor: '',
           dialect: 'hive',
           containsKeywords: ['SELECT'],
@@ -171,9 +164,9 @@ define([
         });
       });
 
-      it('should handle DESCRIBE DATABASE EXTENDED db', function() {
+      it('should handle "DESCRIBE SCHEMA EXTENDED db;|"', function() {
         assertAutoComplete({
-          beforeCursor: 'DESCRIBE DATABASE EXTENDED db;',
+          beforeCursor: 'DESCRIBE SCHEMA EXTENDED db;',
           afterCursor: '',
           dialect: 'hive',
           containsKeywords: ['SELECT'],
@@ -183,31 +176,86 @@ define([
         });
       });
 
-      it('should handle DESCRIBE SCHEMA db', function() {
+      it('should suggest tables for "DESCRIBE |"', function() {
         assertAutoComplete({
-          beforeCursor: 'DESCRIBE SCHEMA db;',
+          beforeCursor: 'DESCRIBE ',
           afterCursor: '',
           dialect: 'hive',
-          containsKeywords: ['SELECT'],
           expectedResult: {
-            lowerCase: false
+            lowerCase: false,
+            suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED', 'FUNCTION', 'SCHEMA'],
+            suggestTables: {},
+            suggestDatabases: { appendDot: true }
           }
         });
       });
 
-      it('should handle DESCRIBE SCHEMA EXTENDED db', function() {
+      it('should suggest tables for "DESCRIBE tbl|"', function() {
         assertAutoComplete({
-          beforeCursor: 'DESCRIBE SCHEMA EXTENDED db;',
+          beforeCursor: 'DESCRIBE tbl',
           afterCursor: '',
           dialect: 'hive',
-          containsKeywords: ['SELECT'],
           expectedResult: {
-            lowerCase: false
+            lowerCase: false,
+            suggestKeywords: ['DATABASE', 'EXTENDED', 'FORMATTED', 'FUNCTION', 'SCHEMA'],
+            suggestTables: {},
+            suggestDatabases: { appendDot: true }
+          }
+        });
+      });
+
+      it('should suggest tables for "DESCRIBE db.|"', function() {
+        assertAutoComplete({
+          beforeCursor: 'DESCRIBE db.',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestTables: { database: 'db' }
+          }
+        });
+      });
+
+      it('should suggest columns for "DESCRIBE db.tbl |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'DESCRIBE db.tbl ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestColumns: {
+              table: 'tbl',
+              database: 'db'
+            }
+          }
+        });
+      });
+
+      it('should suggest keywords for "DESCRIBE FUNCTION |"', function() {
+        assertAutoComplete({
+          beforeCursor: 'DESCRIBE FUNCTION ',
+          afterCursor: '',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['EXTENDED']
           }
         });
       });
 
-      it('should suggest keywords and databases after DESCRIBE DATABASE', function() {
+      it('should suggest keywords for "DESCRIBE FUNCTION | cos"', function() {
+        assertAutoComplete({
+          beforeCursor: 'DESCRIBE FUNCTION ',
+          afterCursor: ' cos',
+          dialect: 'hive',
+          expectedResult: {
+            lowerCase: false,
+            suggestKeywords: ['EXTENDED']
+          }
+        });
+      });
+
+      it('should suggest databases for "DESCRIBE DATABASE |"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE DATABASE ',
           afterCursor: '',
@@ -220,7 +268,7 @@ define([
         });
       });
 
-      it('should suggest keywords and databases after DESCRIBE DATABASE partial', function() {
+      it('should suggest databases for "DESCRIBE DATABASE db|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE DATABASE db',
           afterCursor: '',
@@ -233,7 +281,7 @@ define([
         });
       });
 
-      it('should suggest databases after DESCRIBE DATABASE EXTENDED', function() {
+      it('should suggest databases for "DESCRIBE DATABASE EXTENDED |"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE DATABASE EXTENDED ',
           afterCursor: '',
@@ -245,7 +293,7 @@ define([
         });
       });
 
-      it('should suggest keyworda and databases after DESCRIBE SCHEMA', function() {
+      it('should suggest databases for "DESCRIBE SCHEMA |"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE SCHEMA ',
           afterCursor: '',
@@ -258,7 +306,7 @@ define([
         });
       });
 
-      it('should suggest keywords and databases after DESCRIBE SCHEMA partial', function() {
+      it('should suggest databases for "DESCRIBE SCHEMA db|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE SCHEMA db',
           afterCursor: '',
@@ -271,7 +319,7 @@ define([
         });
       });
 
-      it('should suggest databases after DESCRIBE SCHEMA EXTENDED', function() {
+      it('should suggest databases for "DESCRIBE SCHEMA EXTENDED |"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE SCHEMA EXTENDED ',
           afterCursor: '',
@@ -283,7 +331,7 @@ define([
         });
       });
 
-      it('should suggest tables after DESCRIBE EXTENDED', function() {
+      it('should suggest tables for "DESCRIBE EXTENDED |"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE EXTENDED ',
           afterCursor: '',
@@ -296,19 +344,19 @@ define([
         });
       });
 
-      it('should suggest tables after DESCRIBE EXTENDED db.', function() {
+      it('should suggest tables for "describe extended db.|"', function() {
         assertAutoComplete({
-          beforeCursor: 'DESCRIBE EXTENDED db.',
+          beforeCursor: 'describe extended db.',
           afterCursor: '',
           dialect: 'hive',
           expectedResult: {
-            lowerCase: false,
+            lowerCase: true,
             suggestTables: { database: 'db' }
           }
         });
       });
 
-      it('should suggest columns after DESCRIBE EXTENDED db.tbl', function() {
+      it('should suggest columns for "DESCRIBE EXTENDED db.tbl |"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE EXTENDED db.tbl ',
           afterCursor: '',
@@ -323,7 +371,7 @@ define([
         });
       });
 
-      it('should suggest tables after DESCRIBE FORMATTED', function() {
+      it('should suggest tables for "DESCRIBE FORMATTED |"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE FORMATTED ',
           afterCursor: '',
@@ -336,7 +384,7 @@ define([
         });
       });
 
-      it('should suggest tables after DESCRIBE FORMATTED db.', function() {
+      it('should suggest tables for "DESCRIBE FORMATTED db.|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE FORMATTED db.',
           afterCursor: '',
@@ -350,7 +398,7 @@ define([
         });
       });
 
-      it('should suggest columns after DESCRIBE FORMATTED db.tbl', function() {
+      it('should suggest columns for "DESCRIBE FORMATTED db.tbl |"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE FORMATTED db.tbl ',
           afterCursor: '',
@@ -365,7 +413,7 @@ define([
         });
       });
 
-      it('should suggest fields after DESCRIBE FORMATTED db.tbl col.', function() {
+      it('should suggest fields for "DESCRIBE FORMATTED db.tbl col.|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE FORMATTED db.tbl col.',
           afterCursor: '',
@@ -383,7 +431,7 @@ define([
     });
 
     describe('impala specific', function () {
-      it('should handle DESCRIBE tbl', function() {
+      it('should handle "DESCRIBE tbl;|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE tbl;',
           afterCursor: '',
@@ -395,7 +443,7 @@ define([
         });
       });
 
-      it('should handle DESCRIBE db.tbl', function() {
+      it('should handle "DESCRIBE db.tbl;|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE db.tbl;',
           afterCursor: '',
@@ -407,7 +455,7 @@ define([
         });
       });
 
-      it('should handle DESCRIBE FORMATTED db.tbl', function() {
+      it('should handle "DESCRIBE FORMATTED db.tbl;|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE FORMATTED db.tbl;',
           afterCursor: '',
@@ -419,7 +467,7 @@ define([
         });
       });
 
-      it('should suggest tables and keywords after DESCRIBE', function() {
+      it('should suggest tables for "DESCRIBE |"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE ',
           afterCursor: '',
@@ -435,7 +483,7 @@ define([
         });
       });
 
-      it('should suggest tables and keywords after DESCRIBE partial', function() {
+      it('should suggest tables for "DESCRIBE db|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE db',
           afterCursor: '',
@@ -451,7 +499,7 @@ define([
         });
       });
 
-      it('should suggest tables after DESCRIBE db.', function() {
+      it('should suggest tables for "DESCRIBE db.|"', function() {
         assertAutoComplete({
           beforeCursor: 'DESCRIBE db.',
           afterCursor: '',

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

@@ -30,7 +30,7 @@ define([
 
     var assertAutoComplete = testUtils.assertAutocomplete;
 
-    it('should suggest keywords for empty statement', function() {
+    it('should suggest keywords for "|"', function() {
       assertAutoComplete({
         beforeCursor: '',
         afterCursor: '',
@@ -41,7 +41,7 @@ define([
       });
     });
 
-    it('should suggest keywords after DROP', function() {
+    it('should suggest keywords for "DROP |"', function() {
       assertAutoComplete({
         beforeCursor: 'DROP ',
         afterCursor: '',
@@ -54,7 +54,7 @@ define([
     });
 
     describe('hive specific', function () {
-      it('should suggest keywords after DROP', function() {
+      it('should suggest keywords for "DROP |"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP ',
           afterCursor: '',
@@ -68,7 +68,7 @@ define([
     });
 
     describe('hive specific', function () {
-      it('should follow case after drop', function() {
+      it('should follow case for "drop |"', function() {
         assertAutoComplete({
           beforeCursor: 'drop ',
           afterCursor: '',
@@ -82,7 +82,7 @@ define([
     });
 
     describe('impala specific', function () {
-      it('should suggest keywords after DROP', function() {
+      it('should suggest keywords for "DROP |"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP ',
           afterCursor: '',
@@ -96,7 +96,7 @@ define([
     });
 
     describe('drop database statements', function () {
-      it('should suggest databases after DROP DATABASE ', function() {
+      it('should suggest databases for "DROP DATABASE |"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP DATABASE ',
           afterCursor: '',
@@ -109,7 +109,7 @@ define([
         });
       });
 
-      it('should suggest databases after DROP SCHEMA ', function() {
+      it('should suggest databases for "DROP SCHEMA |"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP SCHEMA ',
           afterCursor: '',
@@ -121,7 +121,7 @@ define([
         });
       });
 
-      it('should suggest keywords after DROP DATABASE IF ', function() {
+      it('should suggest keywords for "DROP DATABASE IF |"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP DATABASE IF ',
           afterCursor: '',
@@ -133,7 +133,7 @@ define([
         });
       });
 
-      it('should suggest databases after DROP DATABASE IF EXISTS ', function() {
+      it('should suggest databases for "DROP DATABASE IF EXISTS |"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP DATABASE IF EXISTS ',
           afterCursor: '',
@@ -146,7 +146,7 @@ define([
       });
 
       describe('Hive specific', function () {
-        it('should suggest keywords after DROP DATABASE foo ', function() {
+        it('should suggest keywords for "DROP DATABASE foo |"', function() {
           assertAutoComplete({
             beforeCursor: 'DROP DATABASE foo ',
             afterCursor: '',
@@ -161,7 +161,7 @@ define([
     });
 
     describe('drop table statements', function () {
-      it('should suggest tables after DROP TABLE ', function() {
+      it('should suggest tables for "DROP TABLE |"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP TABLE ',
           afterCursor: '',
@@ -176,7 +176,7 @@ define([
         });
       });
 
-      it('should suggest tables after DROP TABLE db. ', function() {
+      it('should suggest tables for "DROP TABLE db.|"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP TABLE db.',
           afterCursor: '',
@@ -187,7 +187,7 @@ define([
         });
       });
 
-      it('should suggest keywords after DROP TABLE IF ', function() {
+      it('should suggest keywords for "DROP TABLE IF |"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP TABLE IF ',
           afterCursor: '',
@@ -198,7 +198,7 @@ define([
         });
       });
 
-      it('should suggest tables after DROP TABLE IF EXISTS ', function() {
+      it('should suggest tables for "DROP TABLE IF EXISTS |"', function() {
         assertAutoComplete({
           beforeCursor: 'DROP TABLE IF EXISTS ',
           afterCursor: '',
@@ -213,7 +213,7 @@ define([
       });
 
       describe('Hive specific', function () {
-        it('should suggest keywords after DROP TABLE foo ', function() {
+        it('should suggest keywords for "DROP TABLE foo |"', function() {
           assertAutoComplete({
             beforeCursor: 'DROP TABLE foo ',
             afterCursor: '',

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

@@ -31,7 +31,7 @@ define([
     var assertAutoComplete = testUtils.assertAutocomplete;
 
     describe('Impala specific', function () {
-      it('should suggest keywords for empty statement', function() {
+      it('should suggest keywords for "|"', function() {
         assertAutoComplete({
           beforeCursor: '',
           afterCursor: '',
@@ -43,7 +43,7 @@ define([
         });
       });
 
-      it ('should suggest keywords after LOAD', function () {
+      it('should suggest keywords for "LOAD |"', function () {
         assertAutoComplete({
           beforeCursor: 'LOAD ',
           afterCursor: '',
@@ -55,7 +55,7 @@ define([
         });
       });
 
-      it ('should suggest keywords after LOAD DATA', function () {
+      it('should suggest keywords for "LOAD DATA |"', function () {
         assertAutoComplete({
           beforeCursor: 'LOAD DATA ',
           afterCursor: '',
@@ -67,7 +67,7 @@ define([
         });
       });
 
-      it ('should suggest keywords after LOAD DATA hdfsPath', function () {
+      it('should suggest keywords for "LOAD DATA INPATH \'/some/path\' |"', function () {
         assertAutoComplete({
           beforeCursor: 'LOAD DATA INPATH \'/some/path\' ',
           afterCursor: '',
@@ -79,7 +79,7 @@ define([
         });
       });
 
-      it ('should suggest keywords after LOAD DATA hdfsPath INTO', function () {
+      it('should suggest keywords for "LOAD DATA INPATH \'some/path\' INTO |"', function () {
         assertAutoComplete({
           beforeCursor: 'LOAD DATA INPATH \'some/path\' INTO ',
           afterCursor: '',
@@ -93,7 +93,7 @@ define([
     });
 
     describe('Hive specific', function () {
-      it('should suggest keywords for empty statement', function () {
+      it('should suggest keywords for "|"', function () {
         assertAutoComplete({
           beforeCursor: '',
           afterCursor: '',
@@ -106,7 +106,7 @@ define([
       });
     });
 
-    it('should autocomplete hdfs paths in location references without initial /', function () {
+    it('should suggest hdfs paths for "LOAD DATA INPATH \'|\'"', function () {
       assertAutoComplete({
         beforeCursor: 'LOAD DATA INPATH \'',
         afterCursor: '\'',
@@ -118,7 +118,7 @@ define([
       });
     });
 
-    it('should autocomplete hdfs paths in location references from root', function () {
+    it('should suggest hdfs paths for "LOAD DATA INPATH \'/|\'"', function () {
       assertAutoComplete({
         beforeCursor: 'LOAD DATA INPATH \'/',
         afterCursor: '\'',
@@ -130,7 +130,7 @@ define([
       });
     });
 
-    it('should autocomplete hdfs paths and suggest trailing apostrophe if empty after cursor', function () {
+    it('should suggest hdfs paths for "LOAD DATA INPATH \'/|"', function () {
       assertAutoComplete({
         beforeCursor: 'LOAD DATA INPATH \'/',
         afterCursor: '',
@@ -142,7 +142,7 @@ define([
       });
     });
 
-    it('should autocomplete hdfs paths in location references from inside a path', function () {
+    it('should suggest hdfs paths for "LOAD DATA INPATH \'/|/bar\' INTO TABLE foo"', function () {
       assertAutoComplete({
         serverResponses: {},
         beforeCursor: 'LOAD DATA INPATH \'/',

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 613 - 50
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSelect.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 114 - 112
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecShow.js


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

@@ -30,7 +30,7 @@ define([
 
     var assertAutoComplete = testUtils.assertAutocomplete;
 
-    it('should suggest keywords for empty statement', function() {
+    it('should suggest keywords for "|"', function() {
       assertAutoComplete({
         beforeCursor: '',
         afterCursor: '',
@@ -41,7 +41,7 @@ define([
       });
     });
 
-    it('should suggest keywords after UPDATE TableReference ', function () {
+    it('should suggest keywords for "UPDATE bar  |"', function () {
       assertAutoComplete({
         beforeCursor: 'UPDATE bar  ',
         afterCursor: '',
@@ -52,7 +52,7 @@ define([
       });
     });
 
-    it('should suggest keywords after UPDATE TableReference SET SetClauseList ', function () {
+    it('should suggest keywords for "UPDATE bar SET id=1, foo=2 |"', function () {
       assertAutoComplete({
         beforeCursor: 'UPDATE bar SET id=1, foo=2 ',
         afterCursor: '',
@@ -63,7 +63,7 @@ define([
       });
     });
 
-    it('should suggest keywords after UPDATE TableReference SET identifier ', function () {
+    it('should suggest keywords for "UPDATE bar SET id |"', function () {
       assertAutoComplete({
         beforeCursor: 'UPDATE bar SET id ',
         afterCursor: '',
@@ -74,7 +74,7 @@ define([
       });
     });
 
-    it('should suggest tables after UPDATE', function() {
+    it('should suggest tables for "UPDATE |"', function() {
       assertAutoComplete({
         beforeCursor: 'UPDATE ',
         afterCursor: '',
@@ -88,7 +88,7 @@ define([
       });
     });
 
-    it('should suggest tables after UPDATE with partial table or schema ref', function() {
+    it('should suggest tables for "UPDATE bla|"', function() {
       assertAutoComplete({
         beforeCursor: 'UPDATE bla',
         afterCursor: '',
@@ -102,7 +102,7 @@ define([
       });
     });
 
-    it('should suggest tables after UPDATE with database', function() {
+    it('should suggest tables for "UPDATE bar.|"', function() {
       assertAutoComplete({
         beforeCursor: 'UPDATE bar.',
         afterCursor: '',
@@ -115,7 +115,7 @@ define([
       });
     });
 
-    it('should suggest tables after UPDATE with database and partial table', function() {
+    it('should suggest tables for "UPDATE bar.foo|"', function() {
       assertAutoComplete({
         beforeCursor: 'UPDATE bar.foo',
         afterCursor: '',
@@ -128,7 +128,7 @@ define([
       });
     });
 
-    it('should suggest columns after SET', function() {
+    it('should suggest columns for "UPDATE bar.foo SET |"', function() {
       assertAutoComplete({
         beforeCursor: 'UPDATE bar.foo SET ',
         afterCursor: '',
@@ -142,7 +142,7 @@ define([
       });
     });
 
-    it('should suggest columns after SET id = 1, bar = \'foo\', ', function() {
+    it('should suggest columns for "UPDATE bar.foo SET id = 1, bar = \'foo\', |"', function() {
       assertAutoComplete({
         beforeCursor: 'UPDATE bar.foo SET id = 1, bar = \'foo\', ',
         afterCursor: '',
@@ -156,7 +156,7 @@ define([
       });
     });
 
-    it('should suggest columns after SET bar = \'foo\' WHERE ', function() {
+    it('should suggest columns for "UPDATE bar.foo SET bar = \'foo\' WHERE |"', function() {
       assertAutoComplete({
         beforeCursor: 'UPDATE bar.foo SET bar = \'foo\' WHERE ',
         afterCursor: '',
@@ -172,7 +172,7 @@ define([
       });
     });
 
-    it('should suggest values after SET bar = \'foo\' WHERE id = ', function() {
+    it('should suggest values for "UPDATE bar.foo SET bar = \'foo\' WHERE id = |"', function() {
       assertAutoComplete({
         beforeCursor: 'UPDATE bar.foo SET bar = \'foo\' WHERE id = ',
         afterCursor: '',
@@ -189,7 +189,7 @@ define([
       });
     });
 
-    it('should suggest columns after SET bar = \'foo\' WHERE id = 1 AND ', function() {
+    it('should suggest columns for "UPDATE bar.foo SET bar = \'foo\' WHERE id = 1 AND |"', function() {
       assertAutoComplete({
         beforeCursor: 'UPDATE bar.foo SET bar = \'foo\' WHERE id = 1 AND ',
         afterCursor: '',

+ 7 - 7
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecUse.js

@@ -30,7 +30,7 @@ define([
 
     var assertAutoComplete = testUtils.assertAutocomplete;
 
-    it('should suggest keywords for empty statement', function() {
+    it('should suggest keywords for "|"', function() {
       assertAutoComplete({
         beforeCursor: '',
         afterCursor: '',
@@ -41,7 +41,7 @@ define([
       });
     });
 
-    it('should suggest databases after use', function () {
+    it('should suggest databases for "USE |"', function () {
       assertAutoComplete({
         serverResponses: {},
         beforeCursor: 'USE ',
@@ -53,7 +53,7 @@ define([
       });
     });
 
-    it('should suggest databases after use with started identifier', function () {
+    it('should suggest databases for "USE bla|"', function () {
       assertAutoComplete({
         serverResponses: {},
         beforeCursor: 'USE bla',
@@ -65,9 +65,9 @@ define([
       });
     });
 
-    it('should use a use statement before the cursor if present', function () {
+    it('should use a use statement for "USE database_two; \\nselect |"', function () {
       assertAutoComplete({
-        beforeCursor: 'USE database_two; \n\select ',
+        beforeCursor: 'USE database_two; \nselect ',
         afterCursor: '',
         expectedResult: {
           useDatabase: 'database_two',
@@ -88,7 +88,7 @@ define([
       });
     });
 
-    it('should use the last use statement before the cursor if multiple are present', function () {
+    it('should use the last use statement for "USE other_db; USE closest_db; \\n\\tSELECT |"', function () {
       assertAutoComplete({
         beforeCursor: 'USE other_db; USE closest_db; \n\tSELECT ',
         afterCursor: '',
@@ -111,7 +111,7 @@ define([
       });
     });
 
-    it('should use the use statement before the cursor if multiple are present after the cursor', function () {
+    it('should use the use statement for "USE other_db; USE closest_db; \\n\\tSELECT |; USE some_other_db;"', function () {
       assertAutoComplete({
         beforeCursor: 'USE other_db; USE closest_db; \n\tSELECT ',
         afterCursor: '; USE some_other_db;',

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio