{
  "$schema": "/products/haybarn/functions/api/v1/function.schema.json",
  "schemaVersion": 1,
  "name": "struct_pack",
  "schema": "main",
  "slug": "struct_pack",
  "description": "Create a STRUCT containing the argument values. The entry name will be the bound variable name.",
  "category": "nested",
  "kinds": [
    "scalar"
  ],
  "aliasOf": [],
  "snapshot": {
    "schemaVersion": 1,
    "id": "haybarn-2.0.0-rc11",
    "engine": "haybarn",
    "label": "Haybarn WASM 2.0.0-rc11",
    "engineVersion": "v2.0.0",
    "sourceId": "9b1a0c5829",
    "source": "https://www.npmjs.com/package/@haybarn/haybarn-wasm/v/2.0.0-rc11",
    "binarySha256": "07ab540b40e7dded86546a179f58276085900a44e92d1aa070072360c1f78ae6",
    "capturedAt": "2026-11-03T21:57:39.777Z",
    "requestedExtensions": [
      "core_functions",
      "icu",
      "json",
      "parquet"
    ],
    "loadedExtensions": [
      {
        "extension_name": "core_functions",
        "extension_version": "v2.0.0",
        "installed_from": ""
      },
      {
        "extension_name": "icu",
        "extension_version": "v2.0.0",
        "installed_from": ""
      },
      {
        "extension_name": "json",
        "extension_version": "v2.0.0",
        "installed_from": ""
      },
      {
        "extension_name": "nanoarrow",
        "extension_version": "8f9b4434ef",
        "installed_from": ""
      },
      {
        "extension_name": "parquet",
        "extension_version": "v2.0.0",
        "installed_from": ""
      }
    ],
    "scope": "Built-in functions in the main schema captured from the published Haybarn WASM package, with core_functions, ICU, JSON and Parquet loaded.",
    "runtime": {
      "engine": "haybarn-wasm",
      "packageVersion": "2.0.0-rc11",
      "bundle": "base"
    }
  },
  "links": {
    "html": "/products/haybarn/functions/releases/haybarn-2.0.0-rc11/struct_pack/",
    "markdown": "/products/haybarn/functions/releases/haybarn-2.0.0-rc11/struct_pack/index.md",
    "json": "/products/haybarn/functions/api/v1/haybarn-2.0.0-rc11/functions/struct_pack.json"
  },
  "interpretation": [
    "Choose a snapshot matching the target engine and build. The default is captured from the published Haybarn WASM package used by the browser playground. Historical native snapshots are also available.",
    "Availability is an observation in the recorded build and extension profile, not a guarantee of support in every installation or in WASM.",
    "Types and descriptions are declarations from duckdb_functions(). Binding can specialize result types. Null means not supplied by the catalog; do not invent defaults, optionality, argument mode, or table output columns.",
    "Raw parameter arrays preserve catalog order for scalar/aggregate/macro functions. Raw table arguments are alphabetical. Use callingConvention for engine-confirmed positional order and named arguments; null modes are unrecorded. Named does not mean optional. Macro defaults and special named variadic behavior are not supplied by duckdb_functions().",
    "Catalog examples are source material and may require data or extensions. runnableExamples contains separately verified SQL for the pinned WASM package; sample-data adaptations and guide examples are labeled separately.",
    "Guide annotations and recipes are separate editorial content. The browser runner always uses Haybarn WASM 2.0.0-rc12, independently of the documentation snapshot.",
    "All URLs beginning with / are relative to the origin hosting this document. Exports require no JavaScript, cookies, API key, or browser engine."
  ],
  "overloads": [
    {
      "id": "overload-36952b1a0b5515fa",
      "url": "/products/haybarn/functions/releases/haybarn-2.0.0-rc11/struct_pack/#overload-36952b1a0b5515fa",
      "signature": "struct_pack(…: ANY) → STRUCT",
      "parameterOrder": "catalog-order",
      "callingConvention": {
        "source": null,
        "parameters": [],
        "positional": null,
        "named": null,
        "variadic": {
          "type": "ANY",
          "minimumCount": null,
          "maximumCount": null,
          "namedArgumentMode": null
        },
        "evidence": null
      },
      "syntax": {
        "kind": "function",
        "operator": null
      },
      "catalog": {
        "schema_name": "main",
        "function_name": "struct_pack",
        "function_type": "scalar",
        "description": "Create a STRUCT containing the argument values. The entry name will be the bound variable name.",
        "comment": null,
        "return_type": "STRUCT",
        "parameters": [],
        "parameter_types": [],
        "varargs": "ANY",
        "macro_definition": null,
        "has_side_effects": false,
        "internal": true,
        "examples": [
          "struct_pack(i := 4, s := 'string')"
        ],
        "stability": "CONSISTENT",
        "categories": [],
        "alias_of": null
      }
    }
  ],
  "editorial": {
    "argumentNotes": [],
    "usage": {
      "purpose": "Build a struct with named fields",
      "summary": "Combine named values into a typed STRUCT, using argument names as field names and preserving each field’s type.",
      "behavior": "A NULL field remains part of the struct. The struct itself is still present.",
      "pitfall": "Use := for field names in struct_pack(). A struct has a fixed set of named fields; a MAP is a better fit for varying keys.",
      "sql": "WITH item AS (SELECT struct_pack(name := 'apple', quantity := NULL::INTEGER) AS product)\nSELECT product.name AS name, product.quantity AS quantity FROM item;",
      "columns": [
        "name",
        "quantity"
      ],
      "rows": [
        [
          "apple",
          null
        ]
      ],
      "source": "guide-editorial",
      "intendedRuntime": {
        "engine": "haybarn-wasm",
        "packageVersion": "2.0.0-rc12"
      }
    },
    "recipes": []
  },
  "examples": [
    {
      "original": "struct_pack(i := 4, s := 'string')",
      "sql": "SELECT struct_pack(i := 4, s := 'string');",
      "overloadIds": [
        "overload-36952b1a0b5515fa"
      ],
      "source": "engine-catalog",
      "verification": null
    }
  ],
  "translations": [
    {
      "function": "struct_pack",
      "scope": "",
      "relation": "rewrite",
      "source": {
        "engine": "Snowflake",
        "dialect": "snowflake",
        "name": "",
        "names": [
          "object_construct",
          "object_insert"
        ],
        "sql": "SELECT OBJECT_INSERT(OBJECT_INSERT(OBJECT_INSERT(OBJECT_CONSTRUCT(), 'key1', 5), 'key2', 2.2), 'key3', 'value3')"
      },
      "target": {
        "dialect": "duckdb",
        "name": "struct_pack",
        "sql": "SELECT STRUCT_INSERT(STRUCT_INSERT(STRUCT_PACK(key1 := 5), key2 := 2.2), key3 := 'value3')"
      },
      "formatTokens": [],
      "executionVerified": false,
      "provenance": {
        "name": "SQLGlot",
        "commit": "3086608e6fd4c41c02dfba47171608d2b193fce2",
        "url": "https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_snowflake.py#L2254"
      }
    }
  ],
  "runnableExamples": [
    {
      "function": "struct_pack",
      "original": "struct_pack(i := 4, s := 'string')",
      "sql": "SELECT struct_pack(i := 4, s := 'string');",
      "source": "engine-catalog",
      "verification": {
        "engine": "haybarn-wasm",
        "packageVersion": "2.0.0-rc12",
        "sourceId": "9b1a0c5829",
        "binarySha256": "07ab540b40e7dded86546a179f58276085900a44e92d1aa070072360c1f78ae6",
        "rowCount": 1
      }
    }
  ],
  "additionalDocumentation": [
    {
      "title": "Struct Data Type",
      "url": "https://duckdb.org/docs/current/sql/data_types/struct#creating-structs"
    },
    {
      "title": "Struct Functions",
      "url": "https://duckdb.org/docs/current/sql/functions/struct#struct_packname--any-"
    }
  ],
  "availability": [
    {
      "snapshot": "haybarn-2.0.0-rc12",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-36952b1a0b5515fa"
      ],
      "json": "/products/haybarn/functions/api/v1/haybarn-2.0.0-rc12/functions/struct_pack.json"
    },
    {
      "snapshot": "haybarn-2.0.0-rc11",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-36952b1a0b5515fa"
      ],
      "json": "/products/haybarn/functions/api/v1/haybarn-2.0.0-rc11/functions/struct_pack.json"
    },
    {
      "snapshot": "haybarn-2.0.0-rc8",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-36952b1a0b5515fa"
      ],
      "json": "/products/haybarn/functions/api/v1/haybarn-2.0.0-rc8/functions/struct_pack.json"
    },
    {
      "snapshot": "haybarn-1.5.5-rc3",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-36952b1a0b5515fa"
      ],
      "json": "/products/haybarn/functions/api/v1/haybarn-1.5.5-rc3/functions/struct_pack.json"
    },
    {
      "snapshot": "haybarn-1.5.6-rc6",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-36952b1a0b5515fa"
      ],
      "json": "/products/haybarn/functions/api/v1/haybarn-1.5.6-rc6/functions/struct_pack.json"
    },
    {
      "snapshot": "duckdb-2.0.0",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-36952b1a0b5515fa"
      ],
      "json": "/products/haybarn/functions/api/v1/duckdb-2.0.0/functions/struct_pack.json"
    },
    {
      "snapshot": "duckdb-1.5.6",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-36952b1a0b5515fa"
      ],
      "json": "/products/haybarn/functions/api/v1/duckdb-1.5.6/functions/struct_pack.json"
    },
    {
      "snapshot": "duckdb-1.5.5",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-36952b1a0b5515fa"
      ],
      "json": "/products/haybarn/functions/api/v1/duckdb-1.5.5/functions/struct_pack.json"
    },
    {
      "snapshot": "duckdb-1.4.4",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-36952b1a0b5515fa"
      ],
      "json": "/products/haybarn/functions/api/v1/duckdb-1.4.4/functions/struct_pack.json"
    },
    {
      "snapshot": "duckdb-1.3.2",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-36952b1a0b5515fa"
      ],
      "json": "/products/haybarn/functions/api/v1/duckdb-1.3.2/functions/struct_pack.json"
    }
  ]
}
