How to Cast Data Types in BigQuery

Last updated July 26, 2026 · By the SaturnSQL team

CAST(value AS type) converts between types and errors on invalid input. SAFE_CAST does the same conversion but returns NULL instead of failing the query.

SELECT CAST(order_count AS STRING) AS order_count_text,
       CAST('42' AS INT64) AS order_count_number
FROM orders;

SAFE_CAST for messy input

When a column mixes valid and invalid values, SAFE_CAST lets the query keep running and turns bad rows into NULL instead of aborting the whole job.

SELECT raw_value, SAFE_CAST(raw_value AS INT64) AS parsed_value
FROM staging_import;

String to date

SELECT SAFE_CAST(signup_date_text AS DATE) AS signup_date
FROM staging_import;

Run this in SaturnSQL

SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.

Try it free

Related BigQuery guides