Skip to main content

Module decode

Module decode 

Source
Available on crate features sink-spanner or source-spanner only.
Expand description

Generic Spanner row → serde_json::Value decoding.

faucet sources run arbitrary user SQL, so rows must decode without a compile-time schema. SpannerJson implements the client’s TryFromValue hook, which hands us the raw protobuf value plus the column’s full Type metadata — enough to decode every Spanner type into faithful JSON:

SpannerJSON
INT64 / ENUMinteger (lossless — arrives string-encoded)
FLOAT64 / FLOAT32number (NaN/Infinity → string)
BOOLboolean
STRING / TIMESTAMP / DATE / UUID / INTERVALstring
BYTES / PROTObase64 string (as transmitted)
NUMERICstring (precision preserved)
JSONparsed object/array/scalar
ARRAYarray (element type recursed)
STRUCTobject keyed by field name

Structs§

SpannerJson
Newtype decoding one Spanner column into a serde_json::Value.

Functions§

decode_value
Decode one protobuf value with its (possibly absent) Spanner type.
row_to_json
Decode a whole Row into a JSON object keyed by column name, using the stream’s column metadata (RowIterator::columns_metadata).