[frontend] Switch to using the sqlParserRepository for the local optimizer strategy
This greatly reduces the bundle size for editor other than Hive
@@ -18,23 +18,23 @@ import $ from 'jquery';
import BaseStrategy from './baseStrategy';
import dataCatalog from 'catalog/dataCatalog';
-import sqlAutocompleteParser from 'parse/sql/hive/hiveAutocompleteParser';
+import sqlParserRepository from 'parse/sql/sqlParserRepository';
import I18n from 'utils/i18n';
export default class LocalStrategy extends BaseStrategy {
analyzeRisk(options) {
const snippet = JSON.parse(options.snippetJson);
- // TODO: Get parser from repository, need to extract SqlFunctions dep first
- // to reduce size of main hue bundle
- // const parser = await sqlParserRepository.getAutocompleteParser(snippet.dialect);
+ const deferred = $.Deferred();
+ sqlParserRepository
+ .getAutocompleteParser(this.connector.dialect)
+ .then(sqlAutocompleteParser => {
const sqlParseResult = sqlAutocompleteParser.parseSql(snippet.statement + ' ', '');
const hasLimit = sqlParseResult.locations.some(
location => location.type === 'limitClause' && !location.missing
);
- const deferred = $.Deferred();
deferred.resolve({
status: 0,
message: '',
@@ -56,6 +56,8 @@ export default class LocalStrategy extends BaseStrategy {
noDDL: false
}
});
+ });
+
return deferred.promise();
}
