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(mssql): support cte in virtual tables #18567

Merged
merged 8 commits into from
Feb 10, 2022
Merged

fix(mssql): support cte in virtual tables #18567

merged 8 commits into from
Feb 10, 2022

Conversation

sujiplr
Copy link
Contributor

@sujiplr sujiplr commented Feb 3, 2022

SUMMARY

Superset was not allowing to run CTE based SQLs on MSSQL while creating virtual tables, because MSSQL is not supporting CTE in subquery. Always the CTE sql should be at the top. Hence added the fix to make the SQL to run as same as CTE, this feature can be used for all the databases. Added a new flag called "allows_cte_in_subquery" , if it's True, Superset will parse CTE as Subquery and run it else Superset will run the CTE as same as it is.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Feb-10-2022 13-21-58

TESTING INSTRUCTIONS

Added unit test case, unit test case can be run against mssql dbengine using below command
tox -e sqlite tests/unit_tests/db_engine_specs/test_mssql.py

@villebro villebro changed the title Database Engine CTE Query Parsing fix ( MSSQL ) #804 fix(mssql): support cte in virtual tables Feb 3, 2022
@villebro villebro changed the title fix(mssql): support cte in virtual tables [WIP] fix(mssql): support cte in virtual tables Feb 3, 2022
@villebro villebro changed the title [WIP] fix(mssql): support cte in virtual tables fix(mssql): support cte in virtual tables Feb 4, 2022
@pull-request-size pull-request-size bot added size/L and removed size/M labels Feb 4, 2022
@villebro villebro changed the title fix(mssql): support cte in virtual tables [WIP] fix(mssql): support cte in virtual tables Feb 4, 2022
@codecov
Copy link

codecov bot commented Feb 5, 2022

Codecov Report

Merging #18567 (6a47c7d) into master (2929bb1) will increase coverage by 0.00%.
The diff coverage is 96.96%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #18567   +/-   ##
=======================================
  Coverage   66.32%   66.33%           
=======================================
  Files        1592     1592           
  Lines       62569    62596   +27     
  Branches     6295     6295           
=======================================
+ Hits        41501    41525   +24     
- Misses      19416    19419    +3     
  Partials     1652     1652           
Flag Coverage Δ
hive 52.08% <60.60%> (-0.06%) ⬇️
mysql 81.25% <96.96%> (+<0.01%) ⬆️
postgres 81.30% <96.96%> (+<0.01%) ⬆️
presto 51.92% <60.60%> (-0.06%) ⬇️
python 81.74% <96.96%> (+<0.01%) ⬆️
sqlite 81.00% <96.96%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset/connectors/sqla/models.py 88.32% <94.11%> (-0.20%) ⬇️
superset/db_engine_specs/base.py 88.74% <100.00%> (+0.31%) ⬆️
superset/db_engine_specs/mssql.py 95.91% <100.00%> (+0.08%) ⬆️
superset/charts/schemas.py 99.34% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2929bb1...6a47c7d. Read the comment docs.

@villebro villebro changed the title [WIP] fix(mssql): support cte in virtual tables fix(mssql): support cte in virtual tables Feb 10, 2022
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for working on this, a huge improvement to support CTEs on databases that don't support nested CTEs!

@villebro villebro merged commit b8aef10 into apache:master Feb 10, 2022
@sujiplr
Copy link
Contributor Author

sujiplr commented Feb 15, 2022

Thank you @villebro for all the help you provided .

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.0 labels Mar 13, 2024
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/L 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants