Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
entry.analysisPromise = $.Deferred()
.resolve(entry.analysis)
.promise();
};
let removeTable = function() {}; // noop until actually added
const sourceIdentifier = generateEntryCacheId({
namespace: options.namespace,
path: []
});
if (!self.temporaryEntries[sourceIdentifier]) {
const sourceDeferred = $.Deferred();
self.temporaryEntries[sourceIdentifier] = sourceDeferred.promise();
const sourceEntry = new DataCatalogEntry({
isTemporary: true,
dataCatalog: self,
namespace: options.namespace,
compute: options.compute,
path: [],
definition: {
index: 0,
navOptLoaded: true,
type: 'source'
}
});
addEntryMeta(sourceEntry);
identifiersToClean.push(sourceIdentifier);
sourceEntry.childrenPromise = $.Deferred()
.resolve([])
.promise();
.catch(error => {
console.warn(error);
const entry = new DataCatalogEntry({
dataCatalog: self,
namespace: options.namespace,
compute: options.compute,
path: options.path,
definition: options.definition
});
if (!options.cachedOnly && options.definition) {
entry.saveLater();
}
deferred.resolve(entry);
});
}
.then(storeEntry => {
const definition = storeEntry ? storeEntry.definition : options.definition;
const entry = new DataCatalogEntry({
dataCatalog: self,
namespace: options.namespace,
compute: options.compute,
path: options.path,
definition: definition
});
if (storeEntry) {
mergeEntry(entry, storeEntry);
} else if (!options.cachedOnly && options.definition) {
entry.saveLater();
}
deferred.resolve(entry);
})
.catch(error => {
options.columns.forEach(column => {
const columnPath = path.concat(column.name);
const columnIdentifier = generateEntryCacheId({
namespace: options.namespace,
path: columnPath
});
const columnDeferred = $.Deferred();
self.temporaryEntries[columnIdentifier] = columnDeferred.promise();
identifiersToClean.push(columnIdentifier);
const columnEntry = new DataCatalogEntry({
isTemporary: true,
dataCatalog: self,
namespace: options.namespace,
compute: options.compute,
path: columnPath,
definition: {
comment: '',
index: index++,
name: column.name,
partitionKey: false,
type: column.type
}
});
columnEntry.sample = {
data: [],
$.Deferred()
.reject()
.promise()
);
}
if (self.entries[identifier]) {
return self.entries[identifier];
}
const deferred = $.Deferred();
self.entries[identifier] = deferred.promise();
if (!cacheEnabled) {
deferred
.resolve(
new DataCatalogEntry({
dataCatalog: self,
namespace: options.namespace,
compute: options.compute,
path: options.path,
definition: options.definition
})
)
.promise();
} else {
self.store
.getItem(identifier)
.then(storeEntry => {
const definition = storeEntry ? storeEntry.definition : options.definition;
const entry = new DataCatalogEntry({
dataCatalog: self,
namespace: options.namespace,
databaseEntry.getChildren().done(existingTemporaryTables => {
const tableIdentifier = generateEntryCacheId({
namespace: options.namespace,
path: path
});
self.temporaryEntries[tableIdentifier] = tableDeferred.promise();
identifiersToClean.push(tableIdentifier);
const tableEntry = new DataCatalogEntry({
isTemporary: true,
dataCatalog: self,
namespace: options.namespace,
compute: options.compute,
path: path,
definition: {
comment: '',
index: 0,
name: options.name,
navOptLoaded: true,
type: 'table'
}
});
existingTemporaryTables.push(tableEntry);
const indexToDelete = existingTemporaryTables.length - 1;
removeTable = function() {
sourceEntry.getChildren().done(existingTemporaryDatabases => {
const databaseIdentifier = generateEntryCacheId({
namespace: options.namespace,
path: ['default']
});
if (!self.temporaryEntries[databaseIdentifier]) {
const databaseDeferred = $.Deferred();
self.temporaryEntries[databaseIdentifier] = databaseDeferred.promise();
const databaseEntry = new DataCatalogEntry({
isTemporary: true,
dataCatalog: self,
namespace: options.namespace,
compute: options.compute,
path: ['default'],
definition: {
index: 0,
navOptLoaded: true,
type: 'database'
}
});
addEntryMeta(databaseEntry);
identifiersToClean.push(databaseIdentifier);
databaseEntry.childrenPromise = $.Deferred()
.resolve([])
.promise();