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: status 500 thrown when creating a dataset due to invalid sql #27796

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

Conversation

jzhao62
Copy link

@jzhao62 jzhao62 commented Apr 1, 2024

SUMMARY

previously when a dataset is being created, supersetGenericDB error can be thrown at the db_engine layer if a sql statement is invalid

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

before

before.mp4

after

after.mp4

TESTING INSTRUCTIONS

  • enable sqllab in database configuration
  • open sqllab
  • type invalid sql
  • click save as dataset

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

@qleroy
Copy link
Contributor

qleroy commented Apr 1, 2024

Tested on my dev setup and confirm the Fatal error is turned into a Dataset could not be created. error.

This is also a first step towards resolving #25786.

@john-bodley
Copy link
Member

Thanks @jzhao62 for the PR. Would you mind also adding some unit tests to prevent potential future regressions?

@john-bodley john-bodley self-requested a review April 1, 2024 16:50
Copy link

codecov bot commented Apr 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.48%. Comparing base (76d897e) to head (3a661ab).
Report is 154 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #27796       +/-   ##
===========================================
+ Coverage   60.48%   83.48%   +22.99%     
===========================================
  Files        1931      521     -1410     
  Lines       76236    37488    -38748     
  Branches     8568        0     -8568     
===========================================
- Hits        46114    31297    -14817     
+ Misses      28017     6191    -21826     
+ Partials     2105        0     -2105     
Flag Coverage Δ
hive 49.09% <14.28%> (-0.08%) ⬇️
javascript ?
mysql 77.17% <100.00%> (?)
postgres 77.28% <100.00%> (?)
presto 53.64% <57.14%> (-0.16%) ⬇️
python 83.48% <100.00%> (+19.99%) ⬆️
sqlite 76.73% <100.00%> (?)
unit 58.93% <14.28%> (+1.31%) ⬆️

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.

@john-bodley
Copy link
Member

@jzhao62 for running tests locally try:

> python3.9 -m venv venv
> source venv/bin/activate
> tox -e py39 -- tests/unit_tests/<file>
> tox -e py39-sqlite -- tests/integration_tests/<file>

these instructions should be outlined in CONTRIBUTING.md. Also see here with regards to how to run specific test classes or methods.

@rusackas
Copy link
Member

Hey all,

Just wondering if there's any hope of getting this across the finish line, as it would close both an open Discussion and an open Issue.

@jzhao62
Copy link
Author

jzhao62 commented May 13, 2024

hey @rusackas, i somewhat get stuck in the testing phase, where i cannot pass the celery integration tests from machine, i will address the conflicts and continue work on this

@jzhao62
Copy link
Author

jzhao62 commented May 16, 2024

@rusackas just wondering can someone kick start the test workflows, i highly suspect that the majority of testcases should work fine, i am seeking some help in the slack regarding at running test at meantime,

@jzhao62
Copy link
Author

jzhao62 commented May 16, 2024

great, seems no regression is introduced, i will add unit test for coverage on these line and it is a go.

@rusackas
Copy link
Member

@jzhao62 fantastic, thanks for following through on this! 🙌

@jzhao62
Copy link
Author

jzhao62 commented May 18, 2024

@rusackas hi, i have added unit test for coverage and this PR should be ready to go. if anything else let me know

)
return column_description

except SupersetGenericDBErrorException as ex:
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? It seems like we're re-raising the previous error with the same error type.

except (
SQLAlchemyError,
DAOCreateFailedError,
SupersetGenericDBErrorException,
Copy link
Member

Choose a reason for hiding this comment

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

I suspect this line is actually what is relevant, i.e., the changes to superset/connectors.sqla/utils.py are not necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants