Skip to content

chore(ibis): DEBT-1 - drop the last two lazy mountainash imports - #105

Merged
discreteds merged 1 commit into
developfrom
chore/debt-1-remove-mountainash-import
Aug 19, 2026
Merged

chore(ibis): DEBT-1 - drop the last two lazy mountainash imports#105
discreteds merged 1 commit into
developfrom
chore/debt-1-remove-mountainash-import

Conversation

@discreteds

Copy link
Copy Markdown
Member

Summary

Closes DEBT-1 - removes the last two lazy import mountainash as ma call sites in the ibis backend (_generic_index_exists in _index.py, IbisBackend.list_indexes in backend.py). Both were reading an ibis .sql() result via ma.relation(result).to_dict()/.to_dicts(). mountainash is not declared as a dependency in pyproject.toml, so any environment without it installed would crash the first time index_exists/list_indexes ran.

Fix (Option C, per backlog)

Replaced both with native ibis result.to_pyarrow():

  • _generic_index_exists: .column(0).to_pylist() - reads the COUNT column by position, preserving the exact behavior the ma.relation workaround existed for (Oracle upper-cases the unquoted count alias to COUNT, so keying by name would KeyError).
  • list_indexes: .to_pylist() - same list[dict] row shape as ma.relation(result).to_dicts().

Zero remaining import mountainash in src/.

Tests

  • New: TestIndexExistsReadsColumnByPosition (test_index_ops.py) - exercises _generic_index_exists against a mismatched-alias exists_sql_fn (simulates Oracle's uppercasing) to lock in the positional-read contract.
  • Strengthened: test_list_indexes (test_backend.py) - now asserts exact row-dict keys/values instead of just list length.
  • Verified functionally with mountainash import blocked at runtime (both sqlite and duckdb dialects) - confirms the actual DEBT-1 bug premise (crash when mountainash isn't installed) no longer reproduces.

Verification

tests/test_unit/backends/ibis/{test_index_ops,test_backend}.py: 86 passed
tests/test_unit/: 724 passed, 5 skipped (pre-existing, unrelated)
ruff check (touched files): All checks passed
mypy (touched files): Success, no issues

Generated with assistance from an AI coding agent.

_generic_index_exists (_index.py) and IbisBackend.list_indexes (backend.py)
each did a call-time 'import mountainash as ma' to read an ibis .sql()
result (ma.relation(result).to_dict()/.to_dicts()), the only two
remaining sites after PR #93's cutover deleted the module-level
dependency. mountainash is not declared in pyproject.toml, so any
environment without it installed would crash on first index op.

Replaced with native ibis result.to_pyarrow():
- _generic_index_exists: .column(0).to_pylist() - preserves the
  positional (not alias-name) read Oracle's uppercased COUNT alias
  requires.
- list_indexes: .to_pylist() - same list[dict] shape as
  ma.relation().to_dicts().

Added regression coverage: _generic_index_exists tested against a
mismatched-alias exists_sql_fn (simulates Oracle's uppercasing) to
lock in the positional-read contract; list_indexes strengthened to
assert exact row-dict keys/values instead of just list length.
Verified functionally with the mountainash import blocked at runtime.
@sonarqubecloud

Copy link
Copy Markdown

@discreteds
discreteds merged commit cb82007 into develop Aug 19, 2026
6 checks passed
@discreteds
discreteds deleted the chore/debt-1-remove-mountainash-import branch August 19, 2026 05:46
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