Skip to content

fix(sqllab): save datasets with template parameters #33195

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ethan-l-geotab
Copy link

@ethan-l-geotab ethan-l-geotab commented Apr 21, 2025

SUMMARY

Looking to solve this: #25786.
Trying to allow for datasets with stuff in the parameters to save without having a fatal error.
All it does is add the template parameters at the creation (post) of the dataset

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

TAKEN FROM THE ISSUE:

  1. Go to the SQL lab and open a new query, select the default examples database
  2. Click on the three-dots menu and Parameters.
  3. Enter the following JSON to specify defaults values for Jinja templates (relevant doc )
    {
    "my_table": "persons"
    }
  4. Enter the following text as the query
    SELECT * FROM {{ my_table }}
    Observe that you can execute the query, the context you specified in the Parameters is correctly injected because the results appear as expected.
  5. Save the query as a dataset and it should save correctly instead of giving fatal error.

ADDITIONAL INFORMATION

Copy link

korbit-ai bot commented Apr 21, 2025

Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment /korbit-review.

Your admin can change your review schedule in the Korbit Console

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

@ethan-l-geotab ethan-l-geotab changed the title fix(sqllab): save datasets with jinja fix(sqllab): save datasets with template parameters Apr 21, 2025
@ethan-l-geotab ethan-l-geotab marked this pull request as ready for review April 21, 2025 18:49
@dosubot dosubot bot added the sqllab Namespace | Anything related to the SQL Lab label Apr 21, 2025
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

I've completed my review and didn't find any issues.

Files scanned
File Path Reviewed
superset-frontend/src/utils/datasourceUtils.js
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx
superset/datasets/schemas.py
superset-frontend/src/SqlLab/actions/sqlLab.js

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Copy link

codecov bot commented Apr 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.25%. Comparing base (8c94f9c) to head (7678f6f).
Report is 7 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #33195       +/-   ##
===========================================
+ Coverage        0   83.25%   +83.25%     
===========================================
  Files           0      553      +553     
  Lines           0    39924    +39924     
===========================================
+ Hits            0    33238    +33238     
- Misses          0     6686     +6686     
Flag Coverage Δ
hive 48.29% <100.00%> (?)
mysql 75.46% <100.00%> (?)
postgres 75.53% <100.00%> (?)
presto 52.76% <100.00%> (?)
python 83.25% <100.00%> (?)
sqlite 75.03% <100.00%> (?)
unit 61.32% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Vitor-Avila
Copy link
Contributor

Should this be behind a checkbox in the save dataset modal/dialog? I'm thinking if users setting a _filters config just to emulate dashboard filters might not want these to persist to the dataset 🤔 a checkbox that's disabled by default (to match previous behavior) and can be enabled if desired could help maintaining flexibility.

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

Successfully merging this pull request may close these issues.

2 participants