File Exports
import { Aside } from ‘@astrojs/starlight/components’;
A type: "export" action writes the result of a query to a Parquet / CSV / JSON file at a cloud or local location. It’s a sink: it runs after the relations its query ${ref()}s and produces a file instead of a warehouse object.
-- definitions/orders_export.sqlxconfig { type: "export", export: { location: "s3://my-bucket/orders/", // folder/prefix URI format: "parquet", // parquet | csv | json (json = JSONL) overwrite: true // default true }}SELECT order_id, total::text AS total FROM ${ref("orders")} ORDER BY order_idHow it runs per warehouse
Section titled “How it runs per warehouse”- BigQuery — compiles to native
EXPORT DATA OPTIONS(uri='gs://…/<name>_*.parquet', …) AS <SELECT>. In-engine, using the warehouse’s own GCS access.gs://only. - Postgres / Supabase — the CLI runs the export via DuckDB: it attaches the database read-only and
COPY (SELECT … FROM postgres_query('pg', <your SELECT>)) TO '<uri>'. The SELECT runs on Postgres; DuckDB only encodes + uploads. Targetss3://,gs://, Supabase Storage (its S3-compatible endpoint), or a local path.
MySQL/MariaDB export isn’t supported yet.
export options
Section titled “export options”| Field | Description |
|---|---|
location | Required. Destination folder/prefix URI; SQLAnvil derives the filename. ${} interpolation works (dates, schemaSuffix, vars). |
format | Required. parquet, csv, or json (JSONL). |
overwrite | Replace an existing file/object. Default true. |
filename | Output base filename. Defaults to the action name. |
options | Format-specific passthrough (e.g. compression). |
Schemes & per-warehouse validity
Section titled “Schemes & per-warehouse validity”| Scheme | BigQuery | Postgres / Supabase |
|---|---|---|
gs:// | ✓ (native) | ✓ (DuckDB) |
s3:// (incl. Supabase Storage) | ✗ | ✓ |
local://… or a path | ✗ | ✓ (handy for debugging) |
Storage credentials
Section titled “Storage credentials”Cloud destinations on Postgres/Supabase read credentials from a storage section of the gitignored
.df-credentials.json (BigQuery uses its own GCS access; local:// needs none):
{ "host": "…", "port": 5432, "database": "…", "user": "…", "password": "…", "storage": { "s3": { "endpoint": "<project-ref>.supabase.co/storage/v1/s3", "region": "us-east-1", "accessKeyId": "…", "secretAccessKey": "…" }, "gcs": { "keyId": "…", "secret": "…" } }}Per-environment via --environment’s credentials file.