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

feat(presto): get_catalog_names #23599

Merged
merged 1 commit into from
Apr 6, 2023
Merged

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Apr 5, 2023

SUMMARY

Implement get_catalog_names for Presto/Trino. This is needed to support catalog-level permissions, and also for #22862.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

I configured a Trino database and ran this script:

from superset.app import create_app

app = create_app()
with app.app_context():
    from superset import db
    from superset.db_engine_specs.presto import PrestoEngineSpec
    from superset.models.core import Database

    database = db.session.query(Database).first()
    with database.get_inspector_with_context() as inspector:
        print(PrestoEngineSpec.get_catalog_names(database, inspector))

When ran, it produced the expected output:

['jmx', 'memory', 'mysql', 'system', 'tpcds', 'tpch']  

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

@betodealmeida betodealmeida changed the title feat(presto) get_catalog_names feat(presto): get_catalog_names Apr 5, 2023
@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 5, 2023
@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Merging #23599 (9fda8fd) into master (56dcf25) will decrease coverage by 0.01%.
The diff coverage is 66.66%.

❗ Current head 9fda8fd differs from pull request most recent head 0105645. Consider uploading reports for the commit 0105645 to get more accurate results

@@            Coverage Diff             @@
##           master   #23599      +/-   ##
==========================================
- Coverage   67.72%   67.72%   -0.01%     
==========================================
  Files        1916     1916              
  Lines       74051    74054       +3     
  Branches     8040     8040              
==========================================
+ Hits        50153    50155       +2     
- Misses      21850    21851       +1     
  Partials     2048     2048              
Flag Coverage Δ
hive 52.75% <66.66%> (+<0.01%) ⬆️
mysql 78.49% <66.66%> (-0.01%) ⬇️
postgres 78.57% <66.66%> (-0.01%) ⬇️
presto 52.68% <66.66%> (+<0.01%) ⬆️
python 82.41% <66.66%> (-0.01%) ⬇️
sqlite 77.07% <66.66%> (-0.01%) ⬇️
unit 52.65% <66.66%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset/db_engine_specs/postgres.py 97.10% <ø> (ø)
superset/db_engine_specs/presto.py 87.91% <66.66%> (-0.14%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -310,7 +310,7 @@ def get_catalog_names(
SELECT datname FROM pg_database
WHERE datistemplate = false;
"""
).fetchall()

Choose a reason for hiding this comment

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

Curious about why this had to change?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Antonio-RiveroMartnez in this case it's redundant, the expression generator will implicitly call fetchall() here. Eg:

>>> from sqlalchemy import create_engine
>>> engine = create_engine("shillelagh://")
>>> url = "https://docs.google.com/spreadsheets/d/1LcWZMsdCl92g7nA-D6qGRqg1T5TiHyuKJUY1u9XAnsk/edit#gid=0"
>>> engine.execute(f'SELECT * FROM "{url}"').fetchall()
[('BR', 2), ('BR', 4), ('ZA', 7), ('CR', 11), ('CR', 11), ('FR', 100), ('AR', 42)]
>>> [row for row in engine.execute(f'SELECT * FROM "{url}"')]
[('BR', 2), ('BR', 4), ('ZA', 7), ('CR', 11), ('CR', 11), ('FR', 100), ('AR', 42)]

@betodealmeida betodealmeida merged commit e2e0ad5 into master Apr 6, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 2024
@mistercrunch mistercrunch deleted the presto_get_catalog_names branch March 26, 2024 17:59
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 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants