variant_type_name

variant_type_name(value: variant) -> string

Resolves the data type of a variant column so that column may be typed for better performance.

Given a variant value (typically, something you get from looking up a path or element in a JSON object or array,) determine what type that value has.

The possible types are:

  • "string"
  • "bool"
  • "float64"
  • "int64"
  • "object"
  • "array"
  • null

Domain

This is a scalar function (calculates a single output value for a single input row).

Categories

Examples

make_col obj:parse_json('{"str":"xx", "int":12345, "flt":3.1416, "bol":true, "obj":{}, "ary":[], "nul":null}')
make_col typ_str:variant_type_name(obj.str),
         typ_int:variant_type_name(obj.int),
         typ_flt:variant_type_name(obj.flt),
         typ_bol:variant_type_name(obj.bol),
         typ_obj:variant_type_name(obj.obj),
         typ_ary:variant_type_name(obj.ary),
         typ_nul:variant_type_name(obj.nul),
         typ_xxx:variant_type_name(obj.xxx)

This code parses a JSON object from string, and then constructs a column containing the name of the type of each object in that made object. The values of the columns will be:

columnvalue
typ_str"string"
typ_int"int64"
typ_flt"float64"
typ_bol"bool"
typ_obj"object"
typ_ary"array"
typ_nul"null"
typ_xxxnull