Skip to content

Support (non-legacy) SQL nested data types #2354

Closed
@dhermes

Description

@dhermes

STRUCT<t> and ARRAY<t> seem to be the types.

See #2342. h/t to @c0b for filing.


From #2585: Sample app that reproduces this

Stacktrace:

Traceback (most recent call last):
  File "simple_app.py", line 57, in <module>
    query_shakespeare()
  File "simple_app.py", line 47, in query_shakespeare
    page_token=page_token)
  File "lib/python2.7/site-packages/google/cloud/bigquery/query.py", line 401, in fetch_data
    rows_data = _rows_from_json(response.get('rows', ()), self.schema)
  File "lib/python2.7/site-packages/google/cloud/bigquery/_helpers.py", line 98, in _rows_from_json
    for item in cell['v']])
  File "lib/python2.7/site-packages/google/cloud/bigquery/_helpers.py", line 61, in _record_from_json
    for subfield, cell in zip(field.fields, value['f']):
KeyError: 'f'

Stepping into the debugger:

ipdb> value
{u'v': {u'f': [{u'v': u'hamlet'}, {u'v': u'5318'}]}}
ipdb> field.__dict__
{'field_type': u'RECORD', 'description': None, 'name': u'title', 'fields': [<google.cloud.bigquery.schema.SchemaField object at 0x7f4ba9227550>, <google.cloud.bigquery.schema.SchemaField object at 0x7f4ba9227690>], 'mode': u'REPEATED'}

(Added by @dhermes)

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.release blockingRequired feature/issue must be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions