betodealmeida commented on code in PR #40776:
URL: https://github.com/apache/superset/pull/40776#discussion_r3416583405
##########
superset/db_engine_specs/bigquery.py:
##########
@@ -742,9 +743,37 @@ def adjust_engine_params(
) -> tuple[URL, dict[str, Any]]:
if catalog:
uri = uri.set(host=catalog, database="")
+ if schema:
+ if not uri.host and uri.database:
+ # Triple-slash form (e.g., bigquery:///project): move the
project
+ # from database to host before setting the default dataset,
otherwise
+ # setting database would overwrite the project.
+ uri = uri.set(host=uri.database, database="")
+ # Setting database to schema enables the BigQuery default dataset
so
+ # unqualified table names resolve to schema.table_name.
+ uri = uri.set(database=schema)
Review Comment:
I think we could consolidate this logic to make it easier to follow,
something like:
```python
if not uri.host:
# Triple-slash form (eg, bigquery:///project)
default_catalog = uri.database
default_schema = None
else:
# bigquery://project, bigquery://project/, and bigquery://project/schema
default_catalog = uri.host
default_schema = uri.database or None # coerce to None if empty string
uri = uri.set(host=catalog or default_catalog, database=schema or
default_schema)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]