Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 1 commit into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions superset/assets/javascripts/SqlLab/actions.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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