CLI Reference

On this page

Single binary. All commands listed below.

Commands

CommandDescription
runExecute the pipeline
sandboxPreview changes before committing
scheduleInstall OS-native scheduler
eventsStart event collection endpoint
odataStart OData v4 server
initCreate a new project
newCreate a model file
editOpen file in $EDITOR
sqlRun arbitrary SQL
queryQuery a table directly
statsProject overview
historyRun history for a model
describeModel details and schema
lineageColumn-level lineage
authOAuth2 provider management
checkpointRun all maintenance
flushFlush inlined data to Parquet
mergeMerge small Parquet files
expireExpire old snapshots
cleanupDelete unreferenced files
orphanedDelete orphaned files
rewriteRewrite files with many deletes
--jsonMachine-readable output
versionPrint version

run

ondatrasql run                    # All models in DAG order
ondatrasql run staging.orders     # Single model

sandbox

ondatrasql sandbox                # All models
ondatrasql sandbox staging.orders # One model

See Preview Changes.

schedule

ondatrasql schedule "*/5 * * * *"   # Install (auto-detects OS)
ondatrasql schedule                 # Show status
ondatrasql schedule remove          # Remove
OSBackend
Linuxsystemd user timer
macOSlaunchd plist
WindowsWSL2

See Schedule Pipeline Runs.

events

ondatrasql events 8080            # Public on 8080, admin on 8081

Admin endpoint runs on port + 1 (localhost-only).

See Collect Events.

odata

ondatrasql odata 8090

Serves @expose models at http://127.0.0.1:<port>/odata.

See Serve Data via OData.


init

ondatrasql init

new

ondatrasql new staging.orders.sql
ondatrasql new raw.api_users.sql
ondatrasql new sync.hubspot.sql

edit

ondatrasql edit staging.orders      # Model
ondatrasql edit env                 # .env
ondatrasql edit catalog             # config/catalog.sql
ondatrasql edit macros/audits       # config/macros/audits.sql
ondatrasql edit macros/constraints  # config/macros/constraints.sql
ondatrasql edit macros/warnings     # config/macros/warnings.sql
ondatrasql edit macros/helpers      # config/macros/helpers.sql
ondatrasql edit macros/masking      # config/macros/masking.sql
ondatrasql edit variables/constants # config/variables/constants.sql
ondatrasql edit variables/global    # config/variables/global.sql
ondatrasql edit variables/local     # config/variables/local.sql
ondatrasql edit secrets             # config/secrets.sql
ondatrasql edit settings            # config/settings.sql
ondatrasql edit sources             # config/sources.sql
ondatrasql edit extensions          # config/extensions.sql

sql

ondatrasql sql "SELECT COUNT(*) FROM staging.orders"
ondatrasql sql "SELECT * FROM staging.orders" --format json

query

ondatrasql query staging.orders
ondatrasql query staging.orders --limit 10 --format csv
FlagDescription
--formatcsv, json, markdown
--limitMaximum rows returned

stats

ondatrasql stats

history

ondatrasql history staging.orders
ondatrasql history staging.orders --limit 5

describe

ondatrasql describe staging.orders

lineage

ondatrasql lineage overview              # All models
ondatrasql lineage staging.orders        # One model
ondatrasql lineage staging.orders.total  # One column

See Lineage & Metadata.


auth

ondatrasql auth                   # List providers
ondatrasql auth google-sheets     # Authenticate
ondatrasql auth fortnox           # Authenticate
ModeDetected byDescription
ManagedONDATRA_KEY in .envUses oauth2.ondatra.sh, no app registration
Local<PREFIX>_CLIENT_ID in .envUses your own OAuth2 credentials

Tokens are stored in .ondatra/tokens/ and auto-refresh on every pipeline run.

See Environment Variables for OAuth2 variable reference.


–json

Machine-readable output on stdout. Human output redirected to stderr.

ondatrasql run --json 2>/dev/null | jq -s '.'
FieldDescription
modelTarget table
kindtable, append, merge, scd2, partition, tracked, events
run_typeskip, backfill, incremental, full, create
run_reasonWhy this run type was chosen
rows_affectedRows written (0 for skip)
duration_msExecution time
statusok or error
errorsError messages (when status is error)
warningsWarnings (schema evolution, validation)

version

ondatrasql version

Maintenance

ondatrasql checkpoint             # Run all maintenance in order
ondatrasql flush                  # Flush inlined data to Parquet
ondatrasql merge                  # Merge small Parquet files
ondatrasql expire                 # Expire old snapshots
ondatrasql cleanup                # Delete unreferenced files
ondatrasql orphaned               # Delete orphaned files
ondatrasql rewrite                # Rewrite files with many deletes

See Maintain DuckLake Storage.