Skip to content

Commit

Permalink
reface signature
Browse files Browse the repository at this point in the history
  • Loading branch information
dharanad committed Aug 30, 2024
1 parent f645c7e commit 0fd7313
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
20 changes: 8 additions & 12 deletions datafusion/functions-nested/src/map_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use crate::utils::{get_map_entry_field, make_scalar_function};
use arrow_array::{Array, ArrayRef, ListArray};
use arrow_schema::{DataType, Field};
use datafusion_common::{cast::as_map_array, exec_err, Result};
use datafusion_expr::{ColumnarValue, ScalarUDFImpl, Signature, Volatility};
use datafusion_expr::{
ArrayFunctionSignature, ColumnarValue, ScalarUDFImpl, Signature, TypeSignature,
Volatility,
};
use std::any::Any;
use std::sync::Arc;

Expand All @@ -41,7 +44,10 @@ pub(crate) struct MapKeysFunc {
impl MapKeysFunc {
pub fn new() -> Self {
Self {
signature: Signature::user_defined(Volatility::Immutable),
signature: Signature::new(
TypeSignature::ArraySignature(ArrayFunctionSignature::MapArray),
Volatility::Immutable,
),
}
}
}
Expand Down Expand Up @@ -75,16 +81,6 @@ impl ScalarUDFImpl for MapKeysFunc {
fn invoke(&self, args: &[ColumnarValue]) -> datafusion_common::Result<ColumnarValue> {
make_scalar_function(map_keys_inner)(args)
}

fn coerce_types(
&self,
arg_types: &[DataType],
) -> datafusion_common::Result<Vec<DataType>> {
if arg_types.len() != 1 {
return exec_err!("map_keys expects single argument");
}
Ok(vec![arg_types[0].clone()])
}
}

fn map_keys_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
Expand Down
20 changes: 8 additions & 12 deletions datafusion/functions-nested/src/map_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use crate::utils::{get_map_entry_field, make_scalar_function};
use arrow_array::{Array, ArrayRef, ListArray};
use arrow_schema::{DataType, Field};
use datafusion_common::{cast::as_map_array, exec_err, Result};
use datafusion_expr::{ColumnarValue, ScalarUDFImpl, Signature, Volatility};
use datafusion_expr::{
ArrayFunctionSignature, ColumnarValue, ScalarUDFImpl, Signature, TypeSignature,
Volatility,
};
use std::any::Any;
use std::sync::Arc;

Expand All @@ -41,7 +44,10 @@ pub(crate) struct MapValuesFunc {
impl MapValuesFunc {
pub fn new() -> Self {
Self {
signature: Signature::user_defined(Volatility::Immutable),
signature: Signature::new(
TypeSignature::ArraySignature(ArrayFunctionSignature::MapArray),
Volatility::Immutable,
),
}
}
}
Expand Down Expand Up @@ -75,16 +81,6 @@ impl ScalarUDFImpl for MapValuesFunc {
fn invoke(&self, args: &[ColumnarValue]) -> datafusion_common::Result<ColumnarValue> {
make_scalar_function(map_values_inner)(args)
}

fn coerce_types(
&self,
arg_types: &[DataType],
) -> datafusion_common::Result<Vec<DataType>> {
if arg_types.len() != 1 {
return exec_err!("map_values expects single argument");
}
Ok(vec![arg_types[0].clone()])
}
}

fn map_values_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
Expand Down

0 comments on commit 0fd7313

Please sign in to comment.