-
Notifications
You must be signed in to change notification settings - Fork 77
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
SQLachemy error overriding #400
Conversation
I have added the Slack message link.
I'm doubtful Can we do something like : |
@neelasha23 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor
554d710
to
bdd7f71
Compare
Have added error handling for the postgres issue mentioned in Asana.
I'm checking if there are any other libraries |
We'll not find any library that correctly parses all kinds of SQL dialects; this seems the wrong approach. We might end up with too many false negatives, I believe it's better to look for errors raised by the db driver and show complementary information: either a clearer error message or a link to our docs to fix it. This issue needs better scoping: what errors do we want to catch, and what do we want to do? |
I was going through stackoverflow posts on SQL errors for different db drivers. There are many errors which are use-case specific , e.g., using SQLAlchemy or Sqlite python client / Errors coming up with specific technologies like Ruby. Most of these errors are not relevant for our scenario. Majority of the problem still seems to be syntax errors (which the was the starting point of this issue), but there doesn't seem to be any library out there which can detect precisely where the syntax error occurred. |
I assume 80% will be related to the main drivers, sqlalchemy, psycopg2, sqlite3 etc. What if we cover the basics with sqlglot and just see if people are using it? We won't be able to catch everything (like mentioned above), but covering a big portion is a good resolution. If the research does show that syntax errors are the main issue, let's tackle this one first. I think also out of the types of errors you wrote, a lot of the issues will fall into 1/2. It's always a missing comma, or typos (I think for 2 like Eduardo mentioned we'll need to give better feedback). |
I don't think we should rely on sqlglot as we've seen that the parser might make mistakes. we don't want to be in a position where we tell the user to "fix their query" when it's a perfectly valid SQL that will run just fine in the database. a better approach is to let the code run, and only if it fails, proceed with some clear error messages. |
Yeah, so we are not not going to parse query with sqlglot initially. There is a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 comments.
When ready, tag reviewer and mark as ready for review. |
9a76ef4
to
0d7816c
Compare
@tonykploomber Did you get a chance to review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LG
5e75fef
to
d87dba1
Compare
I think it looks OK. Do we know if it's a bad URL issue? If so, I would consider removing the original error from the driver since it may confuse the user (he ran
I agree |
No we are trying to connect to the engine and if it throws any exception we raise Any thoughts on point 3 here for syntax errors |
What if we change the order? Our error first, then the driver error, and then the reference to the Slack channel? |
Yeah, let's keep it for later then. Ok we can add this text so users know it the original driver error. |
Yes, I think it's good and makes the error message more informative. Distinguishing between the errors will allow us to do something like this in the future. 2023-05-09.13-19-47.mp4 |
To keep it consistent with the connection error, can we include it in the UsageError: {{Our message}} {{Suggestions}} {{Driver error}} {{slack and docs references}} |
Can me done. Let me refactor the code. |
503b3b0
to
1c15365
Compare
Yes that looks fine, please fix the conflict and we're good to go. |
Test Lint changelog util moved error_message sqlglot conflicts tests postgres Error changed import added detail in connection added detail in connection test fix Error msg modified More tests changelog merge conflicts Review cmts Exceptions usageerror Doc note changelog printing ploomber link printing ploomber link err msg changed Review comments Integration test Error msg postgres test runtimeerror Empty commit sqlalchemy version ci fix test ci fix test moved modify_exceptions skipping failing tests Disabled modify_exception fixed tests revert changes Revert xfail ipython usageerror comment comment Empty commit Fix removed skip win fix ipython removed setup changed exception drop table error msg sq brackets format fixed test Empty-Commit rebase func naming Revert xfail moved strings duckdb tests changelog File renamed Integration tests Lint Lint err msg assert Generic db Revert test revert space integration revert sqlparse added original msg tests original in connection tests modified test fix redundant str
Done |
Good to me |
@idomic |
@tonykploomber no go ahead. |
Describe your changes
Overriding sqlalchemy error handling for the case:
Issue number
Closes #229
Checklist before requesting a review
pkgmt format
📚 Documentation preview 📚: https://jupysql--400.org.readthedocs.build/en/400/