Query cached results with SQL (DuckDB) — each asset is a view named after its function

Reads artifact files only: no step runs, user code is never imported, nothing is recorded.

Usage: barca sql [OPTIONS] <QUERY> [FILES]...

Arguments:
  <QUERY>
          The SQL query (DuckDB dialect); quote it as one argument

  [FILES]...
          Python files or directories to read (default: every .py file under the project root that imports barca; see `barca docs discovery`)

Options:
      --json
          Emit JSON on stdout (the default when stdout is not a terminal)

      --pretty
          Emit human-readable output (the default when stdout is a terminal)

  -l, --limit <LIMIT>
          Maximum number of rows to return

          [default: 100]

      --all
          Return every row (no limit)

      --env <ENV>
          Environment name (separates cache/state per environment)

  -h, --help
          Print help (see a summary with '-h')

Examples:
  barca sql "select * from revenue"                       # one view per asset, named after the function
  barca sql "select region, sum(amount) from orders group by 1"   # any DuckDB SQL over cached results
  barca sql "select * from orders o join revenue r using (region)" # join assets
  barca sql "select * from weekly where partition = 'week=w1'"   # partitioned: one view, a partition column
  barca sql "select status from validate"                  # a task's last result is a view too
  barca sql "select * from orders" pipeline.py              # only nodes in this file become views
  barca sql "select * from orders" --limit 20               # first 20 rows (default: at most 100)
  barca sql "select * from orders" --all                    # every row
  barca sql "select * from orders" --json                   # {columns, rows, total, truncated, hint?}
  barca sql "select * from orders" --env dev                # results cached in another environment

Every asset, sensor and task with a result on disk is a view named after its function (or after its
full id, quoted, when two nodes share a name; stderr says so). An asset whose code or inputs changed
is still queryable at its last result, with a note on stderr. Only parquet and json results can be
queried; pickles cannot. Runs in an in-memory DuckDB over the artifact files: your code is never
imported and nothing is recorded. Needs duckdb in barca's Python environment.
With remote storage, the artifacts of the views a query names are downloaded into
.barca/sql-cache/ (stderr says so) and reused while the objects are unchanged; nothing else is
written.
Errors exit 2: a node with no result yet names the `barca get` to run first; an unknown view lists
the views; a SQL error carries DuckDB's message. A remote artifact that cannot be fetched exits 3.
Experimental: barca docs contract.
More: barca docs sql
