Function mz_sql::plan::typeconv::to_jsonb

source ·
pub fn to_jsonb(ecx: &ExprContext<'_>, expr: HirScalarExpr) -> HirScalarExpr
Expand description

Converts an expression to ScalarType::Jsonb.

The rules are as follows:

  • ScalarType::Booleans become JSON booleans.
  • All numeric types are converted to Float64s, then become JSON numbers.
  • Records are converted to a JSON object where the record’s field names are the keys of the object, and the record’s fields are recursively converted to JSON by to_jsonb.
  • Other types are converted to strings by their usual cast function an
  • A Datum::Null of any type becomes a JSON null.