|
@@ -1445,7 +1445,7 @@ class AutocompleteResults {
|
|
|
const tableParts = table.split('.');
|
|
const tableParts = table.split('.');
|
|
|
if (!existingTables[tableParts[tableParts.length - 1]]) {
|
|
if (!existingTables[tableParts[tableParts.length - 1]]) {
|
|
|
tablesAdded = true;
|
|
tablesAdded = true;
|
|
|
- const identifier = self.convertNavOptQualifiedIdentifier(
|
|
|
|
|
|
|
+ const identifier = self.convertOptimizerQualifiedIdentifier(
|
|
|
table,
|
|
table,
|
|
|
suggestJoins.tables
|
|
suggestJoins.tables
|
|
|
);
|
|
);
|
|
@@ -1469,13 +1469,13 @@ class AutocompleteResults {
|
|
|
suggestionString += self.parseResult.lowerCase ? ' and ' : ' AND ';
|
|
suggestionString += self.parseResult.lowerCase ? ' and ' : ' AND ';
|
|
|
}
|
|
}
|
|
|
suggestionString +=
|
|
suggestionString +=
|
|
|
- self.convertNavOptQualifiedIdentifier(
|
|
|
|
|
|
|
+ self.convertOptimizerQualifiedIdentifier(
|
|
|
joinColPair.columns[0],
|
|
joinColPair.columns[0],
|
|
|
suggestJoins.tables,
|
|
suggestJoins.tables,
|
|
|
self.dialect()
|
|
self.dialect()
|
|
|
) +
|
|
) +
|
|
|
' = ' +
|
|
' = ' +
|
|
|
- self.convertNavOptQualifiedIdentifier(
|
|
|
|
|
|
|
+ self.convertOptimizerQualifiedIdentifier(
|
|
|
joinColPair.columns[1],
|
|
joinColPair.columns[1],
|
|
|
suggestJoins.tables,
|
|
suggestJoins.tables,
|
|
|
self.dialect()
|
|
self.dialect()
|
|
@@ -1555,12 +1555,12 @@ class AutocompleteResults {
|
|
|
suggestionString += self.parseResult.lowerCase ? ' and ' : ' AND ';
|
|
suggestionString += self.parseResult.lowerCase ? ' and ' : ' AND ';
|
|
|
}
|
|
}
|
|
|
suggestionString +=
|
|
suggestionString +=
|
|
|
- self.convertNavOptQualifiedIdentifier(
|
|
|
|
|
|
|
+ self.convertOptimizerQualifiedIdentifier(
|
|
|
joinColPair.columns[0],
|
|
joinColPair.columns[0],
|
|
|
suggestJoinConditions.tables
|
|
suggestJoinConditions.tables
|
|
|
) +
|
|
) +
|
|
|
' = ' +
|
|
' = ' +
|
|
|
- self.convertNavOptQualifiedIdentifier(
|
|
|
|
|
|
|
+ self.convertOptimizerQualifiedIdentifier(
|
|
|
joinColPair.columns[1],
|
|
joinColPair.columns[1],
|
|
|
suggestJoinConditions.tables
|
|
suggestJoinConditions.tables
|
|
|
);
|
|
);
|
|
@@ -1717,7 +1717,7 @@ class AutocompleteResults {
|
|
|
return aggregateFunctionsDeferred;
|
|
return aggregateFunctionsDeferred;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- handlePopularGroupByOrOrderBy(navOptAttribute, suggestSpec, deferred, columnsDeferred) {
|
|
|
|
|
|
|
+ handlePopularGroupByOrOrderBy(optimizerAttribute, suggestSpec, deferred, columnsDeferred) {
|
|
|
const self = this;
|
|
const self = this;
|
|
|
const paths = [];
|
|
const paths = [];
|
|
|
suggestSpec.tables.forEach(table => {
|
|
suggestSpec.tables.forEach(table => {
|
|
@@ -1737,7 +1737,7 @@ class AutocompleteResults {
|
|
|
self.cancellablePromises.push(
|
|
self.cancellablePromises.push(
|
|
|
dataCatalog
|
|
dataCatalog
|
|
|
.getCatalog(self.dialect())
|
|
.getCatalog(self.dialect())
|
|
|
- .loadNavOptPopularityForTables({
|
|
|
|
|
|
|
+ .loadOptimizerPopularityForTables({
|
|
|
namespace: self.snippet.namespace(),
|
|
namespace: self.snippet.namespace(),
|
|
|
compute: self.snippet.compute(),
|
|
compute: self.snippet.compute(),
|
|
|
paths: paths,
|
|
paths: paths,
|
|
@@ -1753,28 +1753,30 @@ class AutocompleteResults {
|
|
|
: '';
|
|
: '';
|
|
|
|
|
|
|
|
entries.forEach(entry => {
|
|
entries.forEach(entry => {
|
|
|
- if (entry.navOptPopularity[navOptAttribute]) {
|
|
|
|
|
- totalColumnCount += entry.navOptPopularity[navOptAttribute].columnCount;
|
|
|
|
|
|
|
+ if (entry.optimizerPopularity[optimizerAttribute]) {
|
|
|
|
|
+ totalColumnCount += entry.optimizerPopularity[optimizerAttribute].columnCount;
|
|
|
matchedEntries.push(entry);
|
|
matchedEntries.push(entry);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
if (totalColumnCount > 0) {
|
|
if (totalColumnCount > 0) {
|
|
|
const suggestions = [];
|
|
const suggestions = [];
|
|
|
matchedEntries.forEach(entry => {
|
|
matchedEntries.forEach(entry => {
|
|
|
- const filterValue = self.createNavOptIdentifierForColumn(
|
|
|
|
|
- entry.navOptPopularity[navOptAttribute],
|
|
|
|
|
|
|
+ const filterValue = self.createOptimizerIdentifierForColumn(
|
|
|
|
|
+ entry.optimizerPopularity[optimizerAttribute],
|
|
|
suggestSpec.tables
|
|
suggestSpec.tables
|
|
|
);
|
|
);
|
|
|
suggestions.push({
|
|
suggestions.push({
|
|
|
value: prefix + filterValue,
|
|
value: prefix + filterValue,
|
|
|
filterValue: filterValue,
|
|
filterValue: filterValue,
|
|
|
- meta: navOptAttribute === 'groupByColumn' ? META_I18n.groupBy : META_I18n.orderBy,
|
|
|
|
|
|
|
+ meta:
|
|
|
|
|
+ optimizerAttribute === 'groupByColumn' ? META_I18n.groupBy : META_I18n.orderBy,
|
|
|
category:
|
|
category:
|
|
|
- navOptAttribute === 'groupByColumn'
|
|
|
|
|
|
|
+ optimizerAttribute === 'groupByColumn'
|
|
|
? CATEGORIES.POPULAR_GROUP_BY
|
|
? CATEGORIES.POPULAR_GROUP_BY
|
|
|
: CATEGORIES.POPULAR_ORDER_BY,
|
|
: CATEGORIES.POPULAR_ORDER_BY,
|
|
|
weightAdjust: Math.round(
|
|
weightAdjust: Math.round(
|
|
|
- (100 * entry.navOptPopularity[navOptAttribute].columnCount) / totalColumnCount
|
|
|
|
|
|
|
+ (100 * entry.optimizerPopularity[optimizerAttribute].columnCount) /
|
|
|
|
|
+ totalColumnCount
|
|
|
),
|
|
),
|
|
|
popular: ko.observable(true),
|
|
popular: ko.observable(true),
|
|
|
hasCatalogEntry: false,
|
|
hasCatalogEntry: false,
|
|
@@ -1871,7 +1873,7 @@ class AutocompleteResults {
|
|
|
? suggestFilters.prefix.toLowerCase()
|
|
? suggestFilters.prefix.toLowerCase()
|
|
|
: suggestFilters.prefix) + ' '
|
|
: suggestFilters.prefix) + ' '
|
|
|
: '';
|
|
: '';
|
|
|
- compVal += self.createNavOptIdentifier(
|
|
|
|
|
|
|
+ compVal += self.createOptimizerIdentifier(
|
|
|
value.tableName,
|
|
value.tableName,
|
|
|
grp.columnName,
|
|
grp.columnName,
|
|
|
suggestFilters.tables
|
|
suggestFilters.tables
|
|
@@ -1945,14 +1947,14 @@ class AutocompleteResults {
|
|
|
.done(entry => {
|
|
.done(entry => {
|
|
|
self.cancellablePromises.push(
|
|
self.cancellablePromises.push(
|
|
|
entry
|
|
entry
|
|
|
- .loadNavOptPopularityForChildren({ silenceErrors: true, cancellable: true })
|
|
|
|
|
|
|
+ .loadOptimizerPopularityForChildren({ silenceErrors: true, cancellable: true })
|
|
|
.done(childEntries => {
|
|
.done(childEntries => {
|
|
|
let totalPopularity = 0;
|
|
let totalPopularity = 0;
|
|
|
const popularityIndex = {};
|
|
const popularityIndex = {};
|
|
|
childEntries.forEach(childEntry => {
|
|
childEntries.forEach(childEntry => {
|
|
|
- if (childEntry.navOptPopularity && childEntry.navOptPopularity.popularity) {
|
|
|
|
|
|
|
+ if (childEntry.optimizerPopularity && childEntry.optimizerPopularity.popularity) {
|
|
|
popularityIndex[childEntry.name] = true;
|
|
popularityIndex[childEntry.name] = true;
|
|
|
- totalPopularity += childEntry.navOptPopularity.popularity;
|
|
|
|
|
|
|
+ totalPopularity += childEntry.optimizerPopularity.popularity;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
if (totalPopularity > 0 && Object.keys(popularityIndex).length) {
|
|
if (totalPopularity > 0 && Object.keys(popularityIndex).length) {
|
|
@@ -1961,7 +1963,8 @@ class AutocompleteResults {
|
|
|
tableSuggestions.forEach(suggestion => {
|
|
tableSuggestions.forEach(suggestion => {
|
|
|
if (popularityIndex[suggestion.details.name]) {
|
|
if (popularityIndex[suggestion.details.name]) {
|
|
|
suggestion.relativePopularity = Math.round(
|
|
suggestion.relativePopularity = Math.round(
|
|
|
- (100 * suggestion.details.navOptPopularity.popularity) / totalPopularity
|
|
|
|
|
|
|
+ (100 * suggestion.details.optimizerPopularity.popularity) /
|
|
|
|
|
+ totalPopularity
|
|
|
);
|
|
);
|
|
|
if (suggestion.relativePopularity >= 5) {
|
|
if (suggestion.relativePopularity >= 5) {
|
|
|
suggestion.popular(true);
|
|
suggestion.popular(true);
|
|
@@ -2023,7 +2026,7 @@ class AutocompleteResults {
|
|
|
self.cancellablePromises.push(
|
|
self.cancellablePromises.push(
|
|
|
dataCatalog
|
|
dataCatalog
|
|
|
.getCatalog(self.dialect())
|
|
.getCatalog(self.dialect())
|
|
|
- .loadNavOptPopularityForTables({
|
|
|
|
|
|
|
+ .loadOptimizerPopularityForTables({
|
|
|
namespace: self.snippet.namespace(),
|
|
namespace: self.snippet.namespace(),
|
|
|
compute: self.snippet.compute(),
|
|
compute: self.snippet.compute(),
|
|
|
paths: paths,
|
|
paths: paths,
|
|
@@ -2046,7 +2049,10 @@ class AutocompleteResults {
|
|
|
const popularityIndex = {};
|
|
const popularityIndex = {};
|
|
|
|
|
|
|
|
popularEntries.forEach(popularEntry => {
|
|
popularEntries.forEach(popularEntry => {
|
|
|
- if (popularEntry.navOptPopularity && popularEntry.navOptPopularity[valueAttribute]) {
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ popularEntry.optimizerPopularity &&
|
|
|
|
|
+ popularEntry.optimizerPopularity[valueAttribute]
|
|
|
|
|
+ ) {
|
|
|
popularityIndex[popularEntry.getQualifiedPath()] = true;
|
|
popularityIndex[popularEntry.getQualifiedPath()] = true;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -2067,14 +2073,14 @@ class AutocompleteResults {
|
|
|
) {
|
|
) {
|
|
|
matchedSuggestions.push(suggestion);
|
|
matchedSuggestions.push(suggestion);
|
|
|
totalColumnCount +=
|
|
totalColumnCount +=
|
|
|
- suggestion.details.navOptPopularity[valueAttribute].columnCount;
|
|
|
|
|
|
|
+ suggestion.details.optimizerPopularity[valueAttribute].columnCount;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
if (totalColumnCount > 0) {
|
|
if (totalColumnCount > 0) {
|
|
|
matchedSuggestions.forEach(matchedSuggestion => {
|
|
matchedSuggestions.forEach(matchedSuggestion => {
|
|
|
matchedSuggestion.relativePopularity = Math.round(
|
|
matchedSuggestion.relativePopularity = Math.round(
|
|
|
(100 *
|
|
(100 *
|
|
|
- matchedSuggestion.details.navOptPopularity[valueAttribute].columnCount) /
|
|
|
|
|
|
|
+ matchedSuggestion.details.optimizerPopularity[valueAttribute].columnCount) /
|
|
|
totalColumnCount
|
|
totalColumnCount
|
|
|
);
|
|
);
|
|
|
if (matchedSuggestion.relativePopularity >= 5) {
|
|
if (matchedSuggestion.relativePopularity >= 5) {
|
|
@@ -2094,9 +2100,9 @@ class AutocompleteResults {
|
|
|
return popularColumnsDeferred;
|
|
return popularColumnsDeferred;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- createNavOptIdentifier(navOptTableName, navOptColumnName, tables) {
|
|
|
|
|
|
|
+ createOptimizerIdentifier(optimizerTableName, optimizerColumnName, tables) {
|
|
|
const self = this;
|
|
const self = this;
|
|
|
- let path = navOptTableName + '.' + navOptColumnName.split('.').pop();
|
|
|
|
|
|
|
+ let path = optimizerTableName + '.' + optimizerColumnName.split('.').pop();
|
|
|
for (let i = 0; i < tables.length; i++) {
|
|
for (let i = 0; i < tables.length; i++) {
|
|
|
let tablePath = '';
|
|
let tablePath = '';
|
|
|
if (tables[i].identifierChain.length === 2) {
|
|
if (tables[i].identifierChain.length === 2) {
|
|
@@ -2119,38 +2125,40 @@ class AutocompleteResults {
|
|
|
return path;
|
|
return path;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- createNavOptIdentifierForColumn(navOptColumn, tables) {
|
|
|
|
|
|
|
+ createOptimizerIdentifierForColumn(optimizerColumn, tables) {
|
|
|
const self = this;
|
|
const self = this;
|
|
|
for (let i = 0; i < tables.length; i++) {
|
|
for (let i = 0; i < tables.length; i++) {
|
|
|
if (
|
|
if (
|
|
|
- navOptColumn.dbName &&
|
|
|
|
|
- (navOptColumn.dbName !== self.activeDatabase ||
|
|
|
|
|
- navOptColumn.dbName !== tables[i].identifierChain[0].name)
|
|
|
|
|
|
|
+ optimizerColumn.dbName &&
|
|
|
|
|
+ (optimizerColumn.dbName !== self.activeDatabase ||
|
|
|
|
|
+ optimizerColumn.dbName !== tables[i].identifierChain[0].name)
|
|
|
) {
|
|
) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
if (
|
|
if (
|
|
|
- navOptColumn.tableName &&
|
|
|
|
|
|
|
+ optimizerColumn.tableName &&
|
|
|
hueUtils.equalIgnoreCase(
|
|
hueUtils.equalIgnoreCase(
|
|
|
- navOptColumn.tableName,
|
|
|
|
|
|
|
+ optimizerColumn.tableName,
|
|
|
tables[i].identifierChain[tables[i].identifierChain.length - 1].name
|
|
tables[i].identifierChain[tables[i].identifierChain.length - 1].name
|
|
|
) &&
|
|
) &&
|
|
|
tables[i].alias
|
|
tables[i].alias
|
|
|
) {
|
|
) {
|
|
|
- return tables[i].alias + '.' + navOptColumn.columnName;
|
|
|
|
|
|
|
+ return tables[i].alias + '.' + optimizerColumn.columnName;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (navOptColumn.dbName && navOptColumn.dbName !== self.activeDatabase) {
|
|
|
|
|
- return navOptColumn.dbName + '.' + navOptColumn.tableName + '.' + navOptColumn.columnName;
|
|
|
|
|
|
|
+ if (optimizerColumn.dbName && optimizerColumn.dbName !== self.activeDatabase) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ optimizerColumn.dbName + '.' + optimizerColumn.tableName + '.' + optimizerColumn.columnName
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
if (tables.length > 1) {
|
|
if (tables.length > 1) {
|
|
|
- return navOptColumn.tableName + '.' + navOptColumn.columnName;
|
|
|
|
|
|
|
+ return optimizerColumn.tableName + '.' + optimizerColumn.columnName;
|
|
|
}
|
|
}
|
|
|
- return navOptColumn.columnName;
|
|
|
|
|
|
|
+ return optimizerColumn.columnName;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- convertNavOptQualifiedIdentifier(qualifiedIdentifier, tables, type) {
|
|
|
|
|
|
|
+ convertOptimizerQualifiedIdentifier(qualifiedIdentifier, tables, type) {
|
|
|
const self = this;
|
|
const self = this;
|
|
|
const aliases = [];
|
|
const aliases = [];
|
|
|
let tablesHasDefaultDatabase = false;
|
|
let tablesHasDefaultDatabase = false;
|