Skip to content

BigQuery: named query parameters (@name) parsed as ABS(name) #478

Description

@nikchha

BigQuery named query parameters (@name) are parsed as the @ absolute value operator and emitted as ABS(name).

Version: @polyglot-sql/sdk 0.12.1

Repro

transpile('SELECT * FROM UNNEST(@sites) AS site', Dialect.BigQuery, Dialect.DuckDB).sql[0];
transpile('SELECT x FROM t WHERE id IN UNNEST(@ids)', Dialect.BigQuery, Dialect.DuckDB).sql[0];

Actual

SELECT * FROM UNNEST(ABS(sites)) AS _t0(site)
SELECT x FROM t WHERE CASE WHEN ABS(ids) IS NULL OR ARRAY_LENGTH(ABS(ids)) = 0 THEN FALSE WHEN ARRAY_CONTAINS(ABS(ids), id) THEN TRUE WHEN id IS NULL OR ARRAY_LENGTH(ABS(ids)) <> LIST_COUNT(ABS(ids)) THEN NULL ELSE FALSE END

Expected

@sites / @ids are parsed as parameters (BigQuery has no @ absolute value operator) and emitted as a parameter placeholder in the target dialect. For reference, sqlglot emits UNNEST($sites) for DuckDB.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions