Skip to content

Parser fails if the first group by is a case statement #1308

Closed
@salonijuneja

Description

@salonijuneja

Hi, I am using parser to find underlying tables in a query.

Parser failing on query:

SELECT (CASE WHEN 'USD' = 'USD' THEN "column1"
ELSE "column2"
END) AS "testColumn1", "testColumn2", "testColumn3", count(*)
FROM test_schema.table_name
group by (CASE WHEN 'USD' = 'USD' THEN "column1" ELSE "column2" END), "testColumn2", "testColumn3"

It works on query, though not entirely correct (able to format sql but removing commas in group by columns)

SELECT (CASE WHEN 'USD' = 'USD' THEN "column1"
ELSE "column2"
END) AS "testColumn1", "testColumn2", "testColumn3", count(*)
FROM test_schema.table_name
group by "testColumn2", (CASE WHEN 'USD' = 'USD' THEN "column1" ELSE "column2" END), "testColumn3"

Both the SQLs are valid.
Tried out here

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions