1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Aggregate and enrich order data using embedded DuckDB SQL.
#
# The whole CSV is loaded as a single page (batch_size: 0) so the GROUP BY
# runs across all rows. A reference CSV (countries) is joined at compile time.
#
# faucet validate cli/examples/csv_to_jsonl_sql.yaml
# faucet run cli/examples/csv_to_jsonl_sql.yaml # requires --features transform-sql,source-csv,sink-jsonl
version: 1
name: csv_to_jsonl_sql
pipeline:
source:
type: csv
config:
path: cli/examples/data/orders.csv
has_header: true
batch_size: 0 # whole file as one page → global GROUP BY
transforms:
- type: sql
config:
query: |
SELECT c.country,
COUNT(*) AS order_count,
SUM(CAST(o.amount AS DOUBLE)) AS total_amount
FROM batch o
LEFT JOIN countries c ON o.country_code = c.code
GROUP BY c.country
ORDER BY c.country
relations:
- name: countries
source:
type: csv
path: cli/examples/data/countries.csv
has_header: true
sink:
type: jsonl
config:
path: /tmp/faucet_sql_demo.jsonl