Skip to content

duckdb: unnest in the FROM clause is an unknown function #4712

Backlog

Description

@kyleconroy

Version

main at commit 3ad8b20 (2026-10-23). sqlc version prints v1.31.1.

What happened?

Using unnest as a table function in FROM, with a lateral reference to a list column, fails with unknown function "unnest". DuckDB accepts this query.

unnest in the select list works, so the workaround is to unnest inside a CTE and select from that:

WITH i AS (SELECT id, unnest(items) AS it FROM transactions) SELECT ... FROM i;

Expected: u.it resolves, and its type is the list's element type (here the struct).

Relevant log output

# package db
query.sql:1:1: unknown function "unnest"

Database schema

CREATE TABLE transactions (id VARCHAR NOT NULL, items STRUCT(type VARCHAR, amount INTEGER)[]);

SQL queries

-- name: ListItems :many
SELECT t.id, u.it FROM transactions t, unnest(t.items) AS u(it);

Configuration

version: "2"
sql:
  - engine: duckdb
    schema: schema.sql
    queries: query.sql
    gen:
      go:
        package: db
        out: db

What operating system are you using?

Linux

What database engines are you using?

DuckDB

What type of code are you generating?

Go

Activity

  1. added
    bug
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions