I am loading a datetime field from Pandas into a Google BigQuery DATETIME and get the following error:
google.api_core.exceptions.BadRequest: 400 Error while reading data, error message: Invalid datetime value 1594835746000000 for field 'my field name' of type 'INT64' (logical type 'TIMESTAMP_MICROS'): generic::out_of_range: Cannot return an invalid datetime value of 1594835746000000 microseconds relative to the Unix epoch. The range of valid datetime values is [0001-01-1 00:00:00, 9999-12-31 23:59:59.999999]
Inside Pandas the object is definitely a datetime.datetime object and has a valid date and when I take 1594835746000000 through https://www.epochconverter.com/ it returns a valid date.
I am loading the data into BigQuery by way of a call:
job_config = bigquery.LoadJobConfig(schema = schema_fieldlist)
job = bigquery_client.load_table_from_dataframe(df, f'{dataset}.{tablename}', job_config)
job.result()
where schema_fieldlist is an array and, for the field in question, is defined as:
bigquery.SchemaField('my field name', 'DATETIME')
I am not doing anything clever - can anyone advise if they have got this to work and how? I have seen other questions to do with returning timestamps and the change in valid range between standard and legacy SQL dialects