You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/r2-sql/index.mdx
+22-7Lines changed: 22 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,37 @@
1
1
---
2
-
pcx_content_type: navigation
3
2
title: R2 SQL
3
+
4
+
pcx_content_type: overview
4
5
sidebar:
5
-
order: 7
6
+
order: 1
7
+
badge:
8
+
text: Beta
6
9
head:
7
10
- tag: title
8
11
content: R2 SQL
9
12
description: A distributed SQL engine for R2 Data Catalog
10
13
---
11
14
12
-
## Query Apache Iceberg tables in R2 Data Catalog Using R2 SQL
13
-
15
+
import {
16
+
CardGrid,
17
+
Description,
18
+
Feature,
19
+
LinkTitleCard,
20
+
Plan,
21
+
RelatedProduct,
22
+
} from"~/components";
14
23
15
24
:::note
16
-
R2 SQL is in public beta, and any developer with an R2 subscription can start using it. Currently, outside of standard R2 storage and operations, you will not be billed for your use of R2 SQL. We will update [the pricing page](/r2-sql/platform/pricing) and provide at least 30 days notice before enabling billing.
25
+
R2 SQL is in **open beta**, and any developer with an [R2 subscription](/r2/pricing/) can start using it. Currently, outside of standard R2 storage and operations, you will not be billed for your use of R2 SQL. We will update [the pricing page](/r2-sql/platform/pricing) and provide at least 30 days notice before enabling billing.
17
26
:::
18
27
19
-
R2 SQL is Cloudflare's serverless, distributed, analytics query engine for querying [Apache Iceberg](https://iceberg.apache.org/) tables stored in [R2 data catalog](/r2/data-catalog/). R2 SQL is designed to efficiently query large amounts of data by automatically utilizing file pruning, Cloudflare's distributed compute, and R2 object storage.
28
+
<Description>
29
+
30
+
Query Apache Iceberg tables managed by R2 Data Catalog using SQL.
31
+
32
+
</Description>
33
+
34
+
R2 SQL is Cloudflare's serverless, distributed, analytics query engine for querying [Apache Iceberg](https://iceberg.apache.org/) tables stored in [R2 Data Catalog](/r2/data-catalog/). R2 SQL is designed to efficiently query large amounts of data by automatically utilizing file pruning, Cloudflare's distributed compute, and R2 object storage.
@@ -52,4 +67,4 @@ Read 11.3 kB across 4 files from R2
52
67
On average, 3.36 kB / s
53
68
```
54
69
55
-
Create an end to end data pipeline and query your first table in R2 SQL by following [this step by step guide](/r2-sql/tutorials/end-to-end-pipeline/), learn how to create a data pipeline that takes a stream of events and automatically creates an Apache Iceberg table, making them accessible with R2 SQL.
70
+
Create an end-to-end data pipeline by following [this step by step guide](/r2-sql/get-started/), which shows you how to stream events into an Apache Iceberg table and query it with R2 SQL.
Copy file name to clipboardExpand all lines: src/content/docs/r2-sql/platform/pricing.mdx
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,10 @@ sidebar:
6
6
head:
7
7
- tag: title
8
8
content: R2 SQL - Pricing
9
-
10
9
---
11
10
12
-
During the first phase of the R2 SQL open beta, you will not be billed for R2 SQL usage. You will only be billed for R2 usage.
11
+
R2 SQL is in open beta and available to any developer with an [R2 subscription](/r2/pricing/).
12
+
13
+
We are not currently billing for R2 SQL during open beta. However, you will be billed for standard [R2 storage and operations](/r2/pricing/) for data accessed by queries.
13
14
14
-
We plan to price based on the volume of data queried by R2 SQL. We will provide at least 30 days notice and exact pricing before charging.
15
+
We plan to bill based on the volume of data queried by R2 SQL. We'll provide at least 30 days notice before we make any changes or start charging for R2 SQL usage.
- Create an API key with the necessary permissions.
22
-
- Query data with R2 SQL.
11
+
Query [Apache Iceberg](https://iceberg.apache.org/) tables managed by [R2 Data Catalog](/r2/data-catalog/). R2 SQL queries can be made via [Wrangler](/workers/wrangler/) or HTTP API.
23
12
24
-
R2 SQL can currently be accessed via Wrangler commands or a REST API.
13
+
## Get your warehouse name
25
14
26
-
## Create an API key with the right permissions
15
+
To query data with R2 SQL, you'll need your warehouse name associated with your [catalog](/r2/data-catalog/manage-catalogs/). To retrieve it, you can run the [`r2 bucket catalog get` command](/workers/wrangler/commands/#r2-bucket-catalog-get):
27
16
28
-
To query Apache Iceberg tables in R2 Data Catalog, you must provide a Cloudflare API token with R2 SQL, R2 Data Catalog, and R2 storage permissions.
17
+
```bash
18
+
npx wrangler r2 bucket catalog get <BUCKET_NAME>
19
+
```
20
+
21
+
Alternatively, you can find it in the dashboard by going to the **R2 object storage** page, selecting the bucket, switching to the **Settings** tab, scrolling to **R2 Data Catalog**, and finding **Warehouse name**.
22
+
23
+
## Query via Wrangler
24
+
25
+
To begin, install [`npm`](https://docs.npmjs.com/getting-started). Then [install Wrangler, the Developer Platform CLI](/workers/wrangler/install-and-update/).
26
+
27
+
Wrangler needs an API token with permissions to access R2 Data Catalog, R2 storage, and R2 SQL to execute queries. The `r2 sql query` command looks for the token in the `WRANGLER_R2_SQL_AUTH_TOKEN` environment variable.
28
+
29
+
Set up your environment:
30
+
31
+
```bash
32
+
export WRANGLER_R2_SQL_AUTH_TOKEN=YOUR_API_TOKEN
33
+
```
34
+
35
+
Or create a `.env` file with:
36
+
37
+
```
38
+
WRANGLER_R2_SQL_AUTH_TOKEN=YOUR_API_TOKEN
39
+
```
40
+
41
+
Where `YOUR_API_TOKEN` is the token you created with the [required permissions](#authentication). For more information on setting environment variables, refer to [Wrangler system environment variables](/workers/wrangler/system-environment-variables/).
42
+
43
+
To run a SQL query, run the [`r2 sql query` command](/workers/wrangler/commands/#r2-sql-query):
"query": "SELECT * FROM namespace.table_name limit 10;"
62
+
}'
63
+
```
64
+
65
+
The API requires an API token with the appropriate permissions in the Authorization header. Refer to [Authentication](#authentication) for details on creating a token.
66
+
67
+
For a full list of supported sql commands, refer to the [R2 SQL reference page](/r2-sql/reference/sql-reference).
29
68
30
-
<TabssyncKey='CLIvDash'>
31
-
<TabItemlabel='Dashboard'>
32
-
Create an [API token](https://dash.cloudflare.com/profile/api-tokens) with:
69
+
## Authentication
33
70
34
-
- Access to R2 Data Catalog (**minimum**: edit)
35
-
- Access to R2 storage (**minimum**: read-only)
36
-
- Access to R2 SQL (**minimum**: read-only)
71
+
To query data with R2 SQL, you must provide a Cloudflare API token with R2 SQL, R2 Data Catalog, and R2 storage permissions. R2 SQL requires these permissions to access catalog metadata and read the underlying data files stored in R2.
37
72
38
-
Wrangler now supports the environment variable `WRANGLER_R2_SQL_AUTH_TOKEN` which you can use to `export` your token.
73
+
### Create API token in the dashboard
39
74
40
-
</TabItem>
41
-
<TabItemlabel='Via API'>
42
-
To create an API token programmatically for use with R2 SQL, you will need to specify R2 SQL, R2 Data Catalog, and R2 storage permission groups in your [Access Policy](/r2/api/tokens/#access-policy).
75
+
Create an [R2 API token](/r2/api/tokens/#permissions) with **Admin Read only** permission. This permission includes:
76
+
77
+
- Access to R2 Data Catalog (read-only)
78
+
- Access to R2 storage (read-only)
79
+
- Access to R2 SQL (read-only)
80
+
81
+
Use this token value for the `WRANGLER_R2_SQL_AUTH_TOKEN` environment variable when querying with Wrangler, or in the Authorization header when using the REST API.
82
+
83
+
### Create API token via API
84
+
85
+
To create an API token programmatically for use with R2 SQL, you'll need to specify R2 SQL, R2 Data Catalog, and R2 storage permission groups in your [Access Policy](/r2/api/tokens/#access-policy).
43
86
44
87
#### Example Access Policy
45
88
@@ -63,68 +106,14 @@ To create an API token programmatically for use with R2 SQL, you will need to sp
63
106
},
64
107
{
65
108
"id": "f45430d92e2b4a6cb9f94f2594c141b8",
66
-
"name": "Workers R2 SQL Read"
109
+
"name": "Workers R2 SQL Read"
67
110
}
68
111
]
69
112
}
70
113
]
71
114
```
72
-
</TabItem>
73
-
</Tabs>
74
-
75
-
## Query data via Wrangler
76
-
77
-
ExportyourR2APItokenasanenvironmentvariable:
78
-
79
-
```bash
80
-
export WRANGLER_R2_SQL_AUTH_TOKEN=your_token_here
81
-
```
82
-
83
-
If this is your first time using Wrangler, make sure to login.
84
-
85
-
```bash
86
-
npx wrangler login
87
-
```
88
-
89
-
:::note
90
-
You will want to copy the `Warehouse` of the R2 Data Catalog:
91
-
:::
92
-
93
-
```sh
94
-
❯ npx wrangler r2 bucket catalog get [BUCKET_NAME]
▲ [WARNING] 🚧 `wrangler r2 bucket catalog get` is an open-beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
"query": "SELECT * FROM namespace.table_name limit 10;"
126
-
}'
127
-
```
116
+
To learn more about how to create API tokens for R2 SQL using the API, including required permission groups and usage examples, refer to the [Create API tokens via API documentation](/r2/api/tokens/#create-api-tokens-via-api).
0 commit comments