struct_pack()

Create a STRUCT containing the argument values. The entry name will be the bound variable name.

Arguments & returns

struct_pack(…)

Scalar
Overload link … Varargs Returns
#01 ANY STRUCT

… accepts a variable number of arguments of the type shown.

Example

struct_pack example
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Engine example · Run to view results.

In other engines

Used in larger rewrites 1

These examples use struct_pack as one part of a larger SQL translation.

Snowflake

SELECT OBJECT_INSERT(OBJECT_INSERT(OBJECT_INSERT(OBJECT_CONSTRUCT(), 'key1', 5), 'key2', 2.2), 'key3', 'value3')
In DuckDB
SELECT STRUCT_INSERT(STRUCT_INSERT(STRUCT_PACK(key1 := 5), key2 := 2.2), key3 := 'value3')

SQLGlot example ↗