The functions on this page work on STRUCT values. Functions that access entries by position, such as struct[idx], struct_extract_at, struct_contains, struct_position, and struct_values, also accept TUPLE values, i.e., structs with unnamed entries. struct_concat accepts either only STRUCTs or only TUPLEs. Functions that work with entry names, i.e., struct_insert, struct_keys, struct_update, and remap_struct, require a STRUCT.
Remap a STRUCT, LIST, or MAP value into the shape given by the type of target_type, renaming and reordering fields, descending into nested types, and filling missing fields from defaults.
Remap an input value of type STRUCT, LIST, or MAP into the shape declared by the type of target_type, renaming and reordering fields, descending into nested types, and filling target fields that have no source counterpart from defaults. Only the type of target_type is used, not its value, so any value of the desired type works; a typed NULL literal (e.g. NULL::STRUCT(v1 INT, v2 INT)) is a convenient way to declare the target shape when no suitable value is at hand. mapping is a STRUCT keyed by target field name whose values name the source field to read from; defaults is a STRUCT of constant values for the remaining target fields. Every target field must be covered by either mapping or defaults.
To remap a target field that is itself a STRUCT, give its mapping value as ROW(source_field, {inner_mapping}), and nest its defaults the same way. A LIST's single child is addressed by the mapping key 'list', and a MAP's children by the keys 'key' and 'value'.