yggdrasil.databricks.cli.services.sql¶
sql ¶
ygg databricks sql — run SQL and export results.
ygg databricks sql query "SELECT * FROM main.default.orders LIMIT 50"
ygg databricks sql query "SELECT …" --target out.parquet
ygg databricks sql export --statement-id 01ef… --target /Volumes/main/default/stg/out.csv
ygg databricks sql export --query "SELECT …" --target s3://bucket/out.parquet
query runs a statement on the workspace's SQL warehouse and either
prints a preview or writes the result to --target. It echoes the
statement_id so you can re-fetch the same result later with
export --statement-id — the Statement Execution API keeps a finished
result available for a window, so the export costs no re-run.
The export format is the target's extension (.csv / .parquet /
.arrow / .ndjson / .json) unless --format overrides it.
A target shaped like dbfs:/…, /Volumes/… or /Workspace/… is
written into the workspace; anything else (local path, s3://…) is
written through the generic path layer.