Bläddra i källkod

HUE-7738 [editor] Remove unused suggestFunctions from SqlFunctions

Johan Ahlen 5 år sedan
förälder
incheckning
604e2eef57

+ 0 - 44
desktop/core/src/desktop/js/sql/sqlFunctions.js

@@ -4731,16 +4731,6 @@ const SqlFunctions = (function() {
     }
   };
 
-  const createDocHtml = function(funcDesc) {
-    let html =
-      '<div class="fn-details"><p><span class="fn-sig">' + funcDesc.signature + '</span></p>';
-    if (funcDesc.description) {
-      html += '<p>' + funcDesc.description.replace(/[<]/g, '&lt;').replace(/[>]/g, '&gt;') + '</p>';
-    }
-    html += '<div>';
-    return html;
-  };
-
   const stripPrecision = function(types) {
     const result = [];
     types.forEach(type => {
@@ -4849,39 +4839,6 @@ const SqlFunctions = (function() {
     return result;
   };
 
-  const suggestFunctions = function(
-    dialect,
-    returnTypes,
-    includeAggregate,
-    includeAnalytic,
-    completions,
-    weight
-  ) {
-    const functionsToSuggest = getFunctionsWithReturnTypes(
-      dialect,
-      returnTypes,
-      includeAggregate,
-      includeAnalytic
-    );
-    Object.keys(functionsToSuggest).forEach(name => {
-      completions.push({
-        value: name + '()',
-        meta: functionsToSuggest[name].returnTypes.join('|'),
-        weight:
-          returnTypes.filter(type => {
-            return (
-              functionsToSuggest[name].returnTypes.filter(otherType => {
-                return otherType === type;
-              }).length > 0
-            );
-          }).length > 0
-            ? weight + 1
-            : weight,
-        docHTML: createDocHtml(functionsToSuggest[name])
-      });
-    });
-  };
-
   const findFunction = function(dialect, functionName) {
     return (
       BIT_FUNCTIONS[dialect][functionName] ||
@@ -4941,7 +4898,6 @@ const SqlFunctions = (function() {
   };
 
   return {
-    suggestFunctions: suggestFunctions,
     getArgumentTypes: getArgumentTypes,
     CATEGORIZED_FUNCTIONS: CATEGORIZED_FUNCTIONS,
     getFunctionsWithReturnTypes: getFunctionsWithReturnTypes,

+ 0 - 73
desktop/core/src/desktop/js/sql/sqlFunctions.test.js

@@ -15,81 +15,8 @@
 // limitations under the License.
 
 import { SqlFunctions } from './sqlFunctions';
-import { matchesType } from 'sql/reference/typeUtils';
 
 describe('sqlFunctions.js', () => {
-  it('should suggest only BOOLEAN functions when return type is set to BOOLEAN for Hive', () => {
-    const completions = [];
-    SqlFunctions.suggestFunctions('hive', ['BOOLEAN'], undefined, undefined, completions);
-
-    expect(completions.length).not.toEqual(0);
-
-    const completionsWithCorrectType = completions.filter(completion => {
-      return (
-        completion.meta === 'BOOLEAN' ||
-        completion.meta === 'T' ||
-        completion.meta === 'ARRAY' ||
-        completion.meta === 'MAP' ||
-        completion.meta === 'STRUCT' ||
-        completion.meta === 'UNION' ||
-        completion.meta === 'table'
-      );
-    });
-
-    expect(completionsWithCorrectType.length).toEqual(completions.length);
-  });
-
-  it('should suggest only STRING functions when return type is set to STRING for Hive', () => {
-    const completions = [];
-    SqlFunctions.suggestFunctions('hive', ['STRING'], undefined, undefined, completions);
-
-    expect(completions.length).not.toEqual(0);
-
-    const completionsWithCorrectType = completions.filter(completion =>
-      matchesType('hive', ['STRING'], [completion.meta])
-    );
-
-    expect(completionsWithCorrectType.length).toEqual(completions.length);
-  });
-
-  it('should suggest only NUMBER functions when return type is set to NUMBER for Hive', () => {
-    const completions = [];
-    SqlFunctions.suggestFunctions('hive', ['NUMBER'], undefined, undefined, completions);
-
-    expect(completions.length).not.toEqual(0);
-
-    let atleastOneInt = false;
-    let atleastOneString = false;
-    const completionsWithCorrectType = completions.filter(completion => {
-      atleastOneInt = atleastOneInt || completion.meta === 'INT';
-      atleastOneString = atleastOneString || completion.meta === 'STRING';
-      return matchesType('hive', ['NUMBER'], [completion.meta]);
-    });
-
-    expect(atleastOneInt).toBeTruthy();
-    expect(atleastOneString).toBeTruthy();
-    expect(completionsWithCorrectType.length).toEqual(completions.length);
-  });
-
-  it('should suggest only NUMBER functions when return type is set to NUMBER for Impala', () => {
-    const completions = [];
-    SqlFunctions.suggestFunctions('impala', ['NUMBER'], undefined, undefined, completions);
-
-    expect(completions.length).not.toEqual(0);
-
-    let atleastOneInt = false;
-    let stringPresent = false;
-    const completionsWithCorrectType = completions.filter(completion => {
-      atleastOneInt = atleastOneInt || completion.meta === 'INT';
-      stringPresent = stringPresent || completion.meta === 'STRING';
-      return matchesType('hive', ['NUMBER'], [completion.meta]);
-    });
-
-    expect(atleastOneInt).toBeTruthy();
-    expect(stringPresent).toBeFalsy();
-    expect(completionsWithCorrectType.length).toEqual(completions.length);
-  });
-
   it('should give the expected argument types at a specific position', () => {
     expect(SqlFunctions.getArgumentTypes('hive', 'cos', 1)).toEqual(['DECIMAL', 'DOUBLE']);
     expect(SqlFunctions.getArgumentTypes('hive', 'cos', 2)).toEqual([]);