pub fn to_jsonb(
ecx: &ExprContext<'_>,
expr: HirScalarExpr,
) -> Result<HirScalarExpr, PlanError>Expand description
Converts an expression to SqlScalarType::Jsonb.
The rules are as follows:
SqlScalarType::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 and
become JSON strings. That cast can fail (see
to_string), in which case we propagate the planning error instead of panicking.