Skip to content

Commit 6857751

Browse files
AndrewRookcpcloud
authored andcommitted
fix(decompile): handle isin
1 parent b20a790 commit 6857751

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

ibis/expr/decompile.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ def binary(op, left, right):
286286
return f"{left} {operator} {right}"
287287

288288

289+
@translate.register(ops.InValues)
290+
def isin(op, value, options):
291+
return f"{value}.isin(({', '.join([str(option) for option in options])}))"
292+
293+
289294
class CodeContext:
290295
always_assign = (ops.ScalarParameter, ops.UnboundTable, ops.Aggregation)
291296
always_ignore = (ops.TableColumn, dt.Primitive, dt.Variadic, dt.Temporal)

ibis/expr/tests/test_decompile.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
name="countries",
2121
)
2222
asian_countries = countries.filter(countries.continent == "AS")
23+
eurasian_countries = countries.filter(countries.continent.isin(("AS", "EUR")))
2324
top_with_highest_population = asian_countries.order_by(
2425
asian_countries.population.desc()
2526
).limit(10)
@@ -51,13 +52,15 @@ def test_decompile_invalid_type():
5152
(top_with_highest_population, top_with_highest_population),
5253
(overall_population_density, overall_population_density),
5354
(population_density_per_country, population_density_per_country),
55+
(eurasian_countries, eurasian_countries),
5456
(three, 3),
5557
(nine, nine_),
5658
],
5759
ids=[
5860
"top_with_highest_population",
5961
"overall_population_density",
6062
"population_density_per_country",
63+
"eurasian_countries",
6164
"three",
6265
"nine",
6366
],

0 commit comments

Comments
 (0)