Skip to content

Add managed databases CLI#82

Merged
eddietejeda merged 3 commits into
mainfrom
feat/databases-managed-cli
May 19, 2026
Merged

Add managed databases CLI#82
eddietejeda merged 3 commits into
mainfrom
feat/databases-managed-cli

Conversation

@eddietejeda
Copy link
Copy Markdown
Contributor

Summary

  • Add hotdata databases commands for managed catalogs (source_type: managed): list, create, inspect, delete, and table operations.
  • Support declaring tables at create time via --table (required by the current API before tables load).
  • Load parquet files into managed tables via upload + POST .../loads (replace mode); query as database.schema.table.
  • Add unit tests (mockito) and CLI integration tests; document usage in README.

Test plan

  • cargo test (147 unit + 5 databases_cli + 5 sandbox_env)
  • Live smoke test: databases create --table gdp_realtables load (parquet) → query returns 50 rows

Introduce `hotdata databases` as the UX for managed connections: create catalogs, declare tables, load parquet uploads, and query via `name.schema.table`. Includes unit and integration tests plus README docs.
Comment thread src/databases.rs
Comment on lines +193 to +209
fn upload_parquet_file(api: &ApiClient, path: &str) -> String {
let f = match std::fs::File::open(path) {
Ok(f) => f,
Err(e) => {
eprintln!("error opening file '{path}': {e}");
std::process::exit(1);
}
};

if !is_parquet_path(path) {
eprintln!(
"error: managed table loads require a parquet file (got '{}'). \
Convert your data to parquet or use `hotdata datasets create` for CSV/JSON.",
path
);
std::process::exit(1);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is_parquet_path is checked after opening the file (not blocking). If a user passes --file ./orders.csv, the file is opened and then the extension check rejects it — better to validate the extension first so the wrong-format error doesn't depend on whether the file exists/is readable. Swap the order so the cheap check runs before the syscall.

Comment thread src/databases.rs Outdated
Comment on lines +320 to +322
if detail.source_type != MANAGED_SOURCE_TYPE {
fail_not_managed(&detail.name, &detail.source_type);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this branch is unreachable (not blocking). resolve_database above already enforces is_managed, so by the time we get here db.source_type == "managed" and db.id == detail.id. The DatabaseDetail re-check + fail_not_managed call can be dropped, along with the fail_not_managed helper which has no other callers.

Comment thread src/databases.rs Outdated
Comment on lines +457 to +460
if file.is_some() && upload_id.is_some() {
eprintln!("error: pass either --file or --upload-id, not both");
std::process::exit(1);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: this runtime check is dead code (not blocking). The #[arg(long, conflicts_with = "upload_id")] on the file field makes clap reject the combination at parse time — databases_tables_load_rejects_both_file_and_upload_id_at_parse_time already covers it. The (Some(_), Some(_)) => unreachable!() arm at line 473 confirms the invariant downstream. Safe to delete these four lines.

claude[bot]
claude Bot previously approved these changes May 19, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 53.07443% with 290 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/databases.rs 58.57% 232 Missing ⚠️
src/main.rs 0.00% 58 Missing ⚠️

📢 Thoughts on this report? Let us know!

Validate parquet extension before opening files, remove redundant managed-type check in get(), and drop dead runtime guard for conflicting load flags (clap already enforces).
claude[bot]
claude Bot previously approved these changes May 19, 2026
Add databases command reference, activation triggers, chain workflow, and parquet load workflow to the bundled hotdata skill.
@eddietejeda eddietejeda merged commit d43343d into main May 19, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant