-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,48 +166,13 @@ def test_normalize_indexes(self): | |
) | ||
|
||
@mock.patch("superset.db_engine_specs.bigquery.BigQueryEngineSpec.get_engine") | ||
def test_df_to_sql(self, mock_get_engine): | ||
@mock.patch("superset.db_engine_specs.bigquery.pandas_gbq") | ||
@mock.patch("superset.db_engine_specs.bigquery.service_account") | ||
def test_df_to_sql(self, mock_service_account, mock_pandas_gbq, mock_get_engine): | ||
""" | ||
DB Eng Specs (bigquery): Test DataFrame to SQL contract | ||
""" | ||
# test missing google.oauth2 dependency | ||
sys.modules["pandas_gbq"] = mock.MagicMock() | ||
df = DataFrame() | ||
database = mock.MagicMock() | ||
with self.assertRaises(Exception): | ||
BigQueryEngineSpec.df_to_sql( | ||
database=database, | ||
table=Table(table="name", schema="schema"), | ||
df=df, | ||
to_sql_kwargs={}, | ||
) | ||
|
||
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, | ||
) | ||
Comment on lines
-185
to
-204
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test made no sense, so I removed it. |
||
|
||
import pandas_gbq | ||
from google.oauth2 import service_account | ||
|
||
pandas_gbq.to_gbq = mock.Mock() | ||
service_account.Credentials.from_service_account_info = mock.MagicMock( | ||
mock_service_account.Credentials.from_service_account_info = mock.MagicMock( | ||
return_value="account_info" | ||
) | ||
|
||
|
@@ -216,14 +181,16 @@ def test_df_to_sql(self, mock_get_engine): | |
"secrets" | ||
) | ||
|
||
df = DataFrame() | ||
database = mock.MagicMock() | ||
BigQueryEngineSpec.df_to_sql( | ||
database=database, | ||
table=Table(table="name", schema="schema"), | ||
df=df, | ||
to_sql_kwargs={"if_exists": "extra_key"}, | ||
) | ||
|
||
pandas_gbq.to_gbq.assert_called_with( | ||
mock_pandas_gbq.to_gbq.assert_called_with( | ||
df, | ||
project_id="google-host", | ||
destination_table="schema.name", | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It looks like this is just catching a formerly uncaught exception, is that right?
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.
nm, I see where it was caught before with the ImportError