Skip to content

BigQuery: Parse a WINDOW clause after pipe SELECT and EXTEND - #3092

Open
VanshajPoonia wants to merge 3 commits into
apache:mainfrom
VanshajPoonia:fix/pipe-window-3042
Open

VanshajPoonia wants to merge 3 commits into
apache:mainfrom
VanshajPoonia:fix/pipe-window-3042

Conversation

@VanshajPoonia

Copy link
Copy Markdown

Closes #3042

Dialects: BigQuery

BigQuery lets |> SELECT and |> EXTEND end with a WINDOW name AS (...) clause (https://cloud.google.com/bigquery/docs/reference/standard-sql/pipe-syntax#extend_pipe_operator). This failed before:

SELECT * FROM t |> EXTEND sum(v) OVER w AS s WINDOW w AS (PARTITION BY k)
-- Expected: end of statement, found: WINDOW

PipeOperator::Select and PipeOperator::Extend now have a named_window field, the same as Select::named_window. The parser reuses parse_named_window after the select items and Display prints the clause back. Two public variants gain a field, so matches without .. need the new field.

One thing is left as is which is that if the last select item has no alias, WINDOW is read as its alias, the same as a plain SELECT a WINDOW w AS (...) on main today. Changing that touches the column alias rule for every dialect and that's why I would like to ask before doing it.

AI disclosure: AI assistance was used to write the change and the tests. I read the whole diff and checked the tests fail without the fix and wrote this PR description myself.

BigQuery allows `|> SELECT ... WINDOW w AS (...)` and the same on
`|> EXTEND`. The parser stopped after the select items and failed with
"Expected: end of statement, found: WINDOW".

PipeOperator::Select and PipeOperator::Extend now keep a named_window
list, parsed with parse_named_window like a normal SELECT and printed
back after the items.

Closes apache#3042
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pipe syntax: |> SELECT and |> EXTEND do not parse a WINDOW clause

1 participant