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(bigquery): get_catalog_names #23461

Merged
merged 4 commits into from
Apr 5, 2023
Merged

Conversation

betodealmeida
Copy link
Member

SUMMARY

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

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

I configured a BigQuery 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.bigquery import BigQueryEngineSpec
    from superset.models.core import Database

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

When ran, it produced the expected output:

['covid19-293320']

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

@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Merging #23461 (dee6b5d) into master (95db6c0) will increase coverage by 0.08%.
The diff coverage is 45.45%.

❗ Current head dee6b5d differs from pull request most recent head 4d09c1f. Consider uploading reports for the commit 4d09c1f to get more accurate results

@@            Coverage Diff             @@
##           master   #23461      +/-   ##
==========================================
+ Coverage   67.62%   67.70%   +0.08%     
==========================================
  Files        1914     1914              
  Lines       73987    74002      +15     
  Branches     8030     8030              
==========================================
+ Hits        50031    50106      +75     
+ Misses      21906    21846      -60     
  Partials     2050     2050              
Flag Coverage Δ
hive 52.75% <42.42%> (?)
mysql 78.48% <45.45%> (-0.01%) ⬇️
postgres 78.56% <45.45%> (-0.01%) ⬇️
presto 52.68% <42.42%> (+0.01%) ⬆️
python 82.40% <45.45%> (+0.17%) ⬆️
sqlite 77.06% <45.45%> (-0.01%) ⬇️
unit 52.64% <42.42%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
superset/db_engine_specs/bigquery.py 69.54% <45.45%> (-0.18%) ⬇️

... and 3 files with indirect coverage changes

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

@pull-request-size pull-request-size bot added size/L and removed size/M labels Mar 23, 2023
@betodealmeida betodealmeida force-pushed the bigquery_get_catalog_names branch 5 times, most recently from dc4c6e5 to 428f9e5 Compare March 23, 2023 19:22
Comment on lines -185 to -204
invalid_kwargs = [
{"name": "some_name"},
{"schema": "some_schema"},
{"con": "some_con"},
{"name": "some_name", "con": "some_con"},
{"name": "some_name", "schema": "some_schema"},
{"con": "some_con", "schema": "some_schema"},
]
# Test check for missing schema.
sys.modules["google.oauth2"] = mock.MagicMock()
for invalid_kwarg in invalid_kwargs:
self.assertRaisesRegex(
Exception,
"The table schema must be defined",
BigQueryEngineSpec.df_to_sql,
database=database,
table=Table(table="name"),
df=df,
to_sql_kwargs=invalid_kwarg,
)
Copy link
Member Author

Choose a reason for hiding this comment

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

This test made no sense, so I removed it.

"""
Return the BigQuery client associated with an engine.
"""
if not dependencies_installed:
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this is just catching a formerly uncaught exception, is that right?

Copy link
Member

Choose a reason for hiding this comment

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

nm, I see where it was caught before with the ImportError

@betodealmeida betodealmeida merged commit 7a1aa63 into master Apr 5, 2023
john-bodley pushed a commit to airbnb/superset-fork that referenced this pull request Apr 12, 2023
john-bodley pushed a commit to airbnb/superset-fork that referenced this pull request Apr 13, 2023
john-bodley pushed a commit to airbnb/superset-fork that referenced this pull request Apr 14, 2023
@mistercrunch mistercrunch added the 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels label Mar 13, 2024
@mistercrunch mistercrunch deleted the bigquery_get_catalog_names branch March 26, 2024 16:24
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/L 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants