Skip to content

bigquery.ArrayQueryParameter should be able to accept structs as elements of the array #2906

Closed

Description

@tswast

I commented that setting the types on array query parameters needs to be recursive since the array could contain structs. Note that arrays cannot contain arrays (the workaround is to contain a struct which can then contain an array).

It's not clear how one would do this with the current ArrayQueryParameter constructor.

bigquery.ArrayQueryParameter(
    name='myarray', 
    type='STRUCT',  # Note: this isn't enough information to construct the type object.
    values=?  # What would go here? Dictionaries? That doesn't match other uses of StructQueryParameter.
)

Maybe we need to change how array query parameters are constructed? Maybe it should look more like the StructQueryParameter constructor?

bigquery.ArrayQueryParameter(name, *sub_params)

It'd be a pain for scalar values and the names would have to be ignored on the sub_params if provided, but it's more flexible.

An aside

I'd actually love if we could get rid of all the XQueryParameter classes and use lists, dicts, and ints, floats, etc. But I see that it might be ambiguous for some types especially DATETIME (no time zone) vs TIMESTAMP (stored as UTC time).

Activity

  1. added
    api: bigquery
    type: bug
    type: feature request
    on Dec 28, 2016
  2. added
    priority: p1
    on Feb 28, 2017
  3. added a commit that references this issue on May 6, 2017
    3c59583
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: bigquerypriority: p1type: bugtype: feature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions