Skip to content

Error: Binder Error: Referenced table "unnamed_subquery1" not found! in UNPIVOT with a SELECT expression #7795

@noloerino

Description

@noloerino

What happens?

When performing an UNPIVOT on a SELECT expression (rather than just a table name, as in the examples, duckdb gives the following error:

Error: Binder Error: Referenced table "unnamed_subquery1" not found!
Candidate tables: "unnamed_subquery8"

To Reproduce

CREATE OR REPLACE TABLE monthly_sales(empid INT, dept TEXT, Jan INT, Feb INT, Mar INT, Apr INT, May INT, Jun INT);
INSERT INTO monthly_sales VALUES
(1, 'electronics', 1, 2, 3, 4, 5, 6),
(2, 'clothes', 10, 20, 30, 40, 50, 60),
(3, 'cars', 100, 200, 300, 400, 500, 600);

-- works as intended
UNPIVOT monthly_sales
    ON jan, feb, mar, apr, may, jun
    INTO
        NAME month
        VALUE sales;

-- complains about missing unnamed_subquery
UNPIVOT (SELECT * FROM monthly_sales)
    ON jan, feb, mar, apr, may, jun
    INTO
        NAME month
        VALUE sales;

OS:

macOS 13.1 (arm64)

DuckDB Version:

v0.8.0 e8e4cea

DuckDB Client:

CLI

Full Name:

Jonathan Shi

Affiliation:

Ponder Data

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions