Skip to content

Change-stream mods.keys JSON drops sub-second precision for TIMESTAMP columns #347

Description

@myeo-ant

When a tracked table has a TIMESTAMP column in its primary key, the change-stream DataChangeRecord.mods[].keys JSON encodes that column without fractional seconds. Real Spanner preserves up to 9 fractional digits.

Repro:

  1. CREATE TABLE t (commit_ts TIMESTAMP NOT NULL, k INT64) PRIMARY KEY (commit_ts, k) + CREATE CHANGE STREAM s FOR t
  2. Insert a row with commit_ts = TIMESTAMP '1970-01-21T14:09:51.234567890Z'
  3. Read the change-stream; mods[0].keys.commit_ts is "1970-01-21T14:09:51Z" (decimals dropped)

Cause: backend/actions/change_stream.cc CloudValueToJSONValue uses absl::FormatTime("%Y-%m-%d%ET%H:%M:%SZ", ...) for TYPE_TIMESTAMP%S emits integer seconds. Real Spanner emits fractional. The fix is %E*S (or %E9S).

Same function as #328 (UUID encoding), similar shape of fix.

Affected: any consumer that reconstructs row identity from keys JSON when a TIMESTAMP is part of the PK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions