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(sqllab): Add templateParams on kv store #22013

Merged
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
1 change: 1 addition & 0 deletions superset-frontend/src/SqlLab/actions/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,7 @@ export function popStoredQuery(urlId) {
schema: json.schema ? json.schema : null,
autorun: json.autorun ? json.autorun : false,
sql: json.sql ? json.sql : 'SELECT ...',
templateParams: json.templateParams,
}),
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const unsavedQueryEditor = {
schema: 'query_schema_updated',
sql: 'SELECT * FROM Updated Limit 100',
autorun: true,
templateParams: '{ "my_value": "foo" }',
Copy link
Member

Choose a reason for hiding this comment

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

@justinpark how are these template parameters actually leveraged in the test? It's not apparent to me.

Copy link
Member Author

@justinpark justinpark Nov 3, 2022

Choose a reason for hiding this comment

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

@john-bodley the following block verify that this extra templateParams payload is being passed through api.
(expected includes this extra parameter)

https://github.com/apache/superset/blob/09a7d01ea763e1335de9975240e0ba97d0bd22e1/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/ShareSqlLabQuery.test.tsx#L126-L130

};

const standardProviderWithUnsaved: React.FC = ({ children }) => (
Expand Down
16 changes: 11 additions & 5 deletions superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@ function ShareSqlLabQuery({
}: ShareSqlLabQueryPropTypes) {
const theme = useTheme();

const { dbId, name, schema, autorun, sql, remoteId } = useQueryEditor(
queryEditorId,
['dbId', 'name', 'schema', 'autorun', 'sql', 'remoteId'],
);
const { dbId, name, schema, autorun, sql, remoteId, templateParams } =
useQueryEditor(queryEditorId, [
'dbId',
'name',
'schema',
'autorun',
'sql',
'remoteId',
'templateParams',
]);

const getCopyUrlForKvStore = (callback: Function) => {
const sharedQuery = { dbId, name, schema, autorun, sql };
const sharedQuery = { dbId, name, schema, autorun, sql, templateParams };

return storeQuery(sharedQuery)
.then(shortUrl => {
Expand Down