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
After running the `stream create` command, note the **Stream Endpoint URL** from the output. This is the endpoint you'll use to send data to your pipeline.
111
+
Note the **HTTP Ingest Endpoint URL** from the output. This is the endpoint you'll use to send data to your pipeline.
107
112
:::
113
+
```bash
114
+
# The http ingest endpoint from the output (see example below)
115
+
export STREAM_ENDPOINT= #the http ingest endpoint from the output (see example below)
116
+
```
117
+
118
+
The output should look like this:
119
+
```sh
120
+
🌀 Creating stream 'rawtransactionstream'...
121
+
✨ Successfully created stream 'rawtransactionstream' with id 'stream_id'.
Now you'll create a new SQL query to process data from the original `fraud-transactions` stream and only write flagged transactions that are over the `amount` of 1000.
378
+
Now you'll create a new SQL query to process data from the original `rawtransactionstream` stream and only write flagged transactions that are over the `amount` of 1000.
331
379
332
380
```bash
333
-
npx wrangler pipelines create fraud-pipeline \
334
-
--sql "INSERT INTO filtered-fraud-sink SELECT * FROM fraud-transactions WHERE is_fraud='TRUE' and amount > 1000"
381
+
npx wrangler pipelines create fraudpipeline \
382
+
--sql "INSERT INTO filteredfraudsink SELECT * FROM rawtransactionstream WHERE is_fraud='TRUE' and amount > 1000"
335
383
```
336
384
337
385
:::note
338
386
It may take a few minutes for the new Pipeline to fully Initialize and start processing the data. Also keep in mind the 30 second `roll-interval`
339
387
:::
340
388
341
-
Let's query our table and check the results:
389
+
Let's query the table and check the results:
342
390
```bash
343
-
npx wrangler r2 sql query "
391
+
npx wrangler r2 sql query "YOUR_WAREHOUSE""
344
392
SELECT
345
393
transaction_id,
346
394
user_id,
@@ -350,15 +398,33 @@ SELECT
350
398
is_fraud,
351
399
transaction_timestamp
352
400
FROM fraud_detection.fraud_transactions
353
-
WHERE __ingest_ts > '2025-09-12T01:00:00Z'
354
401
LIMIT 10"
355
402
```
403
+
Let's also verify that the non-fraudulent events are being filtered out:
404
+
```bash
405
+
npx wrangler r2 sql query "YOUR_WAREHOUSE""
406
+
SELECT
407
+
transaction_id,
408
+
user_id,
409
+
amount,
410
+
location,
411
+
merchant_category,
412
+
is_fraud,
413
+
transaction_timestamp
414
+
FROM fraud_detection.fraud_transactions
415
+
WHERE is_fraud = 'FALSE'
416
+
LIMIT 10"
417
+
```
418
+
You should see the following output:
419
+
```text
420
+
Query executed successfully with no results
421
+
```
356
422
357
423
## Conclusion
358
424
359
425
You have successfully built an end to end data pipeline using Cloudflare's data platform. Through this tutorial, you've learned to:
360
426
361
427
1.**Use R2 Data Catalog** - Leveraged Apache Iceberg tables for efficient data storage
362
428
2.**Set up Cloudflare Pipelines** - Created streams, sinks, and pipelines for data ingestion
363
-
3.**Generated sample data** - Created transaction data with basic fraud patterns
364
-
4.**Query with R2 SQL** - Performed complex fraud analysis using SQL queries
429
+
3.**Generated sample data** - Created transaction data with some basic fraud patterns
430
+
4.**Query your tables with R2 SQL** - Access raw and processed data tables stored in R2 Data Catalog
- Sign up for a [Cloudflare account](https://dash.cloudflare.com/sign-up/workers-and-pages).
13
+
-[Create an R2 bucket](/r2/buckets/create-buckets/) and [enable the data catalog](/r2/data-catalog/manage-catalogs/#enable-r2-data-catalog-on-a-bucket).
14
+
-[Create an R2 API token](/r2/api/tokens/) with [R2, R2 SQL, and data catalog permissions](/r2/api/tokens/#permissions).
15
+
- Tables must have a time-based partition key in order be queried by R2 SQL. Read about the current [limitations](/r2/sql/platform/limitations-best-practices) to learn more.
16
+
17
+
R2 SQL can currently be accessed via Wrangler commands or a REST API.
18
+
19
+
## Wrangler
20
+
21
+
22
+
ExportyourR2APItokenasanenvironmentvariable:
23
+
24
+
```bash
25
+
export WRANGLER_R2_SQL_AUTH_TOKEN=your_token_here
26
+
```
27
+
28
+
If this is your first time using Wrangler, make sure to login.
29
+
```bash
30
+
npx wrangler login
31
+
```
32
+
33
+
You'll also want to grab the **warehouse** of the your R2 Data Catalog:
34
+
35
+
```sh
36
+
❯ 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
0 commit comments