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: Trino - handle table not found in SQLLab #26355

Merged
merged 7 commits into from
Jan 11, 2024

Conversation

Khrol
Copy link
Contributor

@Khrol Khrol commented Dec 25, 2023

SUMMARY

SQLAlchemy doesn't strictly define what get_indexes method should do when table is not found.
Some dialects return the empty list while some of them raise NoSuchTableError.

When NoSuchTableError error is thrown, API returns 500 when non-existing table details are requested.
This PR fixes this issue and returns 404 in such cases.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Paste some non-existing table name in table name field and hit Enter:

Screenshot 2023-12-25 at 18 33 10

Expected: no 500 errors from the backend.

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

@Khrol Khrol changed the title Trino: handle table not found in SQLLab fix: Trino: handle table not found in SQLLab Dec 25, 2023
@Khrol Khrol changed the title fix: Trino: handle table not found in SQLLab fix: Trino - handle table not found in SQLLab Dec 25, 2023
Copy link

codecov bot commented Dec 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ea4e9a6) 69.16% compared to head (d7ff579) 69.16%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #26355   +/-   ##
=======================================
  Coverage   69.16%   69.16%           
=======================================
  Files        1948     1948           
  Lines       76054    76061    +7     
  Branches     8493     8493           
=======================================
+ Hits        52601    52608    +7     
  Misses      21273    21273           
  Partials     2180     2180           
Flag Coverage Δ
hive 53.68% <42.85%> (-0.01%) ⬇️
mysql 78.06% <42.85%> (-0.01%) ⬇️
postgres 78.16% <42.85%> (-0.01%) ⬇️
presto 53.63% <42.85%> (-0.01%) ⬇️
python 82.86% <100.00%> (+<0.01%) ⬆️
sqlite 77.75% <42.85%> (-0.01%) ⬇️
unit 55.87% <100.00%> (+0.01%) ⬆️

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.

@Khrol Khrol marked this pull request as ready for review December 25, 2023 16:41
@john-bodley
Copy link
Member

john-bodley commented Jan 2, 2024

Thanks @Khrol for the PR. It seems—as in this example—that the expected behavior for the extra_table_metadata() method is to return an empty dictionary if no indexes exist (assuming the underlying SQLAlchemy dialect returns an empty list as opposed to throwing a NoSuchTableError error.

From a consistency standpoint it seems like the preferred fix would be to augment the Database.get_indexes() method (or preferably the underlying engine spec get_indexes methods) to handle the NoSuchTableError error.

superset/db_engine_specs/trino.py Outdated Show resolved Hide resolved
tests/integration_tests/databases/api_tests.py Outdated Show resolved Hide resolved
@Khrol Khrol marked this pull request as draft January 10, 2024 14:24
@pull-request-size pull-request-size bot added size/M and removed size/S labels Jan 10, 2024
@Khrol Khrol marked this pull request as ready for review January 10, 2024 15:08
@Khrol Khrol requested a review from john-bodley January 10, 2024 15:08
Copy link
Member

@john-bodley john-bodley left a comment

Choose a reason for hiding this comment

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

LGTM

superset/db_engine_specs/trino.py Show resolved Hide resolved
@john-bodley john-bodley merged commit 3daa038 into apache:master Jan 11, 2024
33 checks passed
@michael-s-molina michael-s-molina added v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch labels Jan 11, 2024
@Khrol Khrol deleted the trino_table_not_found branch January 15, 2024 11:52
michael-s-molina pushed a commit that referenced this pull request Jan 18, 2024
Co-authored-by: John Bodley <4567245+john-bodley@users.noreply.github.com>
michael-s-molina pushed a commit that referenced this pull request Jan 18, 2024
Co-authored-by: John Bodley <4567245+john-bodley@users.noreply.github.com>
(cherry picked from commit 3daa038)
@mistercrunch mistercrunch added 🍒 3.0.4 🍒 3.1.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Mar 8, 2024
sfirke pushed a commit to sfirke/superset that referenced this pull request Mar 22, 2024
Co-authored-by: John Bodley <4567245+john-bodley@users.noreply.github.com>
vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 2024
Co-authored-by: John Bodley <4567245+john-bodley@users.noreply.github.com>
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 v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch 🍒 3.0.4 🍒 3.1.1 🍒 3.1.2 🍒 3.1.3 🚢 4.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants