pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
26.63k stars 1.63k forks source link

Multipling a Decimal by Int returns Int type #16035

Closed philippspengler closed 1 week ago

philippspengler commented 2 weeks ago

Checks

Reproducible example

pl.DataFrame([0.12345678]).select(pl.col('column_0').cast(pl.Decimal(scale=6)) * 1)

Log output

shape: (1, 1)
┌──────────┐
│ column_0 │
│ ---      │
│ i32      │
╞══════════╡
│ 0        │
└──────────┘

Issue description

In previous versions of polars (<0.20.23), multiplying a Decimal type column with an integer resulted in a Decimal column. Since polars 0.20.23, polars converts the column to int type.

Expected behavior

shape: (1, 1) ┌────────────────┐ │ column_0 │ │ --- │ │ decimal[*,12] │ ╞════════════════╡ │ 0.123456000000 │ └────────────────┘

Installed versions

``` --------Version info--------- Polars: 0.20.23 Index type: UInt32 Platform: Linux-5.11.0-46-generic-x86_64-with-glibc2.31 Python: 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0] ----Optional dependencies---- adbc_driver_manager: cloudpickle: connectorx: deltalake: fastexcel: fsspec: 2024.3.1 gevent: hvplot: matplotlib: 3.8.4 nest_asyncio: 1.6.0 numpy: 1.23.0 openpyxl: pandas: 2.1.1 pyarrow: 15.0.2 pydantic: pyiceberg: pyxlsb: sqlalchemy: 1.4.52 xlsx2csv: xlsxwriter: ```
deanm0000 commented 2 weeks ago

@ritchie46 any chance it's from https://github.com/pola-rs/polars/pull/15879?

ritchie46 commented 1 week ago

Ah, yes.. That's related. Will take a look.