feat(bigquery): add support for explicit query parameter type#6596
feat(bigquery): add support for explicit query parameter type#6596alvarowolfx merged 15 commits intogoogleapis:mainfrom
Conversation
|
I changed to a slight different approach, having some specific struct and interface that can be used explicitly or with the current QueryParameter struct. |
| func (p QueryParameter) toBQ() (*bq.QueryParameter, error) { | ||
| // QueryParameterValue is a go type for representing a explicit typed BigQuery Query Parameter. | ||
| type QueryParameterValue struct { | ||
| Type StandardSQLDataType |
There was a problem hiding this comment.
Document these fields as appropriate.
| } | ||
|
|
||
| func (p QueryParameter) toBQ() (*bq.QueryParameter, error) { | ||
| // QueryParameterValue is a go type for representing a explicit typed BigQuery Query Parameter. |
There was a problem hiding this comment.
I'm still on the fence about the name due to the collision with the API, but it's a reasonable name otherwise.
Should we document the behavior for nested types as part of the type description? Specifically that you need to fully specify types and values for complex params?
shollyman
left a comment
There was a problem hiding this comment.
I think the only work remaining is to flesh out the documentation for QueryParameterValue (and it's fields) and ship it. Approving contingent on that.
shollyman
left a comment
There was a problem hiding this comment.
Looks good, and I like the explicit examples of usage. Thanks for putting this together!
🤖 I have created a release *beep* *boop* --- ## [1.42.0](bigquery/v1.41.0...bigquery/v1.42.0) (2022-09-21) ### Features * **bigquery/analyticshub:** Start generating apiv1 ([#6707](#6707)) ([feb7d7d](feb7d7d)) * **bigquery/datapolicies:** Start generating apiv1beta1 ([#6697](#6697)) ([f5443e8](f5443e8)) * **bigquery/reservation/apiv1beta1:** add REST transport ([f7b0822](f7b0822)) * **bigquery/storage/managedwriter:** Define append retry predicate ([#6650](#6650)) ([478b8dd](478b8dd)) * **bigquery/storage:** add proto annotation for non-ascii field mapping ([ec1a190](ec1a190)) * **bigquery:** Add reference file schema option for federated formats ([#6693](#6693)) ([3d26091](3d26091)) * **bigquery:** Add support for explicit query parameter type ([#6596](#6596)) ([d59b5b2](d59b5b2)), refs [#4704](#4704) ### Bug Fixes * **bigquery/connection:** integrate gapic-generator-python-1.4.1 and enable more py_test targets ([ec1a190](ec1a190)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Allow users to pass query parameter with an explicit data types instead of relying just on reflection of Go types. Right now the data type that is affect by this change is
*big.Rat, which before was only converted toNUMERICwith 9 digits, and now can be send as aBIGNUMERIC.This adds two methods:
NewScalarQueryParameter(name string, paramType FieldType, value interface{}) QueryParameterNewArrayQueryParameter(name string, paramType FieldType, value interface{}) QueryParameterExample usage:
I'm still evaluating if we need something like
NewStructQueryParameterto pass a list of QueryParameters with explicit data types for each field.Most of this was inspired by the Python implementation that has the same kind of methods for creating query parameters.
Resolves #4704