-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup serializable function + null_count expr (#3247)
- Loading branch information
Showing
17 changed files
with
203 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use super::*; | ||
use polars_core::prelude::*; | ||
#[cfg(feature = "serde")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
#[derive(Clone, PartialEq, Debug)] | ||
pub enum FunctionExpr { | ||
NullCount, | ||
} | ||
|
||
impl FunctionExpr { | ||
pub(crate) fn get_field( | ||
&self, | ||
_input_schema: &Schema, | ||
_cntxt: Context, | ||
fields: &[Field], | ||
) -> Result<Field> { | ||
use FunctionExpr::*; | ||
match self { | ||
NullCount => Ok(Field::new(fields[0].name(), IDX_DTYPE)), | ||
} | ||
} | ||
} | ||
|
||
macro_rules! wrap { | ||
($e:expr) => { | ||
NoEq::new(Arc::new($e)) | ||
}; | ||
} | ||
|
||
impl From<FunctionExpr> for NoEq<Arc<dyn SeriesUdf>> { | ||
fn from(func: FunctionExpr) -> Self { | ||
use FunctionExpr::*; | ||
match func { | ||
NullCount => { | ||
let f = |s: &mut [Series]| { | ||
let s = &s[0]; | ||
Ok(Series::new(s.name(), [s.null_count() as IdxSize])) | ||
}; | ||
wrap!(f) | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.