Skip to content

Flatten an array column using UNNEST breaks #1

Description

@tmakris

Assume a table that has two columns:

  • id: Integer
  • tags: String (REPEATED)
  • is_deleted: Boolean

Trying to execute the following query:

SELECT distinct value FROM {table_ref}, unnest (tags) as value WHERE COALESCE(is_deleted, FALSE) = FALSE

Generates the following error:

`google.api_core.exceptions.BadRequest: 400 rpc error: code = Unimplemented desc = duckdb engine: DuckDB rejected transpiled SQL: Binder Error: Referenced column "__bq_j_5" not found in FROM clause!
Candidate bindings: "value"

LINE 1: SELECT "__bq_j_5" AS "value" FROM (SELECT * FROM (SELECT "__bq_j_4...
^ (sql=SELECT "__bq_j_5" AS "value" FROM (SELECT * FROM (SELECT "__bq_j_4" AS "value" FROM (SELECT * FROM (SELECT __bq_l."id" AS "__bq_j_1", __bq_l."is_deleted" AS "__bq_j_2", __bq_l."tags" AS "__bq_j_3", bq_unnest."value" AS "__bq_j_4", ord AS "__bq_input_rn" FROM (SELECT "id", "is_deleted", "tags" FROM "profiles") AS __bq_l, unnest(__bq_l."tags") WITH ORDINALITY AS bq_unnest("value", ord)) WHERE (COALESCE("__bq_j_2", false) = false)) GROUP BY "__bq_j_4") ORDER BY "value" ASC NULLS FIRST))`

This is tested using the following versions through the respective public Docker images:

  • 0.7.0
  • 0.7.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions