Browse Source

HUE-6835 [autocomplete] Suggest the NULL keyword in value expressions

Johan Ahlen 8 years ago
parent
commit
5356309534

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

@@ -1071,7 +1071,7 @@
         assertAutoComplete({
         assertAutoComplete({
           beforeCursor: 'SELECT * FROM testTable WHERE ${some_variable} + 1 = ',
           beforeCursor: 'SELECT * FROM testTable WHERE ${some_variable} + 1 = ',
           afterCursor: '',
           afterCursor: '',
-          containsKeywords: ['CASE'],
+          containsKeywords: ['CASE', 'NULL'],
           expectedResult: {
           expectedResult: {
             lowerCase: false,
             lowerCase: false,
             suggestFunctions: { types: ['NUMBER']},
             suggestFunctions: { types: ['NUMBER']},
@@ -4744,7 +4744,7 @@
             lowerCase: false,
             lowerCase: false,
             suggestColumns: { source: 'where',  tables: [{ identifierChain: [{ name: 'testTable' }] }] },
             suggestColumns: { source: 'where',  tables: [{ identifierChain: [{ name: 'testTable' }] }] },
             suggestFunctions: {},
             suggestFunctions: {},
-            suggestKeywords: ['CASE', 'EXISTS', 'NOT'],
+            suggestKeywords: ['CASE', 'EXISTS', 'NOT', 'NULL'],
             suggestFilters: { tables: [{ identifierChain: [{ name: 'testTable' }] }] }
             suggestFilters: { tables: [{ identifierChain: [{ name: 'testTable' }] }] }
           }
           }
         });
         });
@@ -4758,7 +4758,7 @@
             lowerCase: false,
             lowerCase: false,
             suggestColumns: { source: 'where',  tables: [{ identifierChain: [{ name: 'testTable' }] }] },
             suggestColumns: { source: 'where',  tables: [{ identifierChain: [{ name: 'testTable' }] }] },
             suggestFunctions: {},
             suggestFunctions: {},
-            suggestKeywords: ['CASE', 'EXISTS', 'NOT'],
+            suggestKeywords: ['CASE', 'EXISTS', 'NOT', 'NULL'],
             suggestFilters: { tables: [{ identifierChain: [{ name: 'testTable' }] }] }
             suggestFilters: { tables: [{ identifierChain: [{ name: 'testTable' }] }] }
           }
           }
         });
         });
@@ -4772,7 +4772,7 @@
             lowerCase: false,
             lowerCase: false,
             suggestColumns: { source: 'where',  tables: [{ identifierChain: [{ name: 'testTable' }] }] },
             suggestColumns: { source: 'where',  tables: [{ identifierChain: [{ name: 'testTable' }] }] },
             suggestFunctions: {},
             suggestFunctions: {},
-            suggestKeywords: ['CASE', 'EXISTS', 'NOT'],
+            suggestKeywords: ['CASE', 'EXISTS', 'NOT', 'NULL'],
             suggestFilters: { tables: [{ identifierChain: [{ name: 'testTable' }] }] }
             suggestFilters: { tables: [{ identifierChain: [{ name: 'testTable' }] }] }
           }
           }
         });
         });
@@ -4786,7 +4786,7 @@
             lowerCase: false,
             lowerCase: false,
             suggestColumns: { source: 'where',  tables: [{ identifierChain: [{ name: 'testTable' }] }] },
             suggestColumns: { source: 'where',  tables: [{ identifierChain: [{ name: 'testTable' }] }] },
             suggestFunctions: {},
             suggestFunctions: {},
-            suggestKeywords: ['CASE', 'EXISTS', 'NOT'],
+            suggestKeywords: ['CASE', 'EXISTS', 'NOT', 'NULL'],
             suggestFilters: { tables: [{ identifierChain: [{ name: 'testTable' }] }] }
             suggestFilters: { tables: [{ identifierChain: [{ name: 'testTable' }] }] }
           }
           }
         });
         });

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

@@ -305,7 +305,7 @@ var SqlParseSupport = (function () {
       }
       }
       parser.suggestColumns();
       parser.suggestColumns();
       parser.suggestFunctions();
       parser.suggestFunctions();
-      var keywords = ['CASE'];
+      var keywords = ['CASE', 'NULL'];
       if (parser.isHive() || typeof oppositeValueExpression === 'undefined' || typeof operator === 'undefined') {
       if (parser.isHive() || typeof oppositeValueExpression === 'undefined' || typeof operator === 'undefined') {
         keywords = keywords.concat(['EXISTS', 'NOT']);
         keywords = keywords.concat(['EXISTS', 'NOT']);
       }
       }