Documentation

    struct_update

    Change or add fields in an existing struct. Each field takes its name from a named argument, as in struct_update(s, b := 2).

    Try an expression

    In Formula, enter the expression and set Output type to VARCHAR.

    Expression

    struct_update({'a': 1, 'b': 2}, b := 3, c := 4)

    Result

    '{'a': 1, 'b': 3, 'c': 4}'

    The expression returns STRUCT(a INTEGER, b INTEGER, c INTEGER). Formula stores it as VARCHAR in this example. To use your own data, replace the example values with column names. Keep format strings and other options as written.

    Arguments and types

    struct_update(...)
    Supported signatures (1)
    struct_update(...: ANY) → STRUCT

    The result type can depend on the input types. See DuckDB for the full argument rules.

    Things to know

    With a missing first argument

    struct_update(CASE WHEN false THEN {'a': 1, 'b': 2} ELSE NULL END, b := 3, c := 4)

    '{'a': NULL, 'b': 3, 'c': 4}'

    Browse structsDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.