Skip to content

Commit

Permalink
fix(rust): Decimal mean agg dtype was incorrect in IR (#18577)
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp authored Sep 6, 2024
1 parent 325dfd1 commit e94ada3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/polars-core/src/scalar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use polars_utils::pl_str::PlSmallStr;
use crate::datatypes::{AnyValue, DataType};
use crate::prelude::Series;

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct Scalar {
dtype: DataType,
value: AnyValue<'static>,
Expand Down
13 changes: 9 additions & 4 deletions crates/polars-plan/src/plans/aexpr/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ use recursive::recursive;
use super::*;

fn float_type(field: &mut Field) {
if (field.dtype.is_numeric() || field.dtype == DataType::Boolean)
&& field.dtype != DataType::Float32
{
field.coerce(DataType::Float64)
let should_coerce = match &field.dtype {
DataType::Float32 => false,
#[cfg(feature = "dtype-decimal")]
DataType::Decimal(..) => true,
DataType::Boolean => true,
dt => dt.is_numeric(),
};
if should_coerce {
field.coerce(DataType::Float64);
}
}

Expand Down

0 comments on commit e94ada3

Please sign in to comment.