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

Query saved paramters #28601

Open
3 tasks done
Hammam94 opened this issue May 20, 2024 · 4 comments
Open
3 tasks done

Query saved paramters #28601

Hammam94 opened this issue May 20, 2024 · 4 comments
Labels
sqllab Namespace | Anything related to the SQL Lab

Comments

@Hammam94
Copy link

Bug description

I am a new user to superset and i am enabling templating to add parameters to the query in the sqlLab but i pass the query link to anyone it passed without the parameters
is there any way to save the parameter with the query as it is mandatory to save it with the query
even i try to save it in the description but the description doesn't appear on the UI

How to reproduce the bug

  1. go to sqlLab
  2. create query with paramters
  3. save the query
  4. open the export link
  5. you won't find the paramters

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Copy link

dosubot bot commented May 20, 2024

To address the issue of parameters not being included when sharing a query link in Apache Superset, especially when using templating in SQL Lab, it's important to understand the mechanisms Superset provides for sharing queries. There are two main methods to share queries with parameters:

  1. Sharing via KV Store: This method is available if the ShareQueriesViaKvStore feature flag is enabled. It allows sharing a query with parameters by generating a short URL. The query and its parameters (templateParams) are stored in a key-value store, and the shared link references this stored query.

  2. Sharing Saved Queries: When a query is saved, it can be shared using a direct link that includes the savedQueryId parameter. For this method, ensure the query is saved with all necessary parameters in the templateParams field. The shared link will allow recipients to access the query along with its parameters.

To ensure your parameters are included when sharing a query link:

  • Verify that the templateParams field is correctly populated before saving or sharing the query.
  • If using the KV Store method, ensure the ShareQueriesViaKvStore feature flag is enabled.
  • Confirm that your Superset version supports these features. If not, updating to the latest version or consulting the Superset documentation may be necessary.

These steps should help in sharing query links that include all necessary parameters, facilitating recipients to view and interact with the shared queries as intended. For more detailed implementation, you can refer to the source code in the superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx and the relevant migrations in the Superset GitHub repository.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@dosubot dosubot bot added the sqllab Namespace | Anything related to the SQL Lab label May 20, 2024
@Hammam94
Copy link
Author

For fruther information form the network
Screen Shot 2024-05-20 at 4 20 37 PM

You can see the template_params returns with null while when i saved it i checked the network and i can see the template_params has value

Copy link

dosubot bot commented May 20, 2024

To resolve the issue with template_params not being included when sharing a query link in Apache Superset, follow these targeted steps:

  1. Correctly Set Template Parameters: Ensure you're using the TemplateParamsEditor to input your template parameters as JSON. This ensures they're correctly set for Jinja templating in your SQL queries.

  2. Serialization and Retrieval: When saving or sharing a query, the templateParams must be serialized correctly and included in the URL. Upon opening a shared query link, Superset should deserialize these parameters and load them into the SQL Lab context. This process is crucial for the parameters to be recognized and used in the shared query.

  3. Database and Migration Check: Confirm that your Superset instance includes the migration adding a template_parameters column in the saved_query table. This column is essential for storing and retrieving template parameters in saved queries, ensuring they persist when sharing query links.

  4. Debugging and Testing: If the issue persists, debug by checking the URL generation to ensure templateParams are included, and verify that upon opening the link, parameters are correctly parsed and set into the application's state. Also, ensure your error handling logic is robust to catch and report any issues with template parameters.

By ensuring the correct setup and handling of template_params, you can improve the reliability of sharing query links with parameters in Apache Superset.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@Hammam94
Copy link
Author

Hammam94 commented May 21, 2024

i got this error when creating the link
There was an error with your request
and here is the network response
Screen Shot 2024-05-21 at 8 54 11 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sqllab Namespace | Anything related to the SQL Lab
Projects
None yet
Development

No branches or pull requests

1 participant