Skip to content

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.sqlx
config {
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_id
  • 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. Targets s3://, gs://, Supabase Storage (its S3-compatible endpoint), or a local path.

MySQL/MariaDB export isn’t supported yet.

FieldDescription
locationRequired. Destination folder/prefix URI; SQLAnvil derives the filename. ${} interpolation works (dates, schemaSuffix, vars).
formatRequired. parquet, csv, or json (JSONL).
overwriteReplace an existing file/object. Default true.
filenameOutput base filename. Defaults to the action name.
optionsFormat-specific passthrough (e.g. compression).
SchemeBigQueryPostgres / Supabase
gs://✓ (native)✓ (DuckDB)
s3:// (incl. Supabase Storage)
local://… or a path✓ (handy for debugging)

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.