Skip to content

Postgres dialect cannot parse CASE expressions as arguments to json_object function #6655

@PressXtoChris

Description

@PressXtoChris

Search before asking

  • I searched the issues and found no similar issues.

What Happened

SqlFluff's postgres dialect fails to parse CASE expressions used in the json_object function when using the syntax introduced in Postgres 16

Expected Behaviour

SqlFluff should report no issues with this statement

Observed Behaviour

Line 1, Position 19: Found unparsable section: "(/n 'new': CASE/n WHEN s..."sqlfluff(PRS)

How to reproduce

SELECT json_object(
        'word': CASE
            WHEN str = '1' THEN 'One'
            WHEN str = '2' THEN 'Two'
            ELSE 'Unknown'
        END
    ) AS json_column
FROM first_table;

Dialect

postgres

Version

3.3.1

Configuration

[sqlfluff]
dialect = postgres
max_line_length = 120
exclude_rules = L039, L003, L071

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