← Back
Cloudflare R2 SQL gains 190+ functions and expressions for richer data analytics
Cloudflare · featureapiplatform · developers.cloudflare.com ↗

Major SQL Expansion for R2 Analytics

Cloudflare has significantly expanded R2 SQL's capabilities with support for over 190 new functions, expressions, and complex data types. This update brings R2 SQL's serverless query engine closer to feature parity with traditional SQL databases, making it easier to perform sophisticated analytics directly on Apache Iceberg tables stored in R2 Data Catalog.

What's New

The release introduces several critical capabilities:

  • CASE Expressions — Both searched and simple forms of conditional logic now work natively in queries
  • Scalar Functions — 163 new functions spanning math, string manipulation, datetime operations, regex, cryptography, encoding, and type inspection
  • Aggregate Functions — Statistical functions (variance, stddev, correlation, regression), bitwise operations, boolean aggregates, and positional aggregates
  • Complex Type Support — Full access to struct fields using bracket notation, 46 array functions, and map key/value extraction
  • Common Table Expressions (CTEs)WITH ... AS syntax for defining named temporary result sets with chaining support
  • Enhanced Expression Support — Arithmetic, type casting (CAST, TRY_CAST, :: shorthand), and EXTRACT functions now work across SELECT, WHERE, GROUP BY, HAVING, and ORDER BY clauses

Developer Impact

These additions eliminate the need to export data for complex analytical transformations. Developers can now handle statistical analysis, time-series aggregations, conditional formatting, and nested data structures entirely within R2 SQL, reducing data movement and improving query performance.

The documentation includes full syntax reference and best practices, with examples demonstrating CASE expressions with statistical aggregates, struct/array access patterns, and chained CTEs for time-series analysis.