> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# NAMED_STRUCT

> Builds a struct from pairs of field names and values.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

The struct itself is non-NULL; NULL values become NULL fields. Field names must be non-NULL.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
named_struct(name, value, ...)
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| name | STRING | Yes | A nonempty constant field name. A nonempty, non-NULL constant string; names must be unique. This argument can repeat. Must be a constant argument. |
| value | BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP, ARRAY, MAP or STRUCT | Yes | The field value; more name/value pairs are accepted. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). This argument can repeat. |

## Returns

* Type: STRUCT
* Possible values: The named fields with their individual input types.
* NULL behavior: The struct itself is non-NULL; NULL values become NULL fields. Field names must be non-NULL.
* Shape: One field per name/value pair with the input value type.
* Ordering: Name/value argument pair order.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* Field order follows the name/value pairs, and each field preserves its value type. The constructed struct is non-NULL even if every field value is NULL.
* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT named_struct('a', 1, 'b', CAST(NULL AS INT)) AS "value";
```

| value |
| - |
| \{"a":1,"b":null} |

### Combine text, a number and a boolean

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT named_struct('name', 'Ada', 'score', CAST(9.5 AS DOUBLE), 'active', TRUE) AS person;
```

| person |
| - |
| \{"name":"Ada","score":9.5,"active":true} |

## Limitations

* Requires an even argument count and at least one pair; names must be nonempty constant strings.
* Supply at least one name/value pair and an even number of arguments. Field names must be nonempty and unique. Name comparison is case-sensitive.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.