-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathimpl_variant_get.rs
More file actions
46 lines (39 loc) · 1.19 KB
/
impl_variant_get.rs
File metadata and controls
46 lines (39 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
macro_rules! impl_variant_get_typed {
(
$(#[$meta:meta])*
$struct_name:ident,
$func_name:expr,
$return_type:expr,
$scalar_from:expr,
$array_from:expr,
$extract:expr $(,)?
) => {
$(#[$meta])*
#[derive(Debug, Hash, PartialEq, Eq)]
pub struct $struct_name {
signature: Signature,
}
impl Default for $struct_name {
fn default() -> Self {
Self {
signature: Signature::new(TypeSignature::Any(2), Volatility::Immutable),
}
}
}
impl ScalarUDFImpl for $struct_name {
fn name(&self) -> &str {
$func_name
}
fn signature(&self) -> &Signature {
&self.signature
}
fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
Ok($return_type)
}
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
invoke_variant_get_typed(args, $scalar_from, $array_from, $extract)
}
}
};
}
pub(crate) use impl_variant_get_typed;