Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadFromBigQuery doesn't support DATETIME type #20835

Open
damccorm opened this issue Jun 4, 2022 · 1 comment
Open

ReadFromBigQuery doesn't support DATETIME type #20835

damccorm opened this issue Jun 4, 2022 · 1 comment

Comments

@damccorm
Copy link
Contributor

damccorm commented Jun 4, 2022

ReadFromBigQuery with Avro export by documentation should produce a python native object i.e. datetime.datetime. 

> the BigQuery types for DATE, DATETIME, TIME, and TIMESTAMP will be exported as strings. This behavior is consistent with BigQuerySource. When using Avro exports, these fields will be exported as native Python types (datetime.date, datetime.datetime, datetime.datetime, and datetime.datetime respectively)

 

However, in practice this doesn't happen as BigQuery doesn't have a type that maps to Avro logical type.

 

Note: There is no logical type that directly corresponds to DATETIME, and BigQuery doesn't support any direct conversion from an Avro type into a DATETIME field.

 

I've also checked manually the AVRO export file that get exported to GCS. The logical type in Avro schema for BQ is datetime.

{"name":"datetime_col","type":["null",{"type":"string","logicalType":"datetime"}]}

 

Avro spec doesn't support datetime logical type[3] nor FastAvro library[4] that is used underneath to read the avro files.

 

Resources:

[1] https://beam.apache.org/releases/pydoc/2.29.0/apache_beam.io.gcp.bigquery.html#apache_beam.io.gcp.bigquery.ReadFromBigQuery

[2] https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-avro#logical_types

[3] https://avro.apache.org/docs/1.8.0/spec.html#Logical****Types|https://avro.apache.org/docs/1.8.0/spec.html#Logical****Types]

[4] https://fastavro.readthedocs.io/en/latest/logical_types.html

 

Imported from Jira BEAM-12375. Original Jira may contain additional context.
Reported by: sayatez.

@lostluck
Copy link
Contributor

lostluck commented Jun 9, 2022

This is definitely IO related, but it's not Go, given it's linking to python. Re-tagging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants