google-cloud-ruby: Cloud Bigtable setCell timestamp field does not set timestamp on cell.
When setting the timestamp on a cell value, the timestamp is ignored. You can test this with the hello world
entry = table.new_mutation_entry "greeting#{i}"
entry.set_cell(
column_family,
column_qualifier,
value,
timestamp: Time.now.to_i * 1000
)
table.mutate_row entry
When I read the results, this is what I see:
greeting0
cf:greeting @ 1970/01/18-21:16:13.999000
"Hello World!"
----------------------------------------
greeting1
cf:greeting @ 1970/01/18-21:16:14.000000
"Hello Bigtable!"
----------------------------------------
greeting2
cf:greeting @ 1970/01/18-21:16:14.000000
"Hello Ruby!"
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (15 by maintainers)
Commits related to this issue
- docs(bigtable): Fix timestamp param documentation [closes #3676] — committed to quartzmo/google-cloud-ruby by quartzmo 5 years ago
I think the problem is that the example code is using milliseconds, but the table is likely configured for microseconds. The API’s
Mutation.SetCell
documentation states:So there seems to me to be a mismatch here. The example code is clearly using milliseconds, but the “granularity of the table” that the user is using is likely set to microseconds.
If you don’t want to change the table granularity, I would replace
Time.now.to_i * 1000
withTime.now.to_i * 1000000
, or the more accurate(t = Time.now; t.to_i * 1000000 + t.usec)
: