Skip to content

Commit

Permalink
fix: Decimal supertype for dyn int (#16046)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored May 4, 2024
1 parent fd0ae1d commit e84fe69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/polars-core/src/utils/supertype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ pub fn get_supertype(l: &DataType, r: &DataType) -> Option<DataType> {
}
}
}
UnknownKind::Int(_) if dt.is_decimal() => Some(dt.clone()),
_ => Some(Unknown(UnknownKind::Any))
}
},
Expand Down
10 changes: 10 additions & 0 deletions py-polars/tests/unit/datatypes/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,13 @@ def test_decimal_streaming() -> None:
D("161102921617598.363263936811563000"),
],
}


def test_decimal_supertype() -> None:
with pl.Config() as cfg:
cfg.activate_decimals()
pl.Config.activate_decimals()
q = pl.LazyFrame([0.12345678]).select(
pl.col("column_0").cast(pl.Decimal(scale=6)) * 1
)
assert q.collect().dtypes[0].is_decimal()

0 comments on commit e84fe69

Please sign in to comment.