Skip to content

Commit

Permalink
fix(clickhouse): raise OperationNotDefinedError if operation is not s…
Browse files Browse the repository at this point in the history
…upported
  • Loading branch information
krzysztof-kwitt authored and cpcloud committed Jan 30, 2023
1 parent 813c95e commit 71e2570
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
3 changes: 2 additions & 1 deletion ibis/backends/clickhouse/compiler/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import sqlglot as sg

import ibis.common.exceptions as com
import ibis.expr.datatypes as dt
import ibis.expr.operations as ops
from ibis.backends.clickhouse.compiler.values import translate_val
Expand All @@ -13,7 +14,7 @@
@functools.singledispatch
def translate_rel(op: ops.TableNode, **_):
"""Translate a table node into sqlglot."""
raise NotImplementedError(type(op))
raise com.OperationNotDefinedError(f'No translation rule for {type(op)}')


@translate_rel.register(ops.DummyTable)
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/clickhouse/compiler/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@functools.singledispatch
def translate_val(op, **_):
"""Translate a value expression into sqlglot."""
raise NotImplementedError(type(op))
raise com.OperationNotDefinedError(f'No translation rule for {type(op)}')


@translate_val.register(dt.DataType)
Expand Down
14 changes: 2 additions & 12 deletions ibis/backends/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,15 +1055,10 @@ def test_exists(batting, awards_players, method_name):
},
marks=[
pytest.mark.broken(
['impala'],
['clickhouse', 'impala'],
"No translation rule for <class 'ibis.expr.operations.temporal.DateFromYMD'>",
raises=com.OperationNotDefinedError,
),
pytest.mark.broken(
['clickhouse'],
"<class 'ibis.expr.operations.temporal.DateFromYMD'>",
raises=NotImplementedError,
),
],
id="date",
),
Expand All @@ -1079,12 +1074,7 @@ def test_exists(batting, awards_players, method_name):
},
marks=[
pytest.mark.broken(
['clickhouse'],
"<class 'ibis.expr.operations.temporal.TimeFromHMS'>",
raises=NotImplementedError,
),
pytest.mark.broken(
['impala'],
['clickhouse', 'impala'],
"No translation rule for <class 'ibis.expr.operations.temporal.TimeFromHMS'>",
raises=com.OperationNotDefinedError,
),
Expand Down

0 comments on commit 71e2570

Please sign in to comment.