Skip to content

Valid CASE statement causes parse error in Oracle dialect if WHEN condition uses brackets #7099

@adam-carruthers

Description

@adam-carruthers

Search before asking

  • I searched the issues and found no similar issues.

What Happened

A valid CASE statement had a parsing error when the WHEN clause used brackets.

This statement fails:

SELECT 
    CASE
        WHEN abc = 1 THEN NULL
        WHEN (
            defg = 2
            AND hijk = 3
        ) THEN NULL
    END AS result
FROM abc;

Expected Behaviour

It should not fail as it is valid

Observed Behaviour

Fails with a parse error "Could not parse"

How to reproduce

Using the SQL above with sqlfluff parse test.sql --dialect oracle

Dialect

Oracle

Version

3.4.2

Configuration

No config needed apart from --dialect oracle

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 workingoracle

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions