{
  "$schema": "/products/haybarn/functions/api/v1/function.schema.json",
  "schemaVersion": 1,
  "name": "unnest",
  "schema": "main",
  "slug": "unnest",
  "description": null,
  "category": "files",
  "kinds": [
    "table"
  ],
  "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/unnest/",
    "markdown": "/products/haybarn/functions/releases/haybarn-2.0.0-rc11/unnest/index.md",
    "json": "/products/haybarn/functions/api/v1/haybarn-2.0.0-rc11/functions/unnest.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-3e87f6f35b7ecbe0",
      "url": "/products/haybarn/functions/releases/haybarn-2.0.0-rc11/unnest/#overload-3e87f6f35b7ecbe0",
      "signature": "unnest(list: ANY) → TABLE",
      "parameterOrder": "alphabetical-not-call-order",
      "callingConvention": {
        "source": "engine-binder",
        "parameters": [
          {
            "name": "list",
            "type": "ANY",
            "mode": "positional",
            "position": 0
          }
        ],
        "positional": [
          {
            "name": "list",
            "type": "ANY",
            "mode": "positional",
            "position": 0
          }
        ],
        "named": [],
        "variadic": null,
        "evidence": {
          "query": "EXPLAIN SELECT * FROM \"unnest\"(NULL, NULL);",
          "diagnostic": "Binder Error: No function matches the given name and argument types 'unnest(\"NULL\", \"NULL\")'. You might need to add explicit type casts.\n\tCandidate functions:\n\tunnest(list ANY, /)\n\n\nLINE 1: EXPLAIN SELECT * FROM \"unnest\"(NULL, NULL);\n                              ^^^^^^^^^^^^^^^^^^^^"
        }
      },
      "syntax": {
        "kind": "function",
        "operator": null
      },
      "catalog": {
        "schema_name": "main",
        "function_name": "unnest",
        "function_type": "table",
        "description": null,
        "comment": null,
        "return_type": null,
        "parameters": [
          "list"
        ],
        "parameter_types": [
          "ANY"
        ],
        "varargs": null,
        "macro_definition": null,
        "has_side_effects": null,
        "internal": true,
        "examples": [],
        "stability": null,
        "categories": [],
        "alias_of": null
      }
    }
  ],
  "editorial": {
    "argumentNotes": [],
    "usage": {
      "purpose": "Turn list items into rows",
      "summary": "Expand a list into individual rows so each item can be filtered, joined, or aggregated with ordinary SQL.",
      "behavior": "A NULL item in a list becomes a NULL row. An empty list or a NULL list produces no rows.",
      "pitfall": "Expanding an empty list can remove its parent row. Use a LEFT JOIN LATERAL when parent rows must survive an empty expansion.",
      "sql": "SELECT value FROM unnest([1, NULL, 3]) AS t(value) ORDER BY value NULLS LAST;",
      "columns": [
        "value"
      ],
      "rows": [
        [
          "1"
        ],
        [
          "3"
        ],
        [
          null
        ]
      ],
      "source": "guide-editorial",
      "intendedRuntime": {
        "engine": "haybarn-wasm",
        "packageVersion": "2.0.0-rc12"
      }
    },
    "recipes": []
  },
  "examples": [],
  "translations": [
    {
      "function": "unnest",
      "scope": "",
      "relation": "rewrite",
      "source": {
        "engine": "PostgreSQL",
        "dialect": "postgres",
        "name": "",
        "names": [
          "date_trunc",
          "generate_series"
        ],
        "sql": "WITH dates AS (SELECT GENERATE_SERIES('2020-01-01'::DATE, '2024-01-01'::DATE, '1 day'::INTERVAL) AS date), date_table AS (SELECT DISTINCT DATE_TRUNC('MONTH', date) AS date FROM dates) SELECT * FROM date_table"
      },
      "target": {
        "dialect": "duckdb",
        "name": "unnest",
        "sql": "WITH dates AS (SELECT UNNEST(GENERATE_SERIES(CAST('2020-01-01' AS DATE), CAST('2024-01-01' AS DATE), CAST('1 day' AS INTERVAL))) AS date), date_table AS (SELECT DISTINCT DATE_TRUNC('MONTH', date) AS date FROM dates) SELECT * FROM date_table"
      },
      "formatTokens": [],
      "executionVerified": false,
      "provenance": {
        "name": "SQLGlot",
        "commit": "3086608e6fd4c41c02dfba47171608d2b193fce2",
        "url": "https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_postgres.py#L787"
      }
    },
    {
      "function": "unnest",
      "scope": "",
      "relation": "rewrite",
      "source": {
        "engine": "Apache Hive",
        "dialect": "hive",
        "name": "explode",
        "names": [
          "explode"
        ],
        "sql": "SELECT a FROM x LATERAL VIEW EXPLODE(y) t AS a"
      },
      "target": {
        "dialect": "duckdb",
        "name": "unnest",
        "sql": "SELECT a FROM x CROSS JOIN UNNEST(y) AS t(a)"
      },
      "formatTokens": [],
      "executionVerified": false,
      "provenance": {
        "name": "SQLGlot",
        "commit": "3086608e6fd4c41c02dfba47171608d2b193fce2",
        "url": "https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_hive.py#L281"
      }
    },
    {
      "function": "unnest",
      "scope": "",
      "relation": "direct",
      "source": {
        "engine": "Apache Spark",
        "dialect": "spark",
        "name": "explode",
        "names": [
          "explode"
        ],
        "sql": "EXPLODE(x)"
      },
      "target": {
        "dialect": "duckdb",
        "name": "unnest",
        "sql": "UNNEST(x)"
      },
      "formatTokens": [],
      "executionVerified": false,
      "provenance": {
        "name": "SQLGlot",
        "commit": "3086608e6fd4c41c02dfba47171608d2b193fce2",
        "url": "https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_duckdb.py#L1119"
      }
    },
    {
      "function": "unnest",
      "scope": "",
      "relation": "rewrite",
      "source": {
        "engine": "BigQuery",
        "dialect": "bigquery",
        "name": "unnest",
        "names": [
          "unnest"
        ],
        "sql": "SELECT * FROM UNNEST(ARRAY<STRUCT<x INT64>>[])"
      },
      "target": {
        "dialect": "duckdb",
        "name": "unnest",
        "sql": "SELECT * FROM (SELECT UNNEST(CAST([] AS STRUCT(x BIGINT)[]), max_depth => 2))"
      },
      "formatTokens": [],
      "executionVerified": false,
      "provenance": {
        "name": "SQLGlot",
        "commit": "3086608e6fd4c41c02dfba47171608d2b193fce2",
        "url": "https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_bigquery.py#L2815"
      }
    },
    {
      "function": "unnest",
      "scope": "",
      "relation": "rewrite",
      "source": {
        "engine": "Snowflake",
        "dialect": "snowflake",
        "name": "minhash_combine",
        "names": [
          "minhash_combine"
        ],
        "sql": "MINHASH_COMBINE(sig_col)"
      },
      "target": {
        "dialect": "duckdb",
        "name": "unnest",
        "sql": "(SELECT JSON_OBJECT('state', LIST(min_h ORDER BY idx NULLS FIRST), 'type', 'minhash', 'version', 1) FROM (SELECT pos AS idx, MIN(val) AS min_h FROM UNNEST(LIST(sig_col)) AS _(sig) JOIN UNNEST(CAST(sig -> '$.state' AS UBIGINT[])) WITH ORDINALITY AS t(val, pos) ON TRUE GROUP BY pos))"
      },
      "formatTokens": [],
      "executionVerified": false,
      "provenance": {
        "name": "SQLGlot",
        "commit": "3086608e6fd4c41c02dfba47171608d2b193fce2",
        "url": "https://github.com/tobymao/sqlglot/blob/3086608e6fd4c41c02dfba47171608d2b193fce2/tests/dialects/test_snowflake.py#L2363"
      }
    }
  ],
  "runnableExamples": [],
  "additionalDocumentation": [
    {
      "title": "Enum Data Type",
      "url": "https://duckdb.org/docs/current/sql/data_types/enum#ordering-of-enums"
    },
    {
      "title": "Struct Data Type",
      "url": "https://duckdb.org/docs/current/sql/data_types/struct#unnest--struct"
    },
    {
      "title": "List Functions",
      "url": "https://duckdb.org/docs/current/sql/functions/list#unnestlist"
    }
  ],
  "availability": [
    {
      "snapshot": "haybarn-2.0.0-rc12",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-3e87f6f35b7ecbe0"
      ],
      "json": "/products/haybarn/functions/api/v1/haybarn-2.0.0-rc12/functions/unnest.json"
    },
    {
      "snapshot": "haybarn-2.0.0-rc11",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-3e87f6f35b7ecbe0"
      ],
      "json": "/products/haybarn/functions/api/v1/haybarn-2.0.0-rc11/functions/unnest.json"
    },
    {
      "snapshot": "haybarn-2.0.0-rc8",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-3e87f6f35b7ecbe0"
      ],
      "json": "/products/haybarn/functions/api/v1/haybarn-2.0.0-rc8/functions/unnest.json"
    },
    {
      "snapshot": "haybarn-1.5.5-rc3",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [],
      "json": "/products/haybarn/functions/api/v1/haybarn-1.5.5-rc3/functions/unnest.json"
    },
    {
      "snapshot": "haybarn-1.5.6-rc6",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [],
      "json": "/products/haybarn/functions/api/v1/haybarn-1.5.6-rc6/functions/unnest.json"
    },
    {
      "snapshot": "duckdb-2.0.0",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [
        "overload-3e87f6f35b7ecbe0"
      ],
      "json": "/products/haybarn/functions/api/v1/duckdb-2.0.0/functions/unnest.json"
    },
    {
      "snapshot": "duckdb-1.5.6",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [],
      "json": "/products/haybarn/functions/api/v1/duckdb-1.5.6/functions/unnest.json"
    },
    {
      "snapshot": "duckdb-1.5.5",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [],
      "json": "/products/haybarn/functions/api/v1/duckdb-1.5.5/functions/unnest.json"
    },
    {
      "snapshot": "duckdb-1.4.4",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [],
      "json": "/products/haybarn/functions/api/v1/duckdb-1.4.4/functions/unnest.json"
    },
    {
      "snapshot": "duckdb-1.3.2",
      "observed": true,
      "overloadCount": 1,
      "matchingOverloadIds": [],
      "json": "/products/haybarn/functions/api/v1/duckdb-1.3.2/functions/unnest.json"
    }
  ]
}
