Skip to content
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

BigQuery: Add support for select expr star #1680

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

iffyio
Copy link
Contributor

@iffyio iffyio commented Jan 23, 2025

Adds support for wildcard expression on arbitrary
expressions in select lists.

Example:

SELECT l.LOCATION[offset(0)].* FROM l

https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#select_expression_star

@iffyio iffyio force-pushed the bigquery-select-expr-star branch from 9517f5d to c666d8d Compare January 27, 2025 07:39
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @iffyio -- this looks good to me. What mind blowing syntax

/// Expression is an object name.
/// e.g. `alias.*` or even `schema.table.*`
ObjectName(ObjectName),
/// Select star on an arbitrary expression.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

// Identifier wildcard expansion.
let select = dialects.verified_only_select("SELECT foo.bar.* FROM T");
let SelectItem::QualifiedWildcard(SelectItemQualifiedWildcardKind::ObjectName(object_name), _) =
only(&select.projection)
Copy link
Contributor

Choose a reason for hiding this comment

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

only is a neat trick

);

// Arbitrary compound expression with wildcard expansion.
let select = dialects.verified_only_select("SELECT foo - bar.* FROM T");
Copy link
Contributor

Choose a reason for hiding this comment

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

this is kind of wild

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😅 thankfully the query isn't semantically valid, maybe the test is misleading in that sense, I added it only to verify that the parser accepts arbitrary expressions and wildcard on variables, but as far as binary operators specifically combined with the wildcard syntax wouldn't have meaning in BigQuery either

Adds support for wildcard expression on arbitrary
expressions in select lists.

Example:
```sql
SELECT l.LOCATION[offset(0)].* FROM l
```
https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#select_expression_star
@iffyio iffyio force-pushed the bigquery-select-expr-star branch from c666d8d to c0f00fd Compare January 28, 2025 09:25
@iffyio iffyio merged commit 8de3a62 into apache:main Jan 28, 2025
9 checks passed
@iffyio iffyio deleted the bigquery-select-expr-star branch January 28, 2025 10:33
Vedin pushed a commit to Embucket/datafusion-sqlparser-rs that referenced this pull request Feb 3, 2025
Vedin pushed a commit to Embucket/datafusion-sqlparser-rs that referenced this pull request Feb 3, 2025
Vedin added a commit to Embucket/datafusion-sqlparser-rs that referenced this pull request Feb 3, 2025
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.

2 participants