Task 0.5 of clean-analyst-bootstrap. Greenfield rewrite — no fallback, no aliases. Existing dev environments lose their cached PAT and must re-authenticate. Env var renames (hard cutover): - DA_CONFIG_DIR -> AGNES_CONFIG_DIR - DA_SERVER -> AGNES_SERVER - DA_SERVER_URL -> AGNES_SERVER_URL (test-only stale ref, not in spec) - DA_NO_UPDATE_CHECK -> AGNES_NO_UPDATE_CHECK - DA_LOCAL_DIR -> AGNES_LOCAL_DIR - DA_TOKEN -> AGNES_TOKEN - DA_STREAM_RETRIES -> AGNES_STREAM_RETRIES Config dir rename: ~/.config/da/ -> ~/.config/agnes/ (across code, comments, docstrings, error messages, install templates, dev scripts). Stale `da X` references in CLI source (and adjacent app/, tests/): swept docstrings, comments, help text, and error messages where the verb survives the rewrite (init, pull, push, catalog, status, diagnose, auth, admin, skills, query, schema, describe, explore, disk-info, snapshot, login, logout, whoami, server, setup) and replaced `da X` with `agnes X`. Intentionally kept `da sync`, `da fetch`, `da analyst`, `da metrics` — those verbs are removed in later tasks; the legacy strings will be detected by `_LEGACY_STRINGS` (added in Task 2). Test fixes: - TestCLIVersion now asserts output starts with `agnes ` (was `da `). Test results: 2675 passed, 25 skipped (full pytest run, excluding 9 pre-existing test_db.py / test_user_management.py / test_e2e_extract.py / test_cli_binary_rename.py failures unrelated to this rename).
45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
"""`agnes schema <table>` — show columns + BQ flavor hints (spec §4.1)."""
|
|
|
|
import json as json_lib
|
|
import typer
|
|
from cli.v2_client import api_get_json, V2ClientError
|
|
|
|
schema_app = typer.Typer(help="Show column metadata for a table")
|
|
|
|
|
|
@schema_app.callback(invoke_without_command=True)
|
|
def schema(
|
|
ctx: typer.Context,
|
|
table_id: str = typer.Argument(...),
|
|
json: bool = typer.Option(False, "--json"),
|
|
):
|
|
"""Show column metadata for a table."""
|
|
if ctx.invoked_subcommand is not None:
|
|
return
|
|
try:
|
|
data = api_get_json(f"/api/v2/schema/{table_id}")
|
|
except V2ClientError as e:
|
|
typer.echo(f"Error: schema fetch failed: {e}", err=True)
|
|
raise typer.Exit(5 if e.status_code >= 500 else 8 if e.status_code == 403 else 2)
|
|
|
|
if json:
|
|
typer.echo(json_lib.dumps(data, indent=2))
|
|
return
|
|
|
|
flavor = data.get("sql_flavor", "duckdb")
|
|
typer.echo(f"Table: {data['table_id']} ({data['source_type']} — use {flavor.upper()} SQL dialect)")
|
|
typer.echo("")
|
|
typer.echo(f"{'COLUMN':30s} {'TYPE':15s} {'NULL':5s} DESCRIPTION")
|
|
for c in data.get("columns", []):
|
|
typer.echo(
|
|
f"{c['name']:30s} {c['type']:15s} "
|
|
f"{'YES' if c.get('nullable') else 'NO':5s} {c.get('description', '')}"
|
|
)
|
|
if data.get("partition_by"):
|
|
typer.echo(f"\nPartition: {data['partition_by']}")
|
|
if data.get("clustered_by"):
|
|
typer.echo(f"Clustered: {', '.join(data['clustered_by'])}")
|
|
if data.get("where_dialect_hints"):
|
|
typer.echo("\nWHERE dialect hints:")
|
|
for k, v in data["where_dialect_hints"].items():
|
|
typer.echo(f" {k:25s} {v}")
|