You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ly...@apache.org on 2022/08/04 16:19:42 UTC

[superset] branch lyndsi/dataset-column-fix created (now 1c6c336963)

This is an automated email from the ASF dual-hosted git repository.

lyndsi pushed a change to branch lyndsi/dataset-column-fix
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 1c6c336963 debugging columns

This branch includes the following new commits:

     new 1c6c336963 debugging columns

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[superset] 01/01: debugging columns

Posted by ly...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lyndsi pushed a commit to branch lyndsi/dataset-column-fix
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 1c6c3369633e8494b32399c18a50844c1c93e756
Author: lyndsiWilliams <kc...@gmail.com>
AuthorDate: Wed Aug 3 22:38:27 2022 -0500

    debugging columns
---
 superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx | 1 +
 superset-frontend/src/SqlLab/components/SaveQuery/index.tsx        | 6 ++++--
 superset-frontend/src/SqlLab/components/SqlEditor/index.jsx        | 7 ++++++-
 superset-frontend/src/utils/datasourceUtils.js                     | 2 +-
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx b/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx
index 12922ef79d..0e83c1dbce 100644
--- a/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx
@@ -151,6 +151,7 @@ export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({
   openWindow = true,
   formData = {},
 }) => {
+  console.log('FINDME SaveDatasetModal', datasource);
   const defaultVizType = useSelector<SqlLabRootState, string>(
     state => state.common?.conf?.DEFAULT_VIZ_TYPE || 'table',
   );
diff --git a/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx b/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx
index 4f88d6c9a1..35e063f25b 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;
@@ -166,6 +167,7 @@ export default function SaveQuery({
     </Form>
   );
 
+  console.log('FINDME SaveQuery', query, queryPayload());
   return (
     <Styles className="SaveQuery">
       <SaveDatasetActionButton
@@ -177,7 +179,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..f066d3b983 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
+++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
@@ -663,6 +663,11 @@ class SqlEditor extends React.PureComponent {
       </Menu>
     );
 
+    const queryWithColumns = () => ({
+      ...qe,
+      columns: this.props.latestQuery?.results?.columns || [],
+    });
+    console.log('findme SqlEditor', qe, queryWithColumns());
     return (
       <StyledToolbar className="sql-toolbar" id="js-sql-toolbar">
         <div className="leftItems">
@@ -721,7 +726,7 @@ class SqlEditor extends React.PureComponent {
         <div className="rightItems">
           <span>
             <SaveQuery
-              query={qe}
+              query={queryWithColumns()}
               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,
 });