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: dataset_macro #23376

Merged
merged 2 commits into from
Mar 14, 2023
Merged

fix: dataset_macro #23376

merged 2 commits into from
Mar 14, 2023

Conversation

betodealmeida
Copy link
Member

SUMMARY

The dataset() macro in SQL Lab doesn't work correctly when the SQL mutator wraps the query in comments. For example, with the following mutator:

def mutator(sql: str) -> str:
    return f"-- begin\n{sql}\n-- end"   

When using the macro:

SELECT * FROM {{ dataset(1) }}

The generated SQL looks like this:

SELECT * FROM (-- begin
SELECT ...
-- end) AS dataset_1

Which strips out the ) AS dataset_1 part, rendering the query invalid since it now misses a closing parenthesis.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Mar 14, 2023

Codecov Report

Merging #23376 (6a77d80) into master (d2c1fb9) will increase coverage by 0.15%.
The diff coverage is 100.00%.

❗ Current head 6a77d80 differs from pull request most recent head 12fb4d5. Consider uploading reports for the commit 12fb4d5 to get more accurate results

@@            Coverage Diff             @@
##           master   #23376      +/-   ##
==========================================
+ Coverage   67.36%   67.52%   +0.15%     
==========================================
  Files        1907     1907              
  Lines       73447    73448       +1     
  Branches     7976     7976              
==========================================
+ Hits        49477    49593     +116     
+ Misses      21921    21806     -115     
  Partials     2049     2049              
Flag Coverage Δ
hive 52.76% <60.00%> (?)
mysql 78.43% <60.00%> (+<0.01%) ⬆️
postgres 78.49% <60.00%> (+<0.01%) ⬆️
presto 52.69% <60.00%> (?)
python 82.26% <100.00%> (+0.32%) ⬆️
sqlite 76.96% <60.00%> (+<0.01%) ⬆️
unit 52.45% <80.00%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
superset/connectors/sqla/models.py 89.56% <100.00%> (+1.27%) ⬆️
superset/jinja_context.py 90.74% <100.00%> (ø)

... and 6 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@betodealmeida betodealmeida merged commit 1874f9a into master Mar 14, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 2024
@mistercrunch mistercrunch deleted the fix_dataset_macro branch March 26, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants