Skip to content

Limitations and best practices

This page summarizes supported features, limitations, and best practices.

Quick reference

FeatureSupportedNotes
SELECT, WHERE, GROUP BY, HAVING, ORDER BY, LIMITYes
Column aliases (AS)Yes
Expressions (CASE, CAST, LIKE, BETWEEN, IN, arithmetic)YesFull expression support
EXPLAINYesReturns execution plan
163 scalar functionsYesMath, string, datetime, regex, crypto, array, map, struct
33 aggregate functionsYesBasic, approximate, statistical, bitwise, boolean, positional
Approximate aggregatesYesapprox_distinct, approx_median, approx_percentile_cont, approx_top_k
Struct / Array / Map column typesYesBracket notation, get_field(), array functions, map functions
CTEs (WITH ... AS)YesSingle-table only. No JOINs or cross-table references within CTEs.
JOINsNoSingle-table only
SubqueriesNo
Window functions (OVER)No
SELECT DISTINCTNoUse approx_distinct
OFFSETNo
UNION / INTERSECT / EXCEPTNo
INSERT / UPDATE / DELETENoRead-only
CREATE / DROP / ALTERNoRead-only

For the full SQL syntax, refer to the SQL reference.


Unsupported SQL features

FeatureError
JOINs (any type)unsupported feature: JOIN operations are not supported
Multi-table CTEs (JOINs or cross-table references within WITH)Single-table CTEs are supported
Subqueries (FROM, WHERE, scalar)unsupported feature: subqueries
SELECT DISTINCTunsupported feature: SELECT DISTINCT is not supported
OFFSETunsupported feature: OFFSET clause is not supported
UNION / INTERSECT / EXCEPTSet operations not supported
Window functions (OVER)unsupported feature: window functions (OVER clause)
INSERT / UPDATE / DELETEonly read-only queries are allowed
CREATE / DROP / ALTERonly read-only queries are allowed
UNNEST / PIVOT / UNPIVOTNot supported
Wildcard modifiers (ILIKE, EXCLUDE, EXCEPT, REPLACE, RENAME on *)Not supported
LATERAL VIEW / QUALIFYNot supported

Unsupported expression patterns

PatternAlternative
func(DISTINCT ...) on any aggregateUse approx_distinct for counting
PERCENTILE_CONT / PERCENTILE_DISCUse approx_percentile_cont
MEDIANUse approx_median
ARRAY_AGGNo alternative (unsupported for memory safety)
STRING_AGGNo alternative (unsupported for memory safety)
Scalar subqueries (SELECT ... WHERE x = (SELECT ...))Not supported
EXISTS (SELECT ...)Not supported
IN (SELECT ...)Use IN (value1, value2, ...) with a literal list

Runtime constraints

ConstraintDetails
Single table per queryQueries must reference exactly one table. No JOINs, no subqueries. CTEs may reference a single table.
Partitioned Iceberg tables onlyUnpartitioned tables are not supported.
Parquet format onlyNo CSV, JSON, or other formats.
Read-onlyR2 SQL is a query engine, not a database. No writes.
now() / current_time() precisionQuantized to 10ms boundaries and forced to UTC.

Common error codes

CodeMeaning
40003Invalid SQL syntax
40004Invalid query (unsupported feature, unknown column, type mismatch)
80001Edge service connection failure (retry)

Best practices

  1. Always include time-range filters in WHERE to limit data scanned.
  2. Use specific column names instead of SELECT * for better performance.
  3. Use LIMIT to control result set size.
  4. Use approximate aggregation functions (approx_distinct, approx_median, approx_percentile_cont) instead of exact alternatives on large datasets.
  5. Enable compaction in R2 Data Catalog to reduce the number of files scanned per query.
  6. Use EXPLAIN to inspect the execution plan and verify predicate pushdown.