| is_valid_variant(v) |
Returns true if the variant is valid, false if it is malformed, NULL if `v` is NULL. |
| is_variant_null(expr) |
Check if a variant value is a variant null. Returns true if and only if the input is a variant null and false otherwise (including in the case of SQL NULL). |
| parse_json(jsonStr) |
Parse a JSON string as a Variant value. Throw an exception when the string is not valid JSON value. |
| schema_of_variant(v) |
Returns schema in the SQL format of a variant. |
| schema_of_variant_agg(v) |
Returns the merged schema in the SQL format of a variant column. |
| to_variant_object(expr) |
Convert a nested input (array/map/struct) into a variant where maps and structs are converted to variant objects which are unordered unlike SQL structs. Input maps can only have string keys. |
| try_parse_json(jsonStr) |
Parse a JSON string as a Variant value. Return NULL when the string is not valid JSON value. |
| try_variant_array_append(v, path, val) |
Appends a value to the array in a variant at the given JSONPath location. Returns the variant unchanged if a path key or index is absent. Returns NULL if a path segment hits a value of an incompatible type, the target is not an array, or if any argument is NULL. |
| try_variant_get(v, path[, type]) |
Extracts a sub-variant from `v` according to `path`, and then cast the sub-variant to `type`. When `type` is omitted, it is default to `variant`. Returns null if the path does not exist or the cast fails. |
| try_variant_insert(v, path, val) |
Inserts a value into a variant at the given JSONPath location. An object path adds a new field; an array path inserts at the index, shifting later elements right. Missing intermediate keys are created. Returns NULL if the field already exists or a path segment hits a value of an incompatible type, or if any argument is NULL. |
| try_variant_set(v, path, val[, create_if_missing]) |
Sets or upserts a value in a variant at the given JSONPath location. An existing object field or array element at the target is replaced. A missing field, array index, or intermediate path is created, unless `create_if_missing` is false, in which case the variant is left unchanged. Returns NULL if a path segment hits a value of an incompatible type, or if any argument is NULL. |
| variant_array_append(v, path, val) |
Appends a value to the array in a variant at the given JSONPath location. Returns the variant unchanged if a path key or index is absent. Throws an error if a path segment hits a value of an incompatible type or the target is not an array. Returns NULL if any argument is NULL. |
| variant_delete(v, path1[, path2, ...]) |
Removes fields or array elements from a variant at the given JSONPath locations. Multiple paths are applied left to right. Returns NULL if `v` is NULL; NULL paths are skipped. |
| variant_explode(expr) |
It separates a variant object/array into multiple rows containing its fields/elements. Its result schema is `struct`. `pos` is the position of the field/element in its parent object/array, and `value` is the field/element value. `key` is the field name when exploding a variant object, or is NULL when exploding a variant array. It ignores any input that is not a variant array/object, including SQL NULL, variant null, and any other variant values. |
| variant_explode_outer(expr) |
It separates a variant object/array into multiple rows containing its fields/elements. Its result schema is `struct`. `pos` is the position of the field/element in its parent object/array, and `value` is the field/element value. `key` is the field name when exploding a variant object, or is NULL when exploding a variant array. It ignores any input that is not a variant array/object, including SQL NULL, variant null, and any other variant values. |
| variant_get(v, path[, type]) |
Extracts a sub-variant from `v` according to `path`, and then cast the sub-variant to `type`. When `type` is omitted, it is default to `variant`. Returns null if the path does not exist. Throws an exception if the cast fails. |
| variant_insert(v, path, val) |
Inserts a value into a variant at the given JSONPath location. An object path adds a new field (error if it already exists); an array path inserts at the index, shifting later elements right. Missing intermediate keys are created. Throws an error if a path segment hits a value of an incompatible type. Returns NULL if any argument is NULL. |
| variant_set(v, path, val[, create_if_missing]) |
Sets or upserts a value in a variant at the given JSONPath location. An existing object field or array element at the target is replaced. A missing field, array index, or intermediate path is created, unless `create_if_missing` is false, in which case the variant is left unchanged. Throws an error if a path segment hits a value of an incompatible type. Returns NULL if any argument is NULL. |
| variant_strip_nulls(v[, include_arrays]) |
Recursively removes object fields and array elements whose value is a variant null, unless `include_arrays` is false, in which case null array elements are kept. Returns NULL if any argument is NULL. |