Documentation

    struct_insert

    Add fields to an existing struct. Each new field takes its name from a named argument, as in struct_insert(s, b := 2).

    Try an expression

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

    Expression

    struct_insert({'a': 1}, b := 2)

    Result

    '{'a': 1, 'b': 2}'

    The expression returns STRUCT(a INTEGER, b 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_insert(...)
    Supported signatures (1)
    struct_insert(...: 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_insert(CASE WHEN false THEN {'a': 1} ELSE NULL END, b := 2)

    '{'a': NULL, 'b': 2}'

    Browse structsDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.