Search code examples
google-bigquerytimestamp

Bigquery error about unable to cast timestamp string to a timestamp when trying to insert it


I am trying to insert this timestamp "2024-07-02T10:46:58.108707769" into a TIMESTAMP column in bigquery, but I get the error Query error: Could not cast literal "2024-07-02T10:46:58.108707769" to type TIMESTAMP, I do not understand what is wrong with this timestamp value as in some online tools it is valid, can someone help clarify?


Solution

  • As per the Gcp documentation Up to 6 decimal places (microsecond precision) are preserved.

    You can describe TIMESTAMP data types as either UNIX timestamps or calendar datetimes. BigQuery stores TIMESTAMP data internally as a UNIX timestamp with microsecond precision. Check this documentation and You can also check this bigQuery not supporting milliseconds timestamps .As @ BugsOverflow already mentioned you are using nanosecond timestamp , you have to convert to microseconds before the insertion.