BigQuery reference
BigQuery conversion functions
Conversion functions change a value from one type to another. CAST fails the whole query on a bad value; SAFE_CAST returns NULL instead, which is usually what you want on raw data.
Functions in this category
| Function | What it does |
|---|---|
| CAST | CAST(expression AS type) converts a value to another data type, such as STRING to INT64 or TIMESTAMP to DATE, and fails the whole query if any value can't be converted. |
| PARSE_NUMERIC | PARSE_NUMERIC(string) converts a STRING to NUMERIC and, unlike CAST, accepts thousands separators, spaces and a trailing minus sign, as in '1,234.50' or '75.10-'. |
| SAFE_CAST | SAFE_CAST(expression AS type) works like CAST but returns NULL instead of failing when a value can't be converted. |
More of the BigQuery reference
Date functionsDatetime functionsTimestamp functionsString functionsAggregate functionsWindow functionsArray functionsJSON functionsConditional expressionsMathematical functionsHash and utility functionsQuery syntaxDDL statementsDML statementsScripting and data movementINFORMATION_SCHEMAError messagesBigQuery pricingPricing calculator
