Skip to main content

Module convert

Module convert 

Source
Expand description

Type-aware conversion from BigQuery TableRows to JSON objects.

BigQuery returns every scalar cell as a string regardless of declared type, with non-trivial structure (RECORD/STRUCT/REPEATED) reflected in nested cell shapes:

  • A RECORD cell carries {"f": [...nested cells...]} in its value field.
  • A REPEATED cell carries [{"v": ...cell...}, ...] in its value field — one element per array entry.

This module walks the schema in lockstep with each row’s cells and emits a serde_json::Value::Object keyed by column name, with each cell typed according to its TableFieldSchema.

§Type mapping

BigQuery typeJSON output
INTEGER / INT64Number (i64 if it fits, else f64)
FLOAT / FLOAT64Number (f64)
NUMERIC / BIGNUMERICString (full precision preserved)
BOOLEAN / BOOLBool
RECORD / STRUCTnested Object
REPEATED <T> modeArray<T>
JSONparsed Value (falls back to String)
STRING / BYTES / TIMESTAMP / DATE / TIME / DATETIME / GEOGRAPHY / INTERVALString
NULL cellNull

Functions§

row_to_json
Convert a BigQuery TableRow into a JSON object using its schema.