Skip to content

Unparseable section VARIADIC #6784

@alpha-beta-soup

Description

@alpha-beta-soup

Search before asking

  • I searched the issues and found no similar issues.

What Happened

I get an unparseable section 'VARIADIC ARRAY_REMOVE(ARRAY[ for

range_merge(datemultirange(
    VARIADIC ARRAY_REMOVE(ARRAY[
        a.source_date,
        b.source_date,
        c.source_date
    ], NULL)
))::daterange, -- source_date

datemultirange does not accept an array, so VARIADIC declares the argmode so I can pass an array. The alternative is much uglier, and gets worse if I want to add more:

range_merge(
    CASE 
        WHEN a.source_date IS NOT NULL AND b.source_date IS NOT NULL AND c.source_date IS NOT NULL
        THEN datemultirange(a.source_date, b.source_date, c.source_date)
        WHEN a.source_date IS NOT NULL AND b.source_date IS NOT NULL
        THEN datemultirange(a.source_date, b.source_date)
        WHEN a.source_date IS NOT NULL AND c.source_date IS NOT NULL
        THEN datemultirange(a.source_date, c.source_date)
        WHEN b.source_date IS NOT NULL AND c.source_date IS NOT NULL
        THEN datemultirange(b.source_date, c.source_date)
        WHEN a.source_date IS NOT NULL THEN datemultirange(a.source_date)
        WHEN b.source_date IS NOT NULL THEN datemultirange(b.source_date)
        WHEN c.source_date IS NOT NULL THEN datemultirange(c.source_date)
        ELSE NULL
    END
)::daterange AS source_date

cf. #4986 (possibly)

Expected Behaviour

My use here is valid (PostgreSQL dialect) so it seems like a parser bug. I expect this to be parsed without error.

Observed Behaviour

unparseable section 'VARIADIC ARRAY_REMOVE(ARRAY[

How to reproduce

SELECT range_merge(datemultirange(
    VARIADIC ARRAY_REMOVE(ARRAY[
        a.source_date,
        b.source_date,
        c.source_date
    ], NULL)
))::daterange
FROM a
FULL OUTER JOIN b USING (h3_index)
FULL OUTER JOIN c USING (h3_index)

Dialect

postgresql

Version

v3.3.1

Configuration

I can reproduce this with the default settings.

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpostgresIssues relating to the Postgres dialect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions