Skip to content

Commit

Permalink
chore: more pattern cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed Sep 27, 2023
1 parent 8fdaf65 commit 6b8f92b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ibis/backends/clickhouse/compiler/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import ibis.expr.types as ir
from ibis.backends.clickhouse.compiler.relations import translate_rel
from ibis.backends.clickhouse.compiler.values import translate_val
from ibis.common.patterns import Call
from ibis.common.patterns import Call, _
from ibis.expr.analysis import c, p, x, y

if TYPE_CHECKING:
Expand Down Expand Up @@ -100,25 +100,24 @@ def fn(node, _, **kwargs):

# replace the right side of InColumn into a scalar subquery for sql
# backends
replace_in_column_with_table_array_view = p.InColumn(x, y) >> c.InColumn(
x,
c.TableArrayView(
replace_in_column_with_table_array_view = p.InColumn(..., y) >> _.copy(
options=c.TableArrayView(
c.Selection(table=a.find_first_base_table(y), selections=(y,))
),
)

# replace any checks against an empty right side of the IN operation with
# `False`
replace_empty_in_values_with_false = p.InValues(x, ()) >> c.Literal(
replace_empty_in_values_with_false = p.InValues(..., ()) >> c.Literal(
False, dtype="bool"
)

# replace `NotExistsSubquery` with `Not(ExistsSubquery)`
#
# this allows to avoid having another rule to negate ExistsSubquery
replace_notexists_subquery_with_not_exists = p.NotExistsSubquery(
x, predicates=y
) >> c.Not(c.ExistsSubquery(x, predicates=y))
replace_notexists_subquery_with_not_exists = p.NotExistsSubquery(...) >> c.Not(
c.ExistsSubquery(...)
)

# clickhouse-specific rewrite to turn notany/notall into equivalent
# already-defined operations
Expand Down

0 comments on commit 6b8f92b

Please sign in to comment.