You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "wthorp (via GitHub)" <gi...@apache.org> on 2025/02/22 00:57:26 UTC
Re: [I] Implement a DB connector for Cloud Spanner [superset]
wthorp commented on issue #16055:
URL: https://github.com/apache/superset/issues/16055#issuecomment-2675895238
If anyone finds themselves here in the future, this shouldn't be too big of a lift. There's a SQLAlchemy project for Spanner, so its not hard to get things _almost_ working.
Add these package lines to docker/requirements-local.txt
```
sqlalchemy-spanner
google-cloud-spanner
```
Configure your GCP service account in docker/.env
```
GOOGLE_APPLICATION_CREDENTIALS=/app/gcp_creds.json
```
Include your GCP credentials in the Dockerfile
```
COPY --chown=superset:superset gcp_creds.json /app/gcp_creds.json
```
You should be able to add a database using the SQLAlchemy URI features with a format like
```
spanner+spanner:///projects/{project_id}/instances/{instance_id}/databases/{database_id}
```
This should correctly populate the Database and its Schemas, but not the Tables. SQL Lab works as well.
The Table listing issue is likely due to Spanner disallowing `information_schema` queries inside transactions.
It's trivial to make SQLAlchemy happy in test code, but I haven't had luck driving the Superset configs yet.
```
with engine.connect() as connection:
connection.execution_options(isolation_level="AUTOCOMMIT") # This is the fix
result = connection.execute(text("SELECT table_name FROM information_schema.tables WHERE table_catalog = ''"))
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org