R2 SQL now supports over 190 new functions, expressions, and complex types
Key Points
- Adds 163 scalar and 33 aggregate functions
- Supports CASE, CTEs, EXPLAIN, and full expression support
- Struct/array/map access with 46 array functions
Summary
R2 SQL (Cloudflare's serverless, distributed analytics engine for querying Apache Iceberg tables in R2 Data Catalog) now supports an expanded SQL grammar so you can run richer analytical queries in-place. This release adds CASE expressions, column aliases in all clauses, arithmetic and casting across clauses, 163 scalar functions, 33 aggregate functions, EXPLAIN, Common Table Expressions (CTEs), and full struct/array/map access including 46 array functions.
Key Points
- New functions: 163 scalar functions (math, string, datetime, regex, crypto, encoding, type-inspection) and 33 aggregate functions (variance, stddev, correlation, regression, bitwise, boolean, positional, etc.).
- Expressions & syntax:
CASE(searched and simple), column aliases (AS) in all clauses, arithmetic inSELECT,WHERE,GROUP BY,HAVING, andORDER BY, plusCAST/TRY_CAST/::shorthand andEXTRACT. - Complex types: bracket notation for struct fields, map key/value extraction, and 46 array functions (e.g.,
array_has,array_to_string). - CTEs:
WITH ... ASand chained CTEs are supported. Limitation: all CTEs must reference the same single table. - Tools & workflow:
EXPLAINis available for query-plan inspection; queries run directly on Iceberg tables in R2 Data Catalog so exporting data is not required. - Recommended action: review the SQL reference for the full function list and the Limitations and best practices guide before authoring or migrating complex queries.