-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EXPRESSIONS] Implement Expression.float.is_inf (#2371)
Resolves #2316. Signed-off-by: Tai Le Manh <[email protected]>
- Loading branch information
Showing
15 changed files
with
195 additions
and
0 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
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,51 @@ | ||
use daft_core::{ | ||
datatypes::{DataType, Field}, | ||
schema::Schema, | ||
series::Series, | ||
}; | ||
|
||
use crate::ExprRef; | ||
|
||
use crate::functions::FunctionExpr; | ||
use common_error::{DaftError, DaftResult}; | ||
|
||
use super::super::FunctionEvaluator; | ||
|
||
pub(super) struct IsInfEvaluator {} | ||
|
||
impl FunctionEvaluator for IsInfEvaluator { | ||
fn fn_name(&self) -> &'static str { | ||
"is_inf" | ||
} | ||
|
||
fn to_field(&self, inputs: &[ExprRef], schema: &Schema, _: &FunctionExpr) -> DaftResult<Field> { | ||
match inputs { | ||
[data] => match data.to_field(schema) { | ||
Ok(data_field) => match &data_field.dtype { | ||
// DataType::Float16 | | ||
DataType::Float32 | DataType::Float64 => { | ||
Ok(Field::new(data_field.name, DataType::Boolean)) | ||
} | ||
_ => Err(DaftError::TypeError(format!( | ||
"Expects input to is_inf to be float, but received {data_field}", | ||
))), | ||
}, | ||
Err(e) => Err(e), | ||
}, | ||
_ => Err(DaftError::SchemaMismatch(format!( | ||
"Expected 1 input args, got {}", | ||
inputs.len() | ||
))), | ||
} | ||
} | ||
|
||
fn evaluate(&self, inputs: &[Series], _: &FunctionExpr) -> DaftResult<Series> { | ||
match inputs { | ||
[data] => data.is_inf(), | ||
_ => Err(DaftError::ValueError(format!( | ||
"Expected 1 input args, got {}", | ||
inputs.len() | ||
))), | ||
} | ||
} | ||
} |
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