---
title: "struct_pack function in Strata | Oplema"
description: "Create a struct from named arguments, grouping related values into one column. Write it as struct_pack(a := 1) in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/struct-pack"
updated: "2026-11-04"
---

# struct\_pack

Create a struct from named arguments. Each field takes its name from its argument, as in struct\_pack(a := 1).

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **VARCHAR**.

### Expression

```
struct_pack(i := 4, s := 'string')
```

### Result

```
'{'i': 4, 's': string}'
```

The expression returns `STRUCT(i INTEGER, s VARCHAR)`. 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.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | {'i': 4, 's': string} |

## Arguments and types

```
struct_pack(...)
```

Supported signatures (1)

```
struct_pack(...: ANY) → STRUCT
```

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

## Things to know

### A missing field stays missing

```
struct_pack(name := NULL::VARCHAR)
```

'{'name': NULL}'

## Related functions

[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).

](https://oplema.com/docs/strata/functions/struct-insert)[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).

](https://oplema.com/docs/strata/functions/struct-update)[row

Create an unnamed struct from its arguments.

](https://oplema.com/docs/strata/functions/row)[struct\_extract

Get one entry from a struct by name, or by position starting at 1 in an unnamed struct.

](https://oplema.com/docs/strata/functions/struct-extract)

[Browse structs](https://oplema.com/docs/strata/functions#structs) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/struct.html#struct_packname-any)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
