-
Notifications
You must be signed in to change notification settings - Fork 73
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
Prod 2435: bq connection test #5138
Changes from all commits
d02d73c
08e3263
4e7a8b2
292da45
338f772
f694506
17f36df
591456b
16d65db
71f7613
7256029
2bd07b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -510,6 +510,29 @@ | |
"""Query wrapper corresponding to the input execution_node.""" | ||
return BigQueryQueryConfig(node) | ||
|
||
# Overrides SQLConnector.test_connection | ||
def test_connection(self) -> Optional[ConnectionTestStatus]: | ||
""" | ||
Overrides SQLConnector.test_connection with a BigQuery-specific connection test. | ||
|
||
The connection is tested using the native python client for BigQuery, since that is what's used | ||
by the detection and discovery workflows/codepaths. | ||
TODO: migrate the rest of this class, used for DSR execution, to also make use of the native bigquery client. | ||
""" | ||
try: | ||
bq_schema = BigQuerySchema(**self.configuration.secrets or {}) | ||
client = bq_schema.get_client() | ||
all_projects = [project for project in client.list_projects()] | ||
if all_projects: | ||
return ConnectionTestStatus.succeeded | ||
logger.error("No Bigquery Projects found with the provided credentials.") | ||
raise ConnectionException( | ||
"No Bigquery Projects found with the provided credentials." | ||
) | ||
except Exception as e: | ||
logger.exception(f"Error testing connection to remote BigQuery {str(e)}") | ||
raise ConnectionException(f"Connection error: {e}") | ||
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 is solid for the exception that's raised up (and hopefully gets to the UI?) in addition, it might be nice to log the exception here too, ideally with a full stack trace - since this endpoint is specifically for troubleshooting, giving as much error information as possible can be helpful. you can use 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. logger exception here: 16d65db#diff-15895ed412c26a8f5c097a7eddfa11273da29a8d999e7c342bdeb475224fff8aR537 I do see the exception in logs if I induce one |
||
|
||
def mask_data( | ||
self, | ||
node: ExecutionNode, | ||
|
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.
may be a question of preference, but i tend to put these sort of comments as proper method docstrings, and that plays nicely with many IDEs. i would note here that we're specifically testing with the native bigquery python client that's used for the d&d workflows, even though it is not yet used for the DSR workflows. something like 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.
docstring here: 16d65db#diff-15895ed412c26a8f5c097a7eddfa11273da29a8d999e7c342bdeb475224fff8aR516