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): avoid trying to return a resultset for DML queries with not resultset #24999

Merged
merged 2 commits into from
Aug 21, 2023

Conversation

Yuval-Moshe
Copy link
Contributor

SUMMARY

Unlike other db engines, the mssql one does not include a check to see if there is even a need to return a result set before trying to fetch the data, that's why we are failing on a non select queries with the Statement not executed or executed statement has no resultset error.
In order to see if there is any result to try and fetch, we should check if the cursor description is not None.

Just for a reference we can see that other db engines like oracle or postgres do have that check before trying to fetch:
Oracle
https://github.com/apache/superset/blob/85a7d5cb3ebe833cfc2980f0846f15bb7ce1dd01/superset/db_engine_specs/postgres.py#L176C1-L179

Postgres
https://github.com/apache/superset/blob/85a7d5cb3ebe833cfc2980f0846f15bb7ce1dd01/superset/db_engine_specs/postgres.py#L176C1-L179

The result is failure in running a DML queries due to 'mssql error: Statement not executed or executed statement has no resultset'

So the fix is simply to add that check before calling the inherited fetch_data method.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

256207004-7bda88ad-7d0e-475b-8b0a-f7b441aade0f

TESTING INSTRUCTIONS

Run a DML query via the SQL Lab on an mssql DB

ADDITIONAL INFORMATION

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.

@john-bodley
Copy link
Member

Thanks @Yuval-Moshe for the fix. Would you mind looking into why the unit tests are failing? Additionally adding a unit test for this would be greatly appreciated as it would help prevent future regressions if said logic changed.

…and added and additional test for no cursor description scenario
@Yuval-Moshe
Copy link
Contributor Author

Hi @john-bodley, sure no problem.
I've fixed the failing test be providing a mocked cursor instead of a None cursor, and added an additional unit test to test the no description scenario.

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

Thank you for the improvement @Yuval-Moshe!

@Yuval-Moshe
Copy link
Contributor Author

@michael-s-molina Sure no problem!
What else is needed for this PR to be merged? I see you approved the PR and all the checks passed successfully, are we pending for @betodealmeida to review also?

@michael-s-molina michael-s-molina merged commit 66eabc2 into apache:master Aug 21, 2023
29 checks passed
@michael-s-molina michael-s-molina added the v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch label Aug 21, 2023
@Yuval-Moshe
Copy link
Contributor Author

@michael-s-molina Thanks!
Can you tell when a new helm chart release will be pushed? or where I can track it?

@michael-s-molina
Copy link
Member

@michael-s-molina Thanks! Can you tell when a new helm chart release will be pushed? or where I can track it?

Helm files are maintained by @craig-rueda. I think a Helm release will be available once 3.0 is out.

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/S v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch 🍒 3.0.0 🍒 3.0.1 🍒 3.0.2 🍒 3.0.3 🍒 3.0.4 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants