Add aggregate function support to BigQuery query_table API#306
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Extends the BigQuery query_table API to allow selecting aggregate column functions (COUNT, MAX, MIN) by introducing a typed Column model (identifier + optional function) and updating SQL generation accordingly.
Changes:
- Introduced
ColumnandColumnFunctioninplaid-stl, and changedQueryTableRequest.columnstoVec<Column>. - Updated the runtime BigQuery API to validate
Column.identifierand renderFUNCTION(\identifier`)` when a function is present. - Updated the runtime result-mapping loop to iterate over
Columnvalues instead of raw strings.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| runtime/plaid/src/apis/gcp/bigquery.rs | Accepts Column inputs, validates identifiers via Column.identifier, and renders aggregate function syntax in generated SQL. |
| runtime/plaid-stl/src/gcp/bigquery.rs | Adds the Column / ColumnFunction request types and updates the public query_table API surface to use them. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
michelemin
approved these changes
May 21, 2026
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.
Summary
Extends the
query_tableBigQuery API to support aggregate column functions (COUNT,MAX,MIN).Previously, columns were plain strings; they are now typed
Columnstructs that carry an optionalColumnFunction.When a function is specified, the generated SQL wraps the column identifier accordingly (e.g.,
COUNT(col)).Changes
Code
runtime/plaid-stl/src/gcp/bigquery.rs: AddedColumnstruct withidentifier: Stringandfunction: Option<ColumnFunction>; addedColumnFunctionenum (Count,Max,Min) withDisplayimpl; updatedQueryTableRequest.columnsfromVec<String>toVec<Column>; updatedquery_tablesignature to acceptVec<Column>.runtime/plaid/src/apis/gcp/bigquery.rs: Updatedbuild_query_stringparameter from&[String]to&[Column]; identifier validation and column-list construction now readcol.identifierand optionally emitFUNCTION(identifier)syntax.Rationale
Aggregate functions are a common need when querying tables. Encoding the function in the column type keeps the query-building logic centralized and validated server-side, avoiding raw SQL injection risks from caller-supplied function strings.
Security Considerations
Identifier validation now operates on
col.identifieras before, ensuring that only allowlisted or validated identifiers pass through. TheColumnFunctionenum is a closed set of known-safe SQL keywords rendered viaDisplay, so no user-supplied function names reach the generated SQL. No authentication or authorization surface changes.Breaking Changes
query_tableandQueryTableRequestnow requireVec<Column>instead ofVec<String>/impl Iterator<Item = impl Display>. Callers must be updated to constructColumnvalues; a plain column with no function isColumn { identifier: "col".into(), function: None }.