BigQuery: Support inline aggregate WHERE filter (AGG(expr WHERE cond))#2404
Open
moshap-firebolt wants to merge 1 commit into
Open
BigQuery: Support inline aggregate WHERE filter (AGG(expr WHERE cond))#2404moshap-firebolt wants to merge 1 commit into
AGG(expr WHERE cond))#2404moshap-firebolt wants to merge 1 commit into
Conversation
GoogleSQL allows an aggregate call to carry an inline WHERE filter, e.g. `COUNT(* WHERE cond)`, `SUM(x WHERE cond)`, `ARRAY_AGG(x WHERE cond ORDER BY y)`. It is the in-argument spelling of the standard `AGG(expr) FILTER (WHERE cond)`. Add `FunctionArgumentClause::Where(Expr)` and parse it in `parse_function_argument_list` for the BigQuery and Generic dialects (before ORDER BY / LIMIT / HAVING), with `Display` and span support. Covered by a new `parse_aggregate_with_where_filter` test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GoogleSQL allows an aggregate call to carry an inline
WHEREfilter, e.g.COUNT(* WHERE cond),SUM(x WHERE cond),ARRAY_AGG(x WHERE cond ORDER BY y).It is the in-argument spelling of the standard
AGG(expr) FILTER (WHERE cond).Changes
FunctionArgumentClause::Where(Expr).parse_function_argument_listfor theBigQueryandGenericdialects, before
ORDER BY/LIMIT/HAVING.DisplayrendersWHERE <expr>; span is computed from the predicate.parse_aggregate_with_where_filterintests/sqlparser_bigquery.rs.Docs: https://cloud.google.com/bigquery/docs/reference/standard-sql/aggregate_functions