BigQuery SQL translation reference
This document details the similarities and differences in SQL syntax between BigQuery and ClickHouse.
Data types
ClickHouse offers more granular precision than BigQuery for numerics.
Where BigQuery has INT64, NUMERIC, BIGNUMERIC, and FLOAT64,
ClickHouse provides multiple integer, decimal, and float widths so storage
and memory can be tuned to the actual range of the data.
When several ClickHouse types map to a single BigQuery type, pick the smallest that fits and consider appropriate codecs for further compression.
| BigQuery | ClickHouse | Notes |
|---|---|---|
ARRAY | Array(t) | |
BIGNUMERIC | Decimal256(S) | |
BOOL | Bool | |
BYTES | String or FixedString(N) | |
DATE | Date or Date32 | Date (2-byte, 1970-2149) for typical analytical data; Date32 (4-byte, 1900-2299) to match BigQuery's full range |
DATETIME | DateTime or DateTime64(p) | Use DateTime64(p) for sub-second precision |
FLOAT64 | Float64 | |
GEOGRAPHY | Geo data types | |
INT64 | UInt8 … UInt256 / Int8 … Int256 | Pick the smallest signed or unsigned variant that fits the value range |
INTERVAL | No equivalent | Use the INTERVAL expression or date/time arithmetic functions |
JSON | JSON or String | JSON is preferred; String with JSONExtract* accessors works as a fallback |
NUMERIC | Decimal(P, S) | Sized variants Decimal32(S) / Decimal64(S) / Decimal128(S) are also available |
RANGE | No equivalent | Store (start, end) columns or a Tuple(start, end) |
STRING | String | Optionally wrap in LowCardinality(String) for columns with few distinct values (enums, status codes, country codes). String functions are byte-based; the String family has UTF8 variants where relevant |
STRUCT | Tuple or Nested | Flattened sibling columns are often more performant in ClickHouse; use Tuple / Nested for named fields when the nested shape is load-bearing |
TIME | No equivalent | Carry a DateTime64 and extract via formatDateTime |
TIMESTAMP | DateTime64(6, 'UTC') | Use for microsecond-precision UTC parity |
DDL statements
Schemas and databases
| BigQuery | ClickHouse |
|---|---|
BigQuery datasets map to ClickHouse databases. | |
Location is a service-level decision in ClickHouse Cloud. | |
Add | |
ClickHouse drops tables in the database unconditionally; there is no | |
Tables
| BigQuery | ClickHouse |
|---|---|
An engine and an | |
BigQuery partitioning expects a single date/timestamp column; ClickHouse accepts an arbitrary expression. ClickHouse partitions are a storage-organisation feature — not a substitute for | |
BigQuery clustering colocates data; in ClickHouse the equivalent is the table's | |
Both copy the schema only; ClickHouse also copies engine and | |
Engine and | |
ClickHouse temporary tables are session-scoped and require an explicit engine (commonly | |
ClickHouse exposes external storage through table engines such as | |
Views and materialized views
| BigQuery | ClickHouse |
|---|---|
Standard logical views; no storage in either engine. | |
ClickHouse materialized views are incremental insert-time triggers that write into a target table. For an aggregate MV, use | |
ClickHouse also supports refreshable materialized views for full-refresh semantics. | |
Indexes, functions, and procedures
| BigQuery | ClickHouse |
|---|---|
ClickHouse full-text indexes accelerate | |
ClickHouse UDFs are expression-only. For complex logic, use the SQL-defined-function or executable-UDF patterns. | |
No equivalent | |
ClickHouse has no JavaScript or Python UDFs in standard SQL; use executable UDFs at the server level. | |
No equivalent | |
ClickHouse has no stored procedures; orchestrate from a client (Python, Go, etc.) or compose into a SQL function. | |
DML
Insert operations
| BigQuery | ClickHouse |
|---|---|
Update operations
| BigQuery | ClickHouse |
|---|---|
ClickHouse mutates asynchronously by default. For synchronous, in-place updates use lightweight updates: | |
Delete operations
| BigQuery | ClickHouse |
|---|---|
ClickHouse's lightweight delete marks rows for removal; physical removal happens at the next merge. For bulk historical cleanup prefer use of TTL. | |
Merge operations
| BigQuery | ClickHouse |
|---|---|
No equivalent | |
ClickHouse has no equivalent | |
DCL
Grants
| BigQuery | ClickHouse |
|---|---|
BigQuery binds to IAM principals (users, groups, service accounts). ClickHouse binds to SQL-level users and roles created with | |
Roles
| BigQuery | ClickHouse |
|---|---|
IAM-managed via console / | |
IAM-managed via console / | |
IAM-managed via console / | |
Syntax
Query syntax
| BigQuery | ClickHouse |
|---|---|
ClickHouse | |
ClickHouse also supports | |
ClickHouse generally requires | |
| |
ClickHouse rejects bare | |
Use | |
ClickHouse has no | |
ClickHouse | |
No equivalent | |
ClickHouse does not provide row-level time travel. Patterns include | |
ClickHouse has no | |
ClickHouse has no | |
Pipe syntax
BigQuery's pipe syntax
chains transformations with the |> operator. ClickHouse has no equivalent;
each pipe operator desugars to a clause in standard SQL. Subqueries or CTEs
are the readable way to chain stages.
| BigQuery | ClickHouse |
|---|---|
ClickHouse | |
Pipes compose left-to-right; in ClickHouse, layer clauses or use a CTE for readability. | |
Procedural language
ClickHouse SQL is not a procedural language. Variables, loops, statement-level
IF / CASE, and stored procedures have no first-class equivalents;
orchestrate multi-step logic from a client library (Python, Go, JavaScript,
etc.) or use parameterized views
for templated queries.
| BigQuery | ClickHouse |
|---|---|
client-side variable, or | |
client-side; | |
multi-statement scripts are run by the client, not the server | |
expression form | |
expression form | |
no equivalent — use a client-driven loop | |
no equivalent | |
iterate over query results client-side | |
| no equivalent |
no stored procedures | |
client-side prepared statements | |
multi-statement transactions are experimental — see transactions roadmap |
Operators
| BigQuery | ClickHouse | Notes |
|---|---|---|
|
|
|
Integer division. | ||
|
| |
| same | |
| same | |
Inclusive of both bounds. | ||
same | ||
ClickHouse also offers | ||
Conditional expressions
| BigQuery | ClickHouse |
|---|---|
Conversion
| BigQuery | ClickHouse |
|---|---|
BigQuery | |
Each numeric type has | |
Specify scale explicitly in ClickHouse. | |
Functions
Array functions
Compared to BigQuery's roughly eight array functions, ClickHouse has more
than 80 built-in array functions.
The idiomatic pattern is to aggregate row values into an array with
groupArray,
transform with higher-order lambda functions
(arrayMap,
arrayFilter,
arrayZip), and
optionally expand back to rows with
arrayJoin. Because of this, many
transformations BigQuery expresses by round-tripping through
UNNEST
collapse to a single function call in ClickHouse.
| BigQuery | ClickHouse |
|---|---|
ClickHouse | |
Aggregate functions
BigQuery exposes roughly 18 aggregate functions plus a handful of approximate aggregates. ClickHouse ships more than 150 aggregate functions and adds combinators — suffixes such as -If, -Array, -Map, -ForEach, -Merge, and -State — that compose with any aggregate to extend its behaviour across data shapes or to use it inside materialized views.