Skip to content

Commit

Permalink
[sql lab] fix partitionned table has no partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed May 10, 2017
1 parent baebba1 commit b5f687d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
20 changes: 16 additions & 4 deletions superset/assets/javascripts/SqlLab/actions.js
Expand Up @@ -252,11 +252,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) => {
Expand All @@ -271,22 +272,33 @@ 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');
});

url = `/superset/extra_table_metadata/${query.dbId}/${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');
});
};
}
Expand Down
4 changes: 3 additions & 1 deletion superset/db_engine_specs.py
Expand Up @@ -540,7 +540,9 @@ def _partition_query(

@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):
Expand Down

0 comments on commit b5f687d

Please sign in to comment.