浏览代码

HUE-5268 [editor] Autocompleter should not suggest columns without tables

Johan Ahlen 9 年之前
父节点
当前提交
7d0aeca

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js

@@ -4404,7 +4404,7 @@ var prioritizeSuggestions = function () {
     var suggestColumns = parser.yy.result.suggestColumns;
     if (typeof suggestColumns.tables === 'undefined' || suggestColumns.tables.length === 0) {
       // Impala supports statements like SELECT * FROM tbl1, tbl2 WHERE db.tbl1.col = tbl2.bla
-      if (isImpala() && typeof suggestColumns.identifierChain !== 'undefined' && suggestColumns.identifierChain.length > 0) {
+      if (parser.yy.result.suggestColumns.linked && isImpala() && typeof suggestColumns.identifierChain !== 'undefined' && suggestColumns.identifierChain.length > 0) {
         if (suggestColumns.identifierChain.length === 1) {
           parser.yy.result.suggestTables = suggestColumns;
           delete parser.yy.result.suggestColumns

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/sql_support.js

@@ -400,7 +400,7 @@ var prioritizeSuggestions = function () {
     var suggestColumns = parser.yy.result.suggestColumns;
     if (typeof suggestColumns.tables === 'undefined' || suggestColumns.tables.length === 0) {
       // Impala supports statements like SELECT * FROM tbl1, tbl2 WHERE db.tbl1.col = tbl2.bla
-      if (isImpala() && typeof suggestColumns.identifierChain !== 'undefined' && suggestColumns.identifierChain.length > 0) {
+      if (parser.yy.result.suggestColumns.linked && isImpala() && typeof suggestColumns.identifierChain !== 'undefined' && suggestColumns.identifierChain.length > 0) {
         if (suggestColumns.identifierChain.length === 1) {
           parser.yy.result.suggestTables = suggestColumns;
           delete parser.yy.result.suggestColumns

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

@@ -71,6 +71,16 @@
       });
     });
 
+    it('should not suggest anything for "SELECT u.|"', function() {
+      assertAutoComplete({
+        beforeCursor: 'SELECT u.',
+        afterCursor: '',
+        expectedResult: {
+          lowerCase: false
+        }
+      });
+    });
+
     it('should suggest keywords for "SELECT foo, bar |"', function() {
       assertAutoComplete({
         beforeCursor: 'SELECT foo, bar ',