You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2022/08/04 18:59:56 UTC
[superset] branch master updated: fix: Columns not passing properly from SQL Lab to Explore (#20975)
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new d42cf4e4c9 fix: Columns not passing properly from SQL Lab to Explore (#20975)
d42cf4e4c9 is described below
commit d42cf4e4c92e44d8ae74993780ba22807979d9bd
Author: Lyndsi Kay Williams <55...@users.noreply.github.com>
AuthorDate: Thu Aug 4 13:59:50 2022 -0500
fix: Columns not passing properly from SQL Lab to Explore (#20975)
* debugging columns
* Clean up code
* Fix test
---
superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.jsx | 2 +-
superset-frontend/src/SqlLab/components/SaveQuery/index.tsx | 5 +++--
superset-frontend/src/SqlLab/components/SqlEditor/index.jsx | 5 ++++-
superset-frontend/src/utils/datasourceUtils.js | 2 +-
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.jsx b/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.jsx
index b7e1a32181..94b7e2780b 100644
--- a/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.jsx
+++ b/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.jsx
@@ -159,7 +159,7 @@ describe('SavedQuery', () => {
const closeBtn = screen.getByRole('button', { name: /close/i });
const saveDatasetHeader = screen.getByText(/save or overwrite dataset/i);
const saveRadio = screen.getByRole('radio', {
- name: /save as new untitled dataset/i,
+ name: /save as new untitled/i,
});
const saveLabel = screen.getByText(/save as new/i);
const saveTextbox = screen.getByRole('textbox');
diff --git a/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx b/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx
index 4f88d6c9a1..554514f4db 100644
--- a/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx
@@ -26,9 +26,10 @@ import { Form, FormItem } from 'src/components/Form';
import Modal from 'src/components/Modal';
import SaveDatasetActionButton from 'src/SqlLab/components/SaveDatasetActionButton';
import { SaveDatasetModal } from 'src/SqlLab/components/SaveDatasetModal';
+import { getDatasourceAsSaveableDataset } from 'src/utils/datasourceUtils';
interface SaveQueryProps {
- query: any;
+ query: QueryPayload;
defaultLabel: string;
onSave: (arg0: QueryPayload) => void;
onUpdate: (arg0: QueryPayload) => void;
@@ -177,7 +178,7 @@ export default function SaveQuery({
onHide={() => setShowSaveDatasetModal(false)}
buttonTextOnSave={t('Save & Explore')}
buttonTextOnOverwrite={t('Overwrite & Explore')}
- datasource={query}
+ datasource={getDatasourceAsSaveableDataset(query)}
/>
<Modal
className="save-query-modal"
diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
index 346e53fbdb..bdda237158 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
+++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
@@ -721,7 +721,10 @@ class SqlEditor extends React.PureComponent {
<div className="rightItems">
<span>
<SaveQuery
- query={qe}
+ query={{
+ ...qe,
+ columns: this.props.latestQuery?.results?.columns || [],
+ }}
defaultLabel={qe.name || qe.description}
onSave={this.saveQuery}
onUpdate={this.props.actions.updateSavedQuery}
diff --git a/superset-frontend/src/utils/datasourceUtils.js b/superset-frontend/src/utils/datasourceUtils.js
index edfc02ec29..1a5924b3e6 100644
--- a/superset-frontend/src/utils/datasourceUtils.js
+++ b/superset-frontend/src/utils/datasourceUtils.js
@@ -19,7 +19,7 @@
export const getDatasourceAsSaveableDataset = source => ({
columns: source.columns,
name: source?.datasource_name || source?.name || 'Untitled',
- dbId: source.database.id,
+ dbId: source?.database?.id || source?.dbId,
sql: source?.sql || '',
schema: source?.schema,
});