-1

I am looking through the documentation for Google Cloud Spanner, and it looks like write operations return a timestamp when the row was actually written.

But when reading rows, it doesn't seem possible to re-capture that timestamp (either as a column that can be read or as a column that could be limited and sorted on).

I assume that I could just update the row after it is written to append a new column (created_at), but ideally it would be nice to have that field automatically appended.

Is there any way to access the original transaction timestamp when querying spanner? I also noticed that there was a CURRENT_TIMESTAMP() sql function. Is that equivalent to the transaction timestamp?

dolan
  • 1,716
  • 11
  • 22

3 Answers3

2

You can create commit timestamp columns, and Cloud Spanner writes the timestamp as part of the transaction:

https://cloud.google.com/spanner/docs/commit-timestamp

Robin
  • 46
  • 2
  • Welcome to Stack Overflow! In the future, please include all relevant code in your post and **don't** just include a link to a code hosting site. Your post should stand alone from any other resource; [consider what would happen](https://en.wikipedia.org/wiki/Link_rot) if that site went down in the future! – Neuron Apr 16 '18 at 23:02
1

Currently, updating the timestamp column is the closest we can get.

Identicon
  • 21
  • 4
0

CURRENT_TIMESTAMP() returns the current time.

See for more information:
https://cloud.google.com/spanner/docs/functions-and-operators#current_timestamp

K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
Rose Liu
  • 251
  • 1
  • 5