bigquery.utils¶
Attributes¶
Functions¶
|
Flatten response objects into something we can actually work with. |
|
Parse a given field back to a Python object. |
|
Convert a query response to a dictionary. |
Module Contents¶
- bigquery.utils.log¶
- bigquery.utils.utc¶
- bigquery.utils.flatten(x)¶
Flatten response objects into something we can actually work with.
The API returns data of the form:
{‘f’: [{‘v’: …}]}
to indicate groupings of fields and their potential for having multiple values. We want those to just be plain old objects.
- Parameters:
x (Any)
- Return type:
Any
- bigquery.utils.parse(field, value)¶
Parse a given field back to a Python object.
This is often trivial: convert the value from a string to the type specified in the field’s schema. There’s a couple caveats we’ve identified so far, though:
NULLABLE fields should be handled specially, eg. so as not to accidentally convert them to the schema type.
REPEATED fields are nested a biot differently than expected, so we need to flatten first, then convert.
Field = Dict[str, Union[str, ‘Field’]], but wow is that difficult to represent in a backwards-enough compatible fashion.
- Parameters:
field (Dict[str, Any])
value (Any)
- Return type:
Any
- bigquery.utils.query_response_to_dict(response)¶
Convert a query response to a dictionary.
API responses for job queries are packed into a difficult-to-use format. This method deserializes a response into a List of rows, with each row being a dictionary of field names to the row’s value.
This method also handles converting the values according to the schema defined in the response (eg. into builtin python types).
- Parameters:
response (Dict[str, Any])
- Return type:
List[Dict[str, Any]]