Skip to content

Commit

Permalink
refactor(patterns): support more flexible sequence matching
Browse files Browse the repository at this point in the history
- improve the implementation of `PatternSequence` and related supplemental patterns
- `TupleOf` pattern now aligns with `*Of` naming to match sequence of a single pattern rather than a tuple of patterns
- remove reduntand object creation logic for alternative but more performant implementations of certain patterns
- support the unpacking syntax to turn patterns into a `SomeOf` pattern
- short circuit `SequenceOf(Any())` to not traverse over the input sequence
- remove unused `PatternMapping` pattern
  • Loading branch information
kszucs committed Nov 6, 2023
1 parent ef5bdf9 commit b8e463d
Show file tree
Hide file tree
Showing 3 changed files with 322 additions and 317 deletions.
4 changes: 2 additions & 2 deletions ibis/backends/clickhouse/compiler/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ 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(..., y) >> _.copy(
replace_in_column_with_table_array_view = p.InColumn(options=y) >> _.copy(
options=c.TableArrayView(
c.Selection(table=lambda _, y: 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(..., ()) >> c.Literal(
replace_empty_in_values_with_false = p.InValues(options=()) >> c.Literal(
False, dtype="bool"
)

Expand Down
Loading

0 comments on commit b8e463d

Please sign in to comment.