-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Summary
I'm running PGAdapter alongside the Google Spanner Emulator in Docker and have connected using the PostgreSQL driver in JetBrains DataGrip. When I execute a query using thejsonb_build_object
function, I receive an error. Notably, the query works in Google Spanner Studio on GCP but fails in DataGrip (and similarly in DBeaver with the Google Spanner driver).
Environment
- PGAdapter: Running in Docker.
- Google Spanner Emulator: Running in Docker.
- Client Tools:
- JetBrains DataGrip (using PostgreSQL driver or Google Spanner Driver)
- DBeaver (using Google Spanner driver)
- Database Dialect: PostgreSQL (as set during database creation).
Steps to Reproduce
- Set Up the Google Spanner Emulator Container:
spanner-dev:
image: gcr.io/cloud-spanner-emulator/emulator:latest
container_name: spanner-dev
ports:
- "9010:9010"
- "9020:9020"
- Initialize the Emulator:
gcloud config configurations create emulator --no-activate || true
gcloud config configurations activate emulator
gcloud config set auth/disable_credentials true
gcloud config set project test-project
gcloud config set api_endpoint_overrides/spanner http://spanner-dev:9020/
gcloud spanner instances create local-instance \
--config=emulator-config \
--description="Local Instance" \
--nodes=1
gcloud spanner databases create local-database \
--instance=local-instance \
--database-dialect=POSTGRESQL
- Start PGAdapter:
Configure and run PGAdapter with the following Docker settings:
image: gcr.io/cloud-spanner-pg-adapter/pgadapter:latest
container_name: pga-adapter
ports:
- "5432:5432"
environment:
- SPANNER_EMULATOR_HOST=spanner-dev:9010
command: ["-p", "test-project", "-i", "local-instance", "-d", "local-database", "-x", "-r", "autoConfigEmulator=true", "-c", ""]
Note: Replace the empty string in the -c parameter with your credentials.
- Connect and Execute the Query:
Connect to the PostgreSQL data source in DataGrip or Connect to the Google Spanner data source in DataGrip or Connect to the Google Spanner connection in DBeaver
Run the following SQL query:
SELECT jsonb_build_object('title','Academy Dinosaur','length',86);
Error Details
The query returns the following error:
[P0001] ERROR: Unknown statement: SQL Error [3]: INVALID_ARGUMENT: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Unable to resolve argument type. Please consider adding an explicit cast - Statement: 'SELECT jsonb_build_object( 'title', 'Academy Dinosaur', 'length', 86 )'
Additional Notes
The error is observed when connecting with DataGrip (using the PostgreSQL driver) and DBeaver (using the Google Spanner driver).
The same query executes successfully in Google Spanner Studio in GCP.
Request for Assistance
Any insights or workarounds to resolve the issue with jsonb_build_object
when using PGAdapter with the Google Spanner Emulator would be greatly appreciated.