ClaudeCloudflare Developer PlatformApr 20, 2026, 12:00 AM

R2 SQL - R2 SQL adds JSON functions, EXPLAIN FORMAT JSON, and unpartitioned table support

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

claudeenmodel: claude-haiku-4-5

R2 SQL adds JSON functions, EXPLAIN FORMAT JSON, and unpartitioned table support

Key Points

  • Native JSON functions for SQL queries
  • EXPLAIN FORMAT JSON for structured query plans
  • Support for unpartitioned Iceberg tables

Summary

R2 SQL, Cloudflare's serverless distributed analytics query engine for Apache Iceberg tables, now includes native JSON functions, structured query plan output, and support for unpartitioned tables.

Key Points

  • JSON Functions: Extract and manipulate JSON data directly in SQL queries using functions like json_get_str(), json_get_int(), json_get_bool(), and json_contains() without client-side processing
  • EXPLAIN FORMAT JSON: Query execution plans are now returned as structured JSON for programmatic analysis and observability tool integration
  • Unpartitioned Table Support: Query Apache Iceberg tables without partition keys, useful for smaller datasets or data without natural time dimensions (partitioning still recommended for tables with 1000+ files)
  • All features work with tables stored in R2 Data Catalog

Full Translation

Translations

A translation section that keeps the flow of the original article.

claudejamodel: claude-haiku-4-5

R2 SQL が JSON 関数、EXPLAIN FORMAT JSON、およびパーティション分割されていないテーブルのサポートを追加

R2 SQL が JSON 関数、EXPLAIN FORMAT JSON、およびパーティション分割されていないテーブルのサポートを追加

2026年4月20日

R2 SQL は、R2 Data Catalog に保存されている Apache Iceberg テーブルをクエリするための Cloudflare のサーバーレス分散分析クエリエンジンです。

R2 SQL は、Apache Iceberg テーブルに保存されている JSON データをクエリするための関数、クエリプランを解析するための EXPLAIN FORMAT JSON、および R2 Data Catalog に保存されているパーティションキーのないテーブルをクエリする機能をサポートするようになりました。

JSON 関数

JSON 関数は、クライアント側の処理なしに SQL で直接 JSON 値を抽出および操作します:

SELECT json_get_str(doc, 'name') AS name,
       json_get_int(doc, 'user', 'profile', 'level') AS level,
       json_get_bool(doc, 'active') AS is_active
FROM my_namespace.sales_data
WHERE json_contains(doc, 'email')

利用可能な関数の完全なリストについては、JSON functions を参照してください。

EXPLAIN FORMAT JSON

EXPLAIN FORMAT JSON は、クエリ実行プランを構造化 JSON として返し、プログラム的な分析と可観測性の統合を実現します:

npx wrangler r2 sql query "${WAREHOUSE}" "EXPLAIN FORMAT JSON SELECT * FROM logpush.requests LIMIT 10;"
┌──────────────────────────────────────┐
│ plan                                 │
├──────────────────────────────────────┤
│ {                                    │
│   "name": "CoalescePartitionsExec", │
│   "output_partitions": 1,            │
│   "rows": 10,                        │
│   "size_approx": "310B",             │
│   "children": [                      │
│     {                                │
│       "name": "DataSourceExec",      │
│       "output_partitions": 4,        │
│       "rows": 28951,                 │
│       "size_approx": "900.0KB",      │
│       "table": "logpush.requests",   │
│       "files": 7,                    │
│       "bytes": 900019,               │
│       "projection": [                │
│         "__ingest_ts",               │
│         "CPUTimeMs",                 │
│         "DispatchNamespace",         │
│         "Entrypoint",                │
│         "Event",                     │
│         "EventTimestampMs",          │
│         "EventType",                 │
│         "Exceptions",                │
│         "Logs",                      │
│         "Outcome",                   │
│         "ScriptName",                │
│         "ScriptTags",                │
│         "ScriptVersion",             │
│         "WallTimeMs"                 │
│       ],                             │
│       "limit": 10                    │
│     }                                │
│   ]                                  │
│ }                                    │
└──────────────────────────────────────┘

詳細については、EXPLAIN を参照してください。

パーティション分割されていない Iceberg テーブル

パーティション分割されていない Iceberg テーブルは直接クエリできるようになりました。これは、小規模なデータセットや自然な時間次元を持たないデータに役立ちます。1000 ファイルを超えるテーブルの場合、パフォーマンスを向上させるためにパーティション分割が推奨されます。

R2 SQL の使用に関する最新のガイダンスについては、Limitations and best practices を参照してください。