GoogleCloudPlatform / GoogleCloudPlatform/cloud-spanner-emulator

Emulator not supporting INSERT with ON CONFLICT DO NOTHING clause

Open
#358 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
334
Forks
77
Avg merge
8m
Merged PRs (30d)
2

Description

In our team we started using the new [INSERT with ON CONFLICT DO NOTHING clause](https://docs.cloud.google.com/spanner/docs/reference/standard-sql/dml-syntax#insert_with_on_conflict_do_nothing_examples) which works in our cloud spanner instances. Whereas when we attempted to use it in our tests and local development we observed following error.

```SQL Error [12]: UNIMPLEMENTED: com.google.api.gax.rpc.UnimplementedException: io.grpc.StatusRuntimeException: UNIMPLEMENTED: ON CONFLICT clause with empty conflict target in INSERT statement is not supported in Emulator```

Looks like the `ON CONFLICT` clause is not supported in emulator.

Sample DB schema and INSERT DMLs
```sql
CREATE TABLE test ( id INT64 NOT NULL, created_on TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP())) PRIMARY KEY (id);

INSERT INTO test (id, created_on) VALUES (1, CURRENT_TIMESTAMP());

INSERT INTO test (id, created_on) VALUES (1, CURRENT_TIMESTAMP()) ON CONFLICT DO NOTHING;
```

Dialect - GoogleSQL

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the provided CREATE TABLE and INSERT statements against the emulator, then trace the emulator's INSERT handling for the GoogleSQL dialect and its ON CONFLICT parsing or execution path. Done means the empty-target ON CONFLICT DO NOTHING statement succeeds in the emulator and preserves the existing row, matching the documented Cloud Spanner behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.