Skip to content

Commit

Permalink
refactor(backends): remove singledispatchmethod from the sql backends (
Browse files Browse the repository at this point in the history
…ibis-project#8338)

## Description of changes

This pull request does two things:

1. Removes use of `singledispatchmethod` in the SQL compilers
1. Fixes the support matrix accuracy for SQL backends

Follow-ups:

* ~Deal with filtering out RisingWave geospatial~ Handled here
* `__init_subclass__` for `SIMPLE_OPS` handled here
* Fix coverage accuracy for the non-SQL backends

## Issues closed

Fixes ibis-project#8283.

Thanks to @jcrist for the `__init_subclass__` tip, that saved N backends
duplication of filling in undefined operations.
  • Loading branch information
cpcloud authored Feb 14, 2024
1 parent 9b9556b commit 78dc393
Show file tree
Hide file tree
Showing 35 changed files with 711 additions and 1,467 deletions.
2 changes: 0 additions & 2 deletions docs/support_matrix.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ hide:

```{python}
#| echo: false
from pathlib import Path
import pandas as pd
import ibis
Expand Down
10 changes: 6 additions & 4 deletions ibis/backends/base/sqlglot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ def dialect(self) -> sg.Dialect:

@classmethod
def has_operation(cls, operation: type[ops.Value]) -> bool:
# singledispatchmethod overrides `__get__` so we can't directly access
# the dispatcher
dispatcher = cls.compiler.visit_node.register.__self__.dispatcher
return dispatcher.dispatch(operation) is not dispatcher.dispatch(object)
compiler = cls.compiler
method = getattr(compiler, f"visit_{operation.__name__}", None)
return method is not None and method not in (
compiler.visit_Undefined,
compiler.visit_Unsupported,
)

def _fetch_from_cursor(self, cursor, schema: sch.Schema) -> pd.DataFrame:
import pandas as pd
Expand Down
Loading

0 comments on commit 78dc393

Please sign in to comment.