-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] Add basic list aggregations (#2032)
- Loading branch information
1 parent
3e73d74
commit 93fc6ca
Showing
23 changed files
with
700 additions
and
114 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
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 | ||
))) | ||
} | ||
} |
Oops, something went wrong.