Skip to content

Commit

Permalink
fix: Don't prune alias in function subtree (#15406)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Mar 31, 2024
1 parent 59ff950 commit cd1994b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 1 addition & 7 deletions crates/polars-plan/src/logical_plan/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,7 @@ fn to_aexpr_impl(expr: Expr, arena: &mut Arena<AExpr>, state: &mut ConversionSta
function,
options,
} => {
match function {
#[cfg(feature = "dtype-struct")]
FunctionExpr::AsStruct => {
state.prune_alias = false;
},
_ => {},
}
state.prune_alias = false;
AExpr::Function {
input: to_aexprs(input, arena, state),
function,
Expand Down
5 changes: 5 additions & 0 deletions py-polars/tests/unit/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,3 +638,8 @@ def test_literal_subtract_schema_13284() -> None:
def test_schema_boolean_sum_horizontal() -> None:
lf = pl.LazyFrame({"a": [True, False]}).select(pl.sum_horizontal("a"))
assert lf.schema == OrderedDict([("a", pl.UInt32)])


def test_struct_alias_prune_15401() -> None:
df = pl.DataFrame({"a": []}, schema={"a": pl.Struct({"b": pl.Int8})})
assert df.select(pl.col("a").alias("c").struct.field("b")).columns == ["b"]

0 comments on commit cd1994b

Please sign in to comment.