Search code examples
google-bigquerygoogle-cloud-spanner

How to convert the spanner TIMESTAMP to BigQuery TIMESTAMP?


I am trying to copy some tables from Spanner to BigQuery.

I dumped Spanner database in csv file and when I try to upload that csv to BigQuery it is throwing error of the timestamp format.

Here they mentioned limitation of BigQuery TIMESTAMP.

How do I convert spanner TIMESTAMP to BigQuery TIMESTAMP?


Solution

  • I converted timestamp to epoch time like this

    SELECT myTime , FORMAT_TIMESTAMP("%s",  myTime, "America/Los_Angeles") FROM MyTable
    
    

    and it worked.