-
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.
add list getter (no overrideable default)
- Loading branch information
1 parent
a994c7b
commit a7b5e5e
Showing
9 changed files
with
196 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::Expr; | ||
use daft_core::{datatypes::Field, schema::Schema, series::Series}; | ||
|
||
use common_error::{DaftError, DaftResult}; | ||
|
||
use super::super::FunctionEvaluator; | ||
|
||
pub(super) struct GetEvaluator {} | ||
|
||
impl FunctionEvaluator for GetEvaluator { | ||
fn fn_name(&self) -> &'static str { | ||
"get" | ||
} | ||
|
||
fn to_field(&self, inputs: &[Expr], schema: &Schema, _: &Expr) -> DaftResult<Field> { | ||
match inputs { | ||
[input, idx] => { | ||
let input_field = input.to_field(schema)?; | ||
let idx_field = idx.to_field(schema)?; | ||
|
||
if !idx_field.dtype.is_integer() { | ||
return Err(DaftError::TypeError(format!( | ||
"Expected get index to be integer, received: {}", | ||
idx_field.dtype | ||
))); | ||
} | ||
|
||
let exploded_field = input_field.to_exploded_field()?; | ||
Ok(exploded_field) | ||
} | ||
_ => Err(DaftError::SchemaMismatch(format!( | ||
"Expected 2 input args, got {}", | ||
inputs.len() | ||
))), | ||
} | ||
} | ||
|
||
fn evaluate(&self, inputs: &[Series], _: &Expr) -> DaftResult<Series> { | ||
match inputs { | ||
[input, idx] => Ok(input.list_get(idx)?), | ||
_ => Err(DaftError::ValueError(format!( | ||
"Expected 2 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