Skip to content

Conversation

@kesmit13
Copy link
Collaborator

Add mixin classes that extend the Ibis SingleStoreDB backend and ir.Table with SingleStoreDB-specific functionality:

  • BackendExtensionsMixin: variable/show accessors (globals, locals, cluster_globals, cluster_locals, vars, cluster_vars, show), plus get_storage_info(), get_workload_metrics(), optimize_table(), and get_table_stats() methods

  • TableExtensionsMixin: optimize(), get_stats(), and get_column_statistics() methods for SingleStoreDB tables

The mixins are automatically registered on import via dynamic base class injection. Protocol classes are used for type checking to satisfy mypy while keeping runtime behavior unchanged.

Add mixin classes that extend the Ibis SingleStoreDB backend and ir.Table
with SingleStoreDB-specific functionality:

- BackendExtensionsMixin: variable/show accessors (globals, locals,
  cluster_globals, cluster_locals, vars, cluster_vars, show), plus
  get_storage_info(), get_workload_metrics(), optimize_table(), and
  get_table_stats() methods

- TableExtensionsMixin: optimize(), get_stats(), and get_column_statistics()
  methods for SingleStoreDB tables

The mixins are automatically registered on import via dynamic base class
injection. Protocol classes are used for type checking to satisfy mypy
while keeping runtime behavior unchanged.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new ibis_extras package that extends the Ibis SingleStoreDB backend with SingleStoreDB-specific functionality through mixin classes that are automatically injected into the backend and table classes at import time.

Changes:

  • Adds BackendExtensionsMixin with variable/show accessors and new methods for storage info, workload metrics, table optimization, and statistics
  • Adds TableExtensionsMixin with table-specific methods for optimization, statistics, and column statistics
  • Implements automatic mixin registration via dynamic base class modification

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 12 comments.

File Description
singlestoredb/ibis_extras/mixins.py Defines mixin classes with SingleStoreDB-specific extensions for backend and table operations, including SQL helper functions for identifier quoting and string escaping
singlestoredb/ibis_extras/init.py Implements automatic registration mechanism that modifies base classes at import time, with collision detection for existing methods/properties

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add error handling for optional ibis imports with informative message
- Remove sqlglot dependency, use backtick quoting for identifiers
- Fix database context assumption in table methods by extracting
  database from table's namespace metadata
- Table methods now correctly pass database to backend methods

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Update _get_table_backend_and_db() to always return resolved database
  name with optional escape parameter ('identifier', 'literal', or None)
- Move optimize_table() implementation to TableExtensionsMixin.optimize()
- Move get_table_stats() implementation to TableExtensionsMixin.get_stats()
- Simplify get_column_statistics() to use new escape parameter
- Remove optimize_table() and get_table_stats() from BackendExtensionsMixin
- Update __init__.py docstring to remove backend method reference

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Return ir.Table instead of dict to match get_storage_info() and
get_column_statistics(). This provides lazy evaluation and lets
users work with the data however they prefer.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

2 participants