Skip to content

Commit

Permalink
fix[rust]: melt default value name was wrong in predicate pushdown (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Aug 14, 2022
1 parent f2829dc commit d63c884
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl PredicatePushDown {
schema,
} => {
let variable_name = args.variable_name.as_deref().unwrap_or("variable");
let value_name = args.value_name.as_deref().unwrap_or("value_name");
let value_name = args.value_name.as_deref().unwrap_or("value");

// predicates that will be done at this level
let condition = |name: Arc<str>| {
Expand Down
17 changes: 17 additions & 0 deletions py-polars/tests/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,20 @@ def test_simplify_expression_lit_true_4376() -> None:
assert df.lazy().filter((pl.col("column_0") == 1) | pl.lit(True)).collect(
simplify_expression=True
).shape == (3, 3)


def test_melt_values_predicate_pushdown() -> None:
lf = pl.DataFrame(
{
"id": [1],
"asset_key_1": ["123"],
"asset_key_2": ["456"],
"asset_key_3": ["abc"],
}
).lazy()

assert (
lf.melt("id", ["asset_key_1", "asset_key_2", "asset_key_3"])
.filter(pl.col("value") == pl.lit("123"))
.collect()
).to_dict(False) == {"id": [1], "variable": ["asset_key_1"], "value": ["123"]}

0 comments on commit d63c884

Please sign in to comment.