hughhhh commented on a change in pull request #11755:
URL:
https://github.com/apache/incubator-superset/pull/11755#discussion_r529895019
##########
File path: superset-frontend/src/SqlLab/components/ResultSet.tsx
##########
@@ -166,14 +210,148 @@ export default class ResultSet extends
React.PureComponent<
}
}
+ handleOverwriteDatasetOption(data, option) {
+ this.setState({ datasetToOverwrite: option })
+ }
+
+ handleOverwriteDataset() {
+ const { sql, results } = this.props.query;
+ const { datasetToOverwrite } = this.state;
+
+ SupersetClient.put({
+ endpoint:
`api/v1/dataset/${datasetToOverwrite.dataSetId}?override_column=true`,
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ sql,
+ columns: results.selected_columns.map(d => ({column_name: d.name}))
+ }),
+ }).then(d => {
+ exploreChart({
+ datasource: `${datasetToOverwrite.dataSetId}__table`,
+ metrics: [],
+ groupby: [],
+ time_range: 'No filter',
+ viz_type: 'table',
+ all_columns: results.selected_columns.map(d => d.name),
+ row_limit: 1000,
+ });
+ })
+ .catch(() => {
+ this.props.actions.addDangerToast(
+ t('An error occurred overwriting dataset'),
+ );
+ });
+
+ this.setState({showSaveDatasetModal: false, overwriteDataSet: false})
+ }
+
+ handleSaveInDataset() {
+ // if user wants to overwrite a dataset we need to prompt them
+ if (this.state.saveDatasetRadioBtnState === OVERWRITE_DATASET_RADIO_STATE)
{
+ this.setState({ overwriteDataSet: true });
+ return;
+ }
+
+ const { schema, sql, dbId, templateParams } = this.props.query;
+ const selectedColumns = this.props.query?.results?.selected_columns || [];
+
+ if (this.state.ctasSave) {
+ // Create Table As flow for explore view
+ this.props.actions
+ .createCtasDatasource({
+ schema,
+ dbId,
+ templateParams,
+ datasourceName: this.state.newSaveDatasetName,
+ })
+ .then((data: { table_id: number }) => {
+ const formData = {
+ datasource: `${data.table_id}__table`,
+ metrics: ['count'],
+ groupby: [],
+ viz_type: 'table',
+ since: '100 years ago',
+ all_columns: [],
+ row_limit: 1000,
+ };
+ this.props.actions.addInfoToast(
+ t('Creating a data source and creating a new tab'),
+ );
+
+ // open new window for data visualization
+ exploreChart(formData);
+ })
+ .catch(() => {
+ this.props.actions.addDangerToast(t('An error occurred'));
Review comment:
when i put `err` as the param in the catch function in returns
undefined. I'll look into it more to help give users more context on the actual
error
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]