Skip to content

Commit

Permalink
[BUG]: error messages for add (#2990)
Browse files Browse the repository at this point in the history
if you tried to add utf8 to another unsupported dtype, it would result
in the incorrect error message of 'Cannot add types: {other}, {other}'
instead of 'Cannot add types: Utf8, {other}'

this fixes that error message
  • Loading branch information
universalmind303 authored Oct 3, 2024
1 parent fe4553f commit f3b998e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/daft-core/src/datatypes/infer_datatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,27 @@ impl<'a> Add for InferDataType<'a> {
(du_self @ &DataType::Duration(..), du_other @ &DataType::Duration(..)) => Err(DaftError::TypeError(
format!("Cannot add due to differing precision: {}, {}. Please explicitly cast to the precision you wish to add in.", du_self, du_other)
)),
(DataType::Null, other) | (other, DataType::Null) => {
(dtype @ DataType::Null, other) | (other, dtype @ DataType::Null) => {
match other {
// Condition is for backwards compatibility. TODO: remove
DataType::Binary | DataType::FixedSizeBinary(..) | DataType::Date => Err(DaftError::TypeError(
format!("Cannot add types: {}, {}", self, other)
format!("Cannot add types: {}, {}", dtype, other)
)),
other if other.is_physical() => Ok(other.clone()),
_ => Err(DaftError::TypeError(
format!("Cannot add types: {}, {}", self, other)
format!("Cannot add types: {}, {}", dtype, other)
)),
}
}
(DataType::Utf8, other) | (other, DataType::Utf8) => {
(dtype @ DataType::Utf8, other) | (other, dtype @ DataType::Utf8) => {
match other {
// DataType::Date condition is for backwards compatibility. TODO: remove
DataType::Binary | DataType::FixedSizeBinary(..) | DataType::Date => Err(DaftError::TypeError(
format!("Cannot add types: {}, {}", self, other)
format!("Cannot add types: {}, {}", dtype, other)
)),
other if other.is_physical() => Ok(DataType::Utf8),
_ => Err(DaftError::TypeError(
format!("Cannot add types: {}, {}", self, other)
format!("Cannot add types: {}, {}", dtype, other)
)),
}
}
Expand Down

0 comments on commit f3b998e

Please sign in to comment.