Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: Columns not passing properly from SQL Lab to Explore #20975

Merged
merged 3 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({
openWindow = true,
formData = {},
}) => {
console.log('FINDME SaveDatasetModal', datasource);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just debugging, it wasn't ready for review yet. I pushed up a "clean up" commit here.

const defaultVizType = useSelector<SqlLabRootState, string>(
state => state.common?.conf?.DEFAULT_VIZ_TYPE || 'table',
);
Expand Down
6 changes: 4 additions & 2 deletions superset-frontend/src/SqlLab/components/SaveQuery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -166,6 +167,7 @@ export default function SaveQuery({
</Form>
);

console.log('FINDME SaveQuery', query, queryPayload());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just debugging, it wasn't ready for review yet. I pushed up a "clean up" commit here.

return (
<Styles className="SaveQuery">
<SaveDatasetActionButton
Expand All @@ -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"
Expand Down
7 changes: 6 additions & 1 deletion superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just debugging, it wasn't ready for review yet. I pushed up a "clean up" commit here.

return (
<StyledToolbar className="sql-toolbar" id="js-sql-toolbar">
<div className="leftItems">
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/utils/datasourceUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});