-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement IntoIterator for list types
- Loading branch information
1 parent
005e434
commit ce971a8
Showing
6 changed files
with
117 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use common_error::{DaftError, DaftResult}; | ||
|
||
use super::DataType; | ||
|
||
/// Get the data type that the sum of a column of the given data type should be casted to. | ||
pub fn try_sum_supertype(dtype: &DataType) -> DaftResult<DataType> { | ||
use DataType::*; | ||
match dtype { | ||
Int8 | Int16 | Int32 | Int64 => Ok(Int64), | ||
UInt8 | UInt16 | UInt32 | UInt64 => Ok(UInt64), | ||
Float32 => Ok(Float32), | ||
Float64 => Ok(Float64), | ||
other => Err(DaftError::TypeError(format!( | ||
"Invalid argument to sum supertype: {}", | ||
other | ||
))), | ||
} | ||
} | ||
|
||
/// Get the data type that the mean of a column of the given data type should be casted to. | ||
pub fn try_mean_supertype(dtype: &DataType) -> DaftResult<DataType> { | ||
use DataType::*; | ||
if dtype.is_numeric() { | ||
Ok(Float64) | ||
} else { | ||
Err(DaftError::TypeError(format!( | ||
"Invalid argument to mean supertype: {}", | ||
dtype | ||
))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters