Skip to content

feat: IbisBackend as single handle — settings-aware constructor + operations + lifecycle#80

Merged
discreteds merged 12 commits into
developfrom
feature/settings-aware-ibis-backend
Apr 27, 2026
Merged

feat: IbisBackend as single handle — settings-aware constructor + operations + lifecycle#80
discreteds merged 12 commits into
developfrom
feature/settings-aware-ibis-backend

Conversation

@discreteds

@discreteds discreteds commented Apr 27, 2026

Copy link
Copy Markdown
Member

Summary

  • Phase 1: Make IbisBackend settings-aware — accept SettingsParameters, URLs, and dialect keywords via three-way constructor dispatch
  • Phase 2+3 (collapsed): Make IbisBackend the single public handle for all ibis interaction — lifecycle management, fluent operations API, and hook-dispatched per-dialect operations via DialectSpec
  • Cleanup: Delete ConnectionFactory, OperationsFactory, SettingsFactory, DatabaseUtils, BaseIbisConnection + 12 subclasses, BaseIbisOperations + concrete subclasses
  • Rewrite all tests to use IbisBackend directly

What Changed

New capabilities on IbisBackend

  • connect() / close() return self (fluent)
  • Context manager: with IbisBackend(...) as backend:
  • Thin wrapper operations: create_table, drop_table, insert, truncate, create_view, drop_view
  • Hook-dispatched operations: upsert, create_index, drop_index, index_exists, list_indexes
  • Accessor methods: ibis_connection() (raw ibis), get_connection() (internal wrapper)
  • Inspection: list_tables, inspect_table, inspect_catalog, etc.

DialectSpec expansion

  • New hook fields: upsert_hook, create_index_hook, drop_index_hook, rename_table_hook
  • DuckDB/SQLite/MotherDuck wired with standalone hook functions extracted from old mixin

Deleted

  • core/factories/ (entire directory)
  • core/utils.py (DatabaseUtils)
  • backends/ibis/connection.py (BaseIbisConnection + 12 subclasses)
  • BaseIbisOperations class hierarchy from operations.py
  • Connection protocol from protocol.py
  • All factory/utils/legacy connection test files

Kept

  • core/connection.py (BaseDBConnection — Iceberg depends on it)
  • Settings classes unchanged
  • IcebergBackend updated for protocol compliance

Test plan

  • 281 tests pass, 5 skipped, 0 failures
  • Lifecycle tests: connect/close/context manager/double-close/use-before-connect
  • Fluent API tests: chaining, returns self
  • Thin wrapper tests: create_table, drop_table, insert, truncate, table, run_sql
  • Hook tests: upsert (DuckDB), create_index/drop_index/index_exists/list_indexes (SQLite + DuckDB)
  • Unsupported operation raises NotImplementedError
  • Integration tests rewritten
  • Zero stale imports of deleted modules

🤖 Generated with Claude Code

discreteds and others added 3 commits April 27, 2026 13:47
…lidation

Add _SCHEME_TO_DIALECT map, three-way dispatch (settings, URL, dialect),
empty-list normalization in connect(), and URL-direct via ibis.connect().
Error cases tested: no args, both args, unknown scheme.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…arameters support

Extend IbisBackend constructor to accept three input forms:
- SettingsParameters (positional) — resolves via descriptor.ibis_dialect + to_driver_kwargs()
- Connection URL (positional) — detects dialect from scheme, delegates to ibis.connect()
- dialect= keyword + **config — existing path, unchanged

Adds _SCHEME_TO_DIALECT reverse lookup, empty-list normalization in connect(),
and 8 new tests covering settings, URL, and error paths.

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

Old spec bundled to_relation() which has been descoped per revised
principle. New spec focuses solely on settings-aware IbisBackend
constructor (Phase 1 of connection consolidation).

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

codecov Bot commented Apr 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.18919% with 106 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.35%. Comparing base (9b2b9e2) to head (57ec49f).
⚠️ Report is 6 commits behind head on develop.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/mountainash_data/backends/ibis/backend.py 76.47% 31 Missing and 13 partials ⚠️
src/mountainash_data/backends/iceberg/backend.py 0.00% 30 Missing ⚠️
src/mountainash_data/backends/ibis/operations.py 60.00% 16 Missing and 8 partials ⚠️
src/mountainash_data/core/protocol.py 20.00% 0 Missing and 8 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #80      +/-   ##
===========================================
- Coverage    55.82%   50.35%   -5.48%     
===========================================
  Files           51       43       -8     
  Lines         2556     1855     -701     
  Branches       270      259      -11     
===========================================
- Hits          1427      934     -493     
+ Misses        1021      813     -208     
  Partials       108      108              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

discreteds and others added 9 commits April 27, 2026 16:44
Collapses connection consolidation Phases 2+3 into a single phase:
make IbisBackend the single public handle for all ibis interaction
by absorbing operations via DialectSpec hooks, adding fluent API,
and deleting factories/DatabaseUtils/legacy class hierarchies.

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

- Keep core/connection.py (BaseDBConnection) — Iceberg depends on it
- Document Redshift URL ambiguity and resolution
- Add explicit compatibility section (internal package, no deprecation needed)
- Add out-of-scope section for Iceberg migration and future dialect hooks

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7 tasks: protocol+lifecycle, DialectSpec hooks, operations on backend,
IcebergBackend update, delete legacy code, rewrite tests, validation.

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

connect() and close() return self for fluent chaining. Context manager
support via __enter__/__exit__. Inspection methods delegate to internal
IbisConnection. Backend protocol updated: connect() returns Self,
Connection protocol removed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add upsert_hook, create_index_hook, drop_index_hook, rename_table_hook
to DialectSpec. Extract standalone hook functions from
_DuckDBFamilyOperationsMixin. Wire DuckDB/SQLite/MotherDuck entries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fluent methods (create_table, insert, upsert, create_index, etc.) return
self. Terminal methods (table, run_sql, list_indexes, etc.) return data.
Hook dispatch: upsert/index operations via DialectSpec callables.

One deviation from spec: truncate() omits the schema kwarg when calling
ibis truncate_table() because SQLBackend does not accept it at the base
level; schema is preserved in the method signature for future dialects.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
connect() returns self, context manager support, inspection methods
delegate to internal connection.

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

Remove ConnectionFactory, OperationsFactory, SettingsFactory, DatabaseUtils,
BaseIbisConnection + 12 subclasses, BaseIbisOperations + concrete subclasses.
Keep BaseDBConnection (Iceberg depends on it).
Update __init__.py to export only Backend, IbisBackend, IcebergBackend,
and inspection model.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Delete factory tests, DatabaseUtils tests, legacy connection tests,
and legacy operations tests. Rewrite integration tests and settings
parametrized tests to use IbisBackend directly. Update package
structure tests to verify removed exports are gone.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@discreteds discreteds changed the title feat(backend): settings-aware IbisBackend (Phase 1) feat: IbisBackend as single handle — settings-aware constructor + operations + lifecycle Apr 27, 2026
@discreteds discreteds merged commit 7cf6738 into develop Apr 27, 2026
7 of 8 checks passed
@discreteds discreteds deleted the feature/settings-aware-ibis-backend branch April 27, 2026 13:17
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