Skip to content

test: clickhouse — finops query history, dbt profiles, and registry error hints#624

Open
anandgupta42 wants to merge 1 commit intomainfrom
test/hourly-20260403-1426
Open

test: clickhouse — finops query history, dbt profiles, and registry error hints#624
anandgupta42 wants to merge 1 commit intomainfrom
test/hourly-20260403-1426

Conversation

@anandgupta42
Copy link
Copy Markdown
Contributor

@anandgupta42 anandgupta42 commented Apr 3, 2026

Summary

Cover ClickHouse paths added in PR #574 that had zero test coverage, plus registry error hint tests for known-unsupported database types.

1. buildHistoryQuery ClickHouse branch — src/altimate/native/finops/query-history.ts (3 new tests)

The ClickHouse finops query history path uses __DAYS__/__LIMIT__ string interpolation (unlike other warehouses that use bind parameters), making input clamping correctness critical. Zero tests existed. New coverage includes:

  • SQL template correctness (system.query_log, QueryFinish, empty binds)
  • Integer clamping for extreme values (days clamped to [1, 365], limit to [1, 10000])
  • NaN and float safety — prevents today() - NaN or LIMIT 50.5 in generated SQL
  • Falsy-zero fallback behavior (0 triggers || 30 / || 100 defaults)

2. parseDbtProfiles ClickHouse adapter — src/altimate/native/connections/dbt-profiles.ts (1 new test)

The clickhouse entry was added to ADAPTER_TYPE_MAP but had no test verifying it maps correctly through the full parseDbtProfiles flow. A user with a ClickHouse adapter in their dbt profiles.yml would get silently skipped connections if this mapping broke. New coverage includes:

  • Full YAML → ConnectionConfig round-trip for ClickHouse adapter type
  • Field mapping correctness (host, port, user, database)

3. Registry known-unsupported database hints — src/altimate/native/connections/registry.ts (4 new tests)

The KNOWN_UNSUPPORTED map (cassandra, cockroachdb, timescaledb) provides friendlier error messages than the generic "Unsupported database type" error, but had zero test coverage. New coverage includes:

  • Cassandra: helpful "not yet supported" + cqlsh hint
  • CockroachDB: suggests using type: postgres instead
  • TimescaleDB: suggests using type: postgres instead
  • Truly unknown type (neo4j): generic error with supported type list

Type of change

  • New feature (non-breaking change which adds functionality)

Issue for this PR

N/A — proactive test coverage for ClickHouse paths added in PR #574

How did you verify your code works?

bun test test/altimate/schema-finops-dbt.test.ts  # 59 pass (56 existing + 3 new)
bun test test/altimate/connections.test.ts         # 78 pass (73 existing + 5 new)

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

https://claude.ai/code/session_01CB7m2CjEFJbJia3ZJKZpHN

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for connection registry error messaging for unsupported database types.
    • Added test coverage for ClickHouse adapter support in dbt profiles parsing.
    • Added comprehensive tests for ClickHouse query history generation, including parameter validation and edge case handling.

…rror hints

Cover ClickHouse paths added in PR #574 that had zero test coverage:
- buildHistoryQuery ClickHouse branch: SQL template correctness, integer clamping
  for days/limit (prevents NaN/float injection into string-interpolated SQL),
  and boundary values
- dbt profiles.yml ClickHouse adapter mapping (prevents silent connection skip)
- Registry known-unsupported DB hints (cassandra, cockroachdb, timescaledb) and
  generic unsupported error message

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

https://claude.ai/code/session_01CB7m2CjEFJbJia3ZJKZpHN
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 47ea5dd8-7868-447f-9565-446a4e957fbe

📥 Commits

Reviewing files that changed from the base of the PR and between 0d34855 and 1a57d9f.

📒 Files selected for processing (2)
  • packages/opencode/test/altimate/connections.test.ts
  • packages/opencode/test/altimate/schema-finops-dbt.test.ts

📝 Walkthrough

Walkthrough

Test coverage additions validate improved database connection error messaging, parser functionality for dbt profiles with ClickHouse adapters, and ClickHouse history query generation with parameter clamping and type safety.

Changes

Cohort / File(s) Summary
Database Connection Tests
packages/opencode/test/altimate/connections.test.ts
Added ConnectionRegistry tests for improved error messaging on unsupported database types (cassandra, cockroachdb, timescaledb, neo4j) and new dbt profiles parser test validating ClickHouse adapter mapping to connection objects with proper type and config fields.
FinOps Query History Tests
packages/opencode/test/altimate/schema-finops-dbt.test.ts
Added three ClickHouse HistoryTemplates.buildHistoryQuery tests validating SQL generation with system.query_log, parameter clamping (days: [1, 365], limit: [1, 10000]), and safe handling of NaN/float inputs with literal interpolation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested labels

contributor

Poem

🐰 With whiskers twitching, I test with glee,
ClickHouse queries, connections so free!
Databases parsed, errors made clear,
Parameters clamped without any fear—
Coverage blooms like clover so bright! 🍀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main changes: adding tests for ClickHouse finops query history, dbt profiles parsing, and registry error hints.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/hourly-20260403-1426

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dev-punia-altimate
Copy link
Copy Markdown

❌ Tests — Failures Detected

TypeScript — 15 failure(s)

  • connection_refused [2.61ms]
  • timeout [2.59ms]
  • permission_denied [2.80ms]
  • parse_error [2.58ms]
  • oom [2.85ms]
  • network_error [2.58ms]
  • auth_failure [2.82ms]
  • rate_limit [2.96ms]
  • internal_error [2.88ms]
  • empty_error [0.24ms]
  • connection_refused [0.14ms]
  • timeout [0.08ms]
  • permission_denied [0.08ms]
  • parse_error [0.08ms]
  • oom [0.07ms]

cc @anandgupta42
Tested at 1a57d9fa | Run log | Powered by QA Autopilot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants