[Feature Request]: Add support for BigQuery structs in BigQueryIO with BEAM_ROW output type
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 4.7k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 196
Description
### What would you like to happen?
The BigQuery to Python type conversion in [bigquery_schema_tools.py](https://github.com/apache/beam/blob/master/sdks/python/apache_beam/io/gcp/bigquery_schema_tools.py) currently only support primitive types. I would like to contribute by adding support for `REPEATED RECORD` fields. Since I am new to this project I would be thankful for some support in this.
@svetakvsundhar can you help me understand if the following can be achieved:
- change the logic in https://github.com/apache/beam/blob/5223ab466e78f403680a22036d3a769897d0cf9d/sdks/python/apache_beam/io/gcp/bigquery_schema_tools.py#L56 to
```python
for i in range(len(the_schema['fields'])):
if the_schema['fields'][i]['type'] in BIG_QUERY_TO_PYTHON_TYPES:
typ = bq_field_to_type(
the_schema['fields'][i]['type'], the_schema['fields'][i]['mode'])
elif the_schema['fields'][i]['type'] == "RECORD":
typ = generate_user_type_from_bq_schema(the_schema['fields'[i])
else:
raise ValueError(
f"Encountered "
f"an unsupported type: {the_schema['fields'][i]['type']!r}")
```
- add support for nested records in https://github.com/apache/beam/blob/5223ab466e78f403680a22036d3a769897d0cf9d/sdks/python/apache_beam/typehints/schemas.py#L513 since it is called in https://github.com/apache/beam/blob/5223ab466e78f403680a22036d3a769897d0cf9d/sdks/python/apache_beam/io/gcp/bigquery_schema_tools.py#L81
I think a similar feature request was implemented in the BigQuery->Avro->Beam conversion for the java sdk: [Pull request 9089](https://github.com/apache/beam/pull/9089).
### Issue Priority
Priority: 2 (default / most feature requests should be filed as P2)
### Issue Components
- [X] Component: Python SDK
- [ ] Component: Java SDK
- [ ] Component: Go SDK
- [ ] Component: Typescript SDK
- [X] Component: IO connector
- [ ] Component: Beam examples
- [ ] Component: Beam playground
- [ ] Component: Beam katas
- [ ] Component: Website
- [ ] Component: Spark Runner
- [ ] Component: Flink Runner
- [ ] Component: Samza Runner
- [ ] Component: Twister2 Runner
- [ ] Component: Hazelcast Jet Runner
- [ ] Component: Google Cloud Dataflow Runner
Contributor guide
Assessment
This issue has not been assessed yet.