Troubleshooting guide
This guide covers potential errors and limitations you may encounter when using R2 SQL. R2 SQL is in open beta, and supported functionality will evolve and change over time.
Error: expected exactly 1 table in FROM clause
Problem: R2 SQL requires specific clauses in your query.
-- Invalid - Missing FROM clauseSELECT user_id WHERE status = 200;
-- ValidSELECT user_idFROM http_requestsWHERE status = 200 AND timestamp BETWEEN '2025-09-24T01:00:00Z' AND '2025-09-25T01:00:00Z';
Solution: Always include FROM
in your queries.
Function not supported
Problem: Cannot use aggregate or SQL functions in SELECT.
-- Invalid - Aggregate functions not supportedSELECT COUNT(*) FROM events WHERE timestamp > '2025-09-24T01:00:00Z'SELECT AVG(response_time) FROM http_requests WHERE status = 200SELECT MAX(timestamp) FROM logs WHERE user_id = '123'
Solution: Use basic column selection, and handle aggregation in your application code.
Cannot access nested fields
Problem: Cannot query individual fields from JSON objects.
-- Invalid - JSON field access not supportedSELECT metadata.user_id FROM eventsSELECT json_field->>'property' FROM logs
-- Valid - Select entire JSON fieldSELECT metadata FROM eventsSELECT json_field FROM logs
Solution: Select the entire JSON column and parse it in your application.
aliases (AS) are not supported
Problem: Cannot create synthetic columns with literal values.
-- Invalid - Synthetic data not supportedSELECT user_id, 'active' as status, 1 as priority FROM users
-- ValidSELECT user_id, status, priority FROM users WHERE status = 'active'
Solution: Add the required data to your table schema, or handle it in post-processing.
Error: Multiple tables not supported
or JOIN operations not allowed
Problem: Cannot query multiple tables or use JOINs.
-- Invalid - Multiple tables not supportedSELECT a.*, b.* FROM table1 a, table2 b WHERE a.id = b.idSELECT * FROM events JOIN users ON events.user_id = users.id
-- Valid - Separate queriesSELECT * FROM table1 WHERE id IN ('id1', 'id2', 'id3')-- Then in application code, query table2 separatelySELECT * FROM table2 WHERE id IN ('id1', 'id2', 'id3')
Solution:
- Denormalize your data by including necessary fields in a single table.
- Perform multiple queries and join data in your application.
Error: only table name is supported in FROM clause
Problem: Cannot use subqueries in FROM clause.
-- Invalid - Subqueries not supportedSELECT * FROM (SELECT user_id FROM events WHERE status = 200) as active_users
-- Valid - Use direct query with appropriate filtersSELECT user_id FROM events WHERE status = 200
Solution: Flatten your query logic or use multiple sequential queries.
Error: This feature is not implemented: GetFieldAccess
Problem: Cannot filter on array fields.
-- Invalid - Array filtering not supportedSELECT * FROM logs WHERE tags[0] = 'error'SELECT * FROM events WHERE 'admin' = ANY(roles)
-- Valid alternatives - denormalize or use string containsSELECT * FROM logs WHERE tags_string LIKE '%error%'-- Or restructure data to avoid arrays
Solution:
- Denormalize array data into separate columns.
- Use string concatenation of array values for pattern matching.
- Restructure your schema to avoid array types.
Error: unsupported binary operator
or Error during planning: could not parse compound
Problem: Cannot filter on fields inside JSON objects.
-- Invalid - JSON field filtering not supportedSELECT * FROM requests WHERE metadata.country = 'US'SELECT * FROM logs WHERE json_data->>'level' = 'error'
-- Valid alternativesSELECT * FROM requests WHERE country = 'US' -- If denormalized-- Or filter entire JSON field and parse in applicationSELECT * FROM logs WHERE json_data IS NOT NULL
Solution:
- Denormalize frequently queried JSON fields into separate columns.
- Filter on the entire JSON field, and handle parsing in your application.
Error: right argument to a binary expression must be a literal
Problem: Cannot compare one column to another in WHERE clause.
-- Invalid - Column comparisons not supportedSELECT * FROM events WHERE start_time < end_timeSELECT * FROM logs WHERE request_size > response_size
-- Valid - Use computed columns or application logic-- Add a computed column 'duration' to your schemaSELECT * FROM events WHERE duration > 0
Solution: Handle comparisons in your application layer.
maximum LIMIT is 10000
Problem: Cannot use invalid LIMIT values.
-- Invalid - Out of range limitsSELECT * FROM events LIMIT 50000 -- Maximum is 10,000
-- ValidSELECT * FROM events LIMIT 1SELECT * FROM events LIMIT 10000
Solution: Use LIMIT values between 1 and 10,000.
OFFSET not supported
Problem: Cannot use pagination syntax.
-- Invalid - Pagination not supportedSELECT * FROM events LIMIT 100 OFFSET 200SELECT * FROM events LIMIT 100, 100
-- Valid alternatives - Use ORDER BY with conditional filters-- Page 1SELECT * FROM events WHERE timestamp >= '2024-01-01' ORDER BY timestamp LIMIT 100
-- Page 2 - Use last timestamp from previous pageSELECT * FROM events WHERE timestamp > '2024-01-01T10:30:00Z' ORDER BY timestamp LIMIT 100
Solution: Implement cursor-based pagination using ORDER BY and WHERE conditions.
Error: invalid SQL: only top-level SELECT clause is supported
Problem: Cannot modify table schema or reference non-existent columns.
-- Invalid - Schema changes not supportedALTER TABLE events ADD COLUMN new_field STRINGUPDATE events SET status = 200 WHERE user_id = '123'
Solution:
- Plan your schema carefully before data ingestion.
- Ensure all column names exist in your current schema.
If your queries are running slowly:
-
Always include partition (timestamp) filters: This is the most important optimization.
-- GoodWHERE timestamp BETWEEN '2024-01-01' AND '2024-01-02' -
Use selective filtering: Include specific conditions to reduce result sets.
-- GoodWHERE status = 200 AND country = 'US' AND timestamp > '2024-01-01' -
Limit result size: Use appropriate LIMIT values.
-- Good for explorationSELECT * FROM events WHERE timestamp > '2024-01-01' LIMIT 100
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark
-