I have a table in BigQuery with Xday, Xmonth, and Xyear columns but the data was user generated and apparently done without adequate input validation so some of it is nonsense. It's easy enough to do things like Xday between 1 and 31, but I still get an error when doing date(Xyear, Xmonth, Xday) if for example someone put in February 30th.

Is there some way I can either validate the date prior to doing the conversion to the date type or a way to just toss out the rows causing errors instead of throwing the exception?

有帮助吗?

解决方案

You can add the prefix SAFE so the DATE function returns NULL instead of throwing an error.

https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators

许可以下: CC-BY-SA归因
不隶属于 dba.stackexchange
scroll top