cloudspannerecosystem / cassandra-to-spanner-proxy

Apache License 2.0
9 stars 4 forks source link

Timestamps must end with Z #3

Open jdiamond opened 1 month ago

jdiamond commented 1 month ago

Create a table like this with spanner-cli:

create table timestamp_offsets (
  id string(max),
  ts timestamp,
  last_commit_ts timestamp options (allow_commit_timestamp=true)
) primary key (id);

Insert the metadata:

INSERT INTO TableConfigurations (KeySpaceName, TableName, ColumnName, ColumnType, IsPrimaryKey, PK_Precedence) VALUES ('test', 'timestamp_offsets', 'id', 'text', true, 0);
INSERT INTO TableConfigurations (KeySpaceName, TableName, ColumnName, ColumnType, IsPrimaryKey, PK_Precedence) VALUES ('test', 'timestamp_offsets', 'ts', 'timestamp', false, 0);

I can insert timestamps with "Z" or with a numeric offset via spanner-cli:

insert into timestamp_offsets (id, ts) values ('a', '2024-10-22T12:00:00Z');
insert into timestamp_offsets (id, ts) values ('b', '2024-10-22T12:00:00-07:00');

Only the timestamp ending with "Z" works via cqlsh:

insert into test.timestamp_offsets (id, ts) values ('c', '2024-10-22T12:00:00Z');
insert into test.timestamp_offsets (id, ts) values ('d', '2024-10-22T12:00:00-07:00');

When I try to execute that last insert, I get this error in cqlsh:

InvalidRequest: Error from server: code=2200 [Invalid query] message="spanner: code = "FailedPrecondition", desc = "Invalid value for column ts in table timestamp_offsets: Expected TIMESTAMP.""

And this error in the proxy:

{"level":"error","time":"2024-10-23T00:04:03.244Z","caller":"proxy/proxy.go:1548","msg":"Error occurred at spanner - ","Query":"insert into test.timestamp_offsets (id, ts) values ('d', '2024-10-22T12:00:00-07:00');","error":"spanner: code = \"FailedPrecondition\", desc = \"Invalid value for column ts in table timestamp_offsets: Expected TIMESTAMP.\"","stacktrace":"github.com/ollionorg/cassandra-to-spanner-proxy/third_party/datastax/proxy.(*client).handleQuery\n\t/go/src/cassandra-to-spanner-proxy/third_party/datastax/proxy/proxy.go:1548\ngithub.com/ollionorg/cassandra-to-spanner-proxy/third_party/datastax/proxy.(*client).Receive\n\t/go/src/cassandra-to-spanner-proxy/third_party/datastax/proxy/proxy.go:641\ngithub.com/ollionorg/cassandra-to-spanner-proxy/third_party/datastax/proxycore.(*Conn).read\n\t/go/src/cassandra-to-spanner-proxy/third_party/datastax/proxycore/conn.go:114"}