GoogleCloudPlatform / cloud-spanner-emulator

An open source emulator for Cloud Spanner.
Apache License 2.0
276 stars 45 forks source link

ALTER INDEX not supported on emulator #129

Open naphatkrit opened 1 year ago

naphatkrit commented 1 year ago

Spanner DDL spec supports ALTER INDEX statements, such as, ALTER INDEX MyIndex DROP STORED COLUMN MyColumn;. Running this against the emulator results in an error:

spanner> ALTER INDEX MyIndex DROP STORED COLUMN MyColumn;
ERROR: rpc error: code = InvalidArgument desc = Error parsing Spanner DDL statement: ALTER INDEX MyIndex DROP STORED COLUMN MyColumn : Syntax error on line 1, column 7: Encountered 'INDEX' while parsing: alter_statement

Running this same DDL statement on a real spanner instance worked fine.

I am on emulator version 1.5.9.

ablx commented 1 year ago

Just came here for the same issue. My current workaround is to filter out alter statements, but this is not very useful in the long run.

ninaBraunger0007 commented 5 months ago

I have the same issue. Is there already a solution available?

shevisj commented 4 months ago

~I'm also running into the same issue. We depend on the emulator for integration testing so it looks like I'll just have to create a new index with the alterations and delete the old one later which is pretty inefficient. It would be really nice if the emulator aligned with the spec here. Related Spanner DDL docs for reference.~

Looks like support was added in https://github.com/GoogleCloudPlatform/cloud-spanner-emulator/releases/tag/v1.5.13 so might just need to upgrade!

ablx commented 4 months ago

Using 1.5.22 com.google.cloud.spanner.SpannerException: UNIMPLEMENTED: io.grpc.StatusRuntimeException: UNIMPLEMENTED: Cannot add NOT NULL column _index_data_table_<indexname>.<stored column name> to existing table _index_data_table<indexname>.

Edit: DROP STORED COLUMN works, adding does not.