GoogleCloudPlatform / GoogleCloudPlatform/cloud-spanner-emulator

Unable to create generated timestamp column from protobuf timestamp

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

Description

I have the following protobuf schema:
```proto
package project.service;

message Parent {
Child child = 1;
}

message Child {
google.protobuf.Timestamp created_at = 1;
}
```
And the following DDL:
```sql
CREATE TABLE my_table(
parent project.service.Parent NOT NULL,
id STRING(MAX) NOT NULL,
created_at TIMESTAMP NOT NULL AS (
TIMESTAMP_ADD(
TIMESTAMP_SECONDS(parent.child.created_at.seconds),
INTERVAL parent.child.created_at.nanos NANOSECOND
)
) STORED
) PRIMARY KEY (id);
```

And I have proto bundles created for `Parent`, `Child`, and `google.protobuf.Timestamp`.

I'm seeing that the DDL runs without error, but an error arises when inserting into the table (`readWriteTransaction`). It seems to be an issue with the `created_at` generated column. If it's simplified to, say,
```sql
created_at TIMESTAMP NOT NULL AS (TIMESTAMP_SECONDS(parent.child.created_at.seconds)) STORED
```
then there is no error, but this is an adequate precision.

There error message is quite vague: `UNKNOWN: io.grpc.StatusRuntimeException: UNKNOWN: Unexpected error in RPC handling`.

[Using latest image (1.5.51, f450d0c2a7316)
](https://console.cloud.google.com/artifacts/docker/cloud-spanner-emulator/us/gcr.io/emulator/sha256:f450d0c2a73164ed9bbda1f3b675931f133a78bf046314db86268cbeecc67fb6)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.