Skip to content

Bigquery fail - Error when use function STRING_AGG with IGNORE NULLS #142

@lveras

Description

@lveras

Error when use function STRING_AGG with IGNORE NULLS

Query sample:

WITH agg_phones AS (
    SELECT
        m.stone_code,
        ct.name AS type,
        c.contact_name AS name,
        ARRAY_AGG(DISTINCT email IGNORE NULLS) AS email,
        ARRAY_AGG(DISTINCT c.mobile_phone_number IGNORE NULLS) AS m_phone,
        ARRAY_AGG(DISTINCT c.phone_number IGNORE NULLS) AS phone,
        MAX(c.last_modified_date) as last_modified_date
    FROM
        ...
)
​
SELECT
    stone_code,
    type,
    name,
    email,
    ARRAY(SELECT DISTINCT phones
        FROM
            UNNEST(ARRAY_CONCAT(m_phone, phone)) AS phones
    ) AS phones_array,
    last_modified_date,
    CURRENT_TIMESTAMP AS processed_at
FROM
    agg_phones

How to reproduce?

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