fix: is_select check for lowercase select with "WITH" clauses (#22370)

This commit is contained in:
Francisco Muniz de Paula Neto
2023-04-18 12:59:50 -03:00
committed by GitHub
parent 37a78b14be
commit e9b4022787
2 changed files with 24 additions and 2 deletions

View File

@@ -1008,6 +1008,28 @@ FROM foo f"""
assert sql.is_select()
def test_cte_is_select_lowercase() -> None:
"""
Some CTEs with lowercase select are not correctly identified as SELECTS.
"""
sql = ParsedQuery(
"""WITH foo AS(
select
FLOOR(__time TO WEEK) AS "week",
name,
COUNT(DISTINCT user_id) AS "unique_users"
FROM "druid"."my_table"
GROUP BY 1,2
)
select
f.week,
f.name,
f.unique_users
FROM foo f"""
)
assert sql.is_select()
def test_unknown_select() -> None:
"""
Test that `is_select` works when sqlparse fails to identify the type.