[sql lab] fix partitionned table has no partitions (#2740)

This commit is contained in:
Maxime Beauchemin 2017-05-11 08:23:43 -07:00 committed by GitHub
parent e5584440ce
commit 5dbfdefae8
2 changed files with 19 additions and 5 deletions

View File

@ -254,11 +254,12 @@ export function addTable(query, tableName, schemaName) {
queryEditorId: query.id,
schema: schemaName,
name: tableName,
};
dispatch(mergeTable(Object.assign({}, table, {
isMetadataLoading: true,
isExtraMetadataLoading: true,
expanded: false,
};
dispatch(mergeTable(table));
})));
let url = `/superset/table/${query.dbId}/${tableName}/${schemaName}/`;
$.get(url, (data) => {
@ -273,15 +274,19 @@ export function addTable(query, tableName, schemaName) {
ctas: false,
};
// Merge table to tables in state
table = Object.assign({}, table, data, {
const newTable = Object.assign({}, table, data, {
expanded: true,
isMetadataLoading: false,
});
dispatch(mergeTable(table, dataPreviewQuery));
dispatch(mergeTable(newTable, dataPreviewQuery));
// Run query to get preview data for table
dispatch(runQuery(dataPreviewQuery));
})
.fail(() => {
const newTable = Object.assign({}, table, {
isMetadataLoading: false,
});
dispatch(mergeTable(newTable));
notify.error('Error occurred while fetching table metadata');
});
@ -289,6 +294,13 @@ export function addTable(query, tableName, schemaName) {
$.get(url, (data) => {
table = Object.assign({}, table, data, { isExtraMetadataLoading: false });
dispatch(mergeTable(table));
})
.fail(() => {
const newTable = Object.assign({}, table, {
isExtraMetadataLoading: false,
});
dispatch(mergeTable(newTable));
notify.error('Error occurred while fetching table metadata');
});
};
}

View File

@ -540,7 +540,9 @@ class PrestoEngineSpec(BaseEngineSpec):
@classmethod
def _latest_partition_from_df(cls, df):
return df.to_records(index=False)[0][0]
recs = df.to_records(index=False)
if recs:
return recs[0][0]
@classmethod
def latest_partition(cls, table_name, schema, database, show_first=False):