Skip to content

Commit 205b4a4

Browse files
more improvements from reviews
1 parent 39c0e8c commit 205b4a4

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

src/content/docs/r2-sql/reference/limitations-best-practices.mdx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ R2 SQL is designed for querying **partitioned** Apache Iceberg tables in your R2
3333

3434
## Supported SQL Clauses
3535

36-
R2 SQL supports a limited set of SQL clauses: `SELECT`, `FROM`, `WHERE`, `ORDER BY`, and `LIMIT`. All other SQL clauses are not supported at the moment. New features will be released in the future, keep an eye on this page and the changelog\[LINK TO CHANGE LOG\] for the latest.
36+
R2 SQL supports a limited set of SQL clauses: `SELECT`, `FROM`, `WHERE`, `ORDER BY`, and `LIMIT`. All other SQL clauses are not supported at the moment. New features will be released in the future, keep an eye on this page for the latest.
3737

3838
---
3939

@@ -56,14 +56,14 @@ R2 SQL supports a limited set of SQL clauses: `SELECT`, `FROM`, `WHERE`, `ORDER
5656

5757
```sql
5858
-- Valid
59-
SELECT timestamp, user_id, status
60-
SELECT *
59+
SELECT timestamp, user_id, status FROM my_table;
60+
SELECT * FROM my_table;
6161

6262
-- Invalid
63-
SELECT user_id AS uid, timestamp AS ts
64-
SELECT COUNT(*) FROM events
65-
SELECT json_field.property FROM table
66-
SELECT 1 AS synthetic_column
63+
SELECT user_id AS uid, timestamp AS ts FROM my_table;
64+
SELECT COUNT(*) FROM events FROM FROM my_table;
65+
SELECT json_field.property FROM my_table;
66+
SELECT 1 AS synthetic_column FROM my_table;
6767
```
6868

6969
---
@@ -128,7 +128,6 @@ SELECT * FROM logs WHERE status = 200 AND user_type = 'premium'
128128
SELECT * FROM requests WHERE (method = 'GET' OR method = 'POST') AND response_time < 1000
129129

130130
--Invalid
131-
SELECT * FROM events -- Missing time filter
132131
SELECT * FROM logs WHERE tags[0] = 'error' -- Array filtering
133132
SELECT * FROM requests WHERE metadata.user_id = '123' -- JSON field filtering
134133
SELECT * FROM events WHERE col_a = col_b -- Column comparison
@@ -141,8 +140,8 @@ SELECT * FROM logs WHERE response_time + latency > 5000 -- Arithmetic
141140

142141
### Supported Features
143142

144-
- **ASC**: Ascending order (Default)
145-
- **DESC**: Descending order
143+
- **ASC**: Ascending order
144+
- **DESC**: Descending order (Default, on full partition key)
146145

147146
### Limitations
148147

@@ -153,7 +152,6 @@ SELECT * FROM logs WHERE response_time + latency > 5000 -- Arithmetic
153152
```sql
154153
SELECT * FROM table_name WHERE ... ORDER BY partitionKey
155154
SELECT * FROM table_name WHERE ... ORDER BY partitionKey DESC
156-
SELECT * FROM table_name WHERE ... ORDER BY partitionKey DESC
157155
```
158156

159157
---
@@ -175,7 +173,7 @@ SELECT * FROM table_name WHERE ... ORDER BY partitionKey DESC
175173

176174
```sql
177175
-- Valid
178-
SELECT * FROM events WHERE ... LIMIT 100
176+
SELECT * FROM events LIMIT 100
179177
SELECT * FROM logs WHERE ... LIMIT 10000
180178

181179
-- Invalid

src/content/docs/r2-sql/reference/sql-reference.mdx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ SELECT timestamp, user_id, response_code FROM table_name
6464
SELECT * FROM table_name
6565
```
6666

67-
### Examples
68-
69-
```sql
70-
SELECT column_name FROM table_name
71-
```
7267

7368
---
7469

@@ -89,14 +84,14 @@ SELECT * WHERE condition [AND|OR condition ...]
8984

9085
#### Value Comparisons
9186

92-
- `column_name BETWEEN value AND value`
87+
- `column_name BETWEEN value' AND 'value`
9388
- `column_name = value`
9489
- `column_name >= value`
9590
- `column_name > value`
9691
- `column_name <= value`
9792
- `column_name < value`
9893
- `column_name != value`
99-
- `column_name LIKE value%`
94+
- `column_name LIKE 'value%'`
10095

10196
#### Logical Operators
10297

@@ -109,6 +104,8 @@ SELECT * WHERE condition [AND|OR condition ...]
109104
- **float** \- Decimal numbers
110105
- **string** \- Text values (quoted)
111106
- **timestamp** - RFC3339 format (`'YYYY-DD-MMT-HH:MM:SSZ'`)
107+
- **date** - Date32/Data64 expressed as a string (`'YYYY-MM-DD'`)
108+
- **boolean** - Explicitly valued (true, false)
112109

113110
### Examples
114111

@@ -247,7 +244,7 @@ SELECT * FROM table_name WHERE country_code = 'US'
247244

248245
## Operator Precedence
249246

250-
1. **Comparison operators**: `=`, `!=`, `<`, `<=`, `>`, `>=`, `LIK#`, `BETWEEN`, `IS NULL`, `IS NOT NULL`
247+
1. **Comparison operators**: `=`, `!=`, `<`, `<=`, `>`, `>=`, `LIKE`, `BETWEEN`, `IS NULL`, `IS NOT NULL`
251248
2. **AND** (higher precedence)
252249
3. **OR** (lower precedence)
253250

src/content/docs/r2-sql/troubleshooting.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This guide covers potential errors and limitations you may encounter when using
1414
### Missing Required Clauses
1515

1616
<div className="error-box">
17-
**Error**: `expected exactly 1 table in `FROM` clause`
17+
**Error**: `expected exactly 1 table in FROM clause`
1818
</div>
1919

2020
**Problem**: R2 SQL requires specific clauses in your query.
@@ -75,7 +75,7 @@ SELECT json_field FROM logs
7575
### Synthetic Data
7676

7777
<div className="error-box">
78-
**Error**: `aliases (`AS`) are not supported`
78+
**Error**: `aliases (AS) are not supported`
7979
</div>
8080

8181
**Problem**: Cannot create synthetic columns with literal values.
@@ -120,7 +120,7 @@ SELECT * FROM table2 WHERE id IN ('id1', 'id2', 'id3')
120120
### Subqueries
121121

122122
<div className="error-box">
123-
**Error**: `only table name is supported in `FROM` clause`
123+
**Error**: `only table name is supported in FROM clause`
124124
</div>
125125

126126
**Problem**: Cannot use subqueries in FROM clause.

0 commit comments

Comments
 (0)