Skip to content

Support DISTINCT AS { STRUCT | VALUE } for BigQuery #1880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 11, 2025

Conversation

bombsimon
Copy link
Contributor

According to the query syntax at
https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#select_list you can combine [ { ALL | DISTINCT } ] with [ AS { STRUCT | VALUE } ]:

SELECT
  [ WITH differential_privacy_clause ]
  [ { ALL | DISTINCT } ]
  [ AS { STRUCT | VALUE } ]
  select_list

This adds support to parse DISTINCT or ALL as the first keyword after SELECT and adds two new variants to the ValueTableMode if defined.

According to the query syntax at
https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#select_list
you can combine `[ { ALL | DISTINCT } ]` with `[ AS { STRUCT | VALUE } ]`:

```sh
SELECT
  [ WITH differential_privacy_clause ]
  [ { ALL | DISTINCT } ]
  [ AS { STRUCT | VALUE } ]
  select_list
```

This adds support to parse `DISTINCT` or `ALL` as the first keyword
after `SELECT` and adds two new variants to the `ValueTableMode` if
defined.
@bombsimon bombsimon force-pushed the distinct-as-struct branch from 6408fc9 to 6a774da Compare June 11, 2025 13:38
This does, similar to regular `ALL`, not store that state on the
`Select` struct so it's not tested as a `verified_stmt`.
@bombsimon bombsimon requested a review from iffyio June 11, 2025 15:34
Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @bombsimon!
cc @alamb

@iffyio iffyio merged commit 703ba2c into apache:main Jun 11, 2025
9 checks passed
@iffyio iffyio deleted the distinct-as-struct branch June 11, 2025 16:12
@alamb
Copy link
Contributor

alamb commented Jun 12, 2025

woohoo

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.

3 participants