BigQuery data types define how Google BigQuery stores, processes, and validates each column’s values.
BigQuery supports primitive (INT64, FLOAT64, NUMERIC, BIGNUMERIC, BOOL, STRING, BYTES), date-time (DATE, DATETIME, TIME, TIMESTAMP), and complex (ARRAY, STRUCT, GEOGRAPHY, JSON) types. Each type controls storage format, valid operations, and function compatibility.
Teams often stage data in PostgreSQL before loading to BigQuery or query BigQuery from Postgres FDW. Aligning types avoids truncation, rounding, or cast failures during ETL and federated queries.
INT64 → BIGINT, FLOAT64 → DOUBLE PRECISION, NUMERIC → NUMERIC(38,9), STRING → TEXT, BOOL → BOOLEAN, BYTES → BYTEA, DATE/TIME/TIMESTAMP map to their PostgreSQL counterparts, GEOGRAPHY → GEOGRAPHY (PostGIS), JSON → JSONB.
Use CREATE TABLE or ALTER TABLE in PostgreSQL with matching types. When loading with the BigQuery postgres_translator tool, supply a JSON schema that mirrors BigQuery’s definitions.
Yes—declare NUMERIC(10,2) in PostgreSQL to mirror BigQuery NUMERIC for currency. This prevents floating-point drift when transferring order totals.
PostgreSQL has native ARRAY and composite types. Alternatively, serialize to JSONB for flexibility, then unpack with -> operators when querying.
Store all times in UTC TIMESTAMP WITH TIME ZONE in PostgreSQL. BigQuery TIMESTAMP is always UTC, so this avoids implicit shifts during export/import.
1) Cast columns to their final BigQuery equivalents in SELECT. 2) Export to CSV/Avro/Parquet. 3) Supply an explicit BigQuery schema matching those types. Validate with bq load --autodetect=false.
Choose the narrowest type that still holds all values. Smaller columns speed scans in both engines. For example, store stock as INT64 not NUMERIC.
open-source pg2bq
, Airbyte, and Fivetran generate BigQuery schemas from PostgreSQL catalogs, flagging mismatches before runtime errors occur.
No native UUID type exists; store as STRING in BigQuery and cast back to UUID in PostgreSQL.
BigQuery GEOGRAPHY and PostGIS GEOGRAPHY share WKT/WKB formats. Export/import as text to preserve shapes.
BigQuery NUMERIC supports 38 digits with 9 decimal places. PostgreSQL NUMERIC can exceed this, so truncate before loading.