Skip to content

Commit fe20268

Browse files
committed
remove argument checks
1 parent f71b883 commit fe20268

1 file changed

Lines changed: 2 additions & 16 deletions

File tree

src/json_from_scalar.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,8 @@ impl ScalarUDFImpl for JsonFromScalar {
4848
}
4949

5050
fn return_type(&self, arg_types: &[DataType]) -> DataFusionResult<DataType> {
51-
if arg_types.len() != 1 {
52-
return plan_err!(
53-
"The '{}' function requires exactly one argument, got {}",
54-
self.name(),
55-
arg_types.len()
56-
);
57-
}
5851
// Check that the input type is a scalar type that we can convert to JSON
59-
match arg_types[0] {
52+
match arg_types[0] { // The signature check ensures we only get one argument
6053
DataType::Null
6154
| DataType::Boolean
6255
| DataType::Int8
@@ -80,14 +73,7 @@ impl ScalarUDFImpl for JsonFromScalar {
8073
}
8174

8275
fn invoke_with_args(&self, mut args: ScalarFunctionArgs) -> DataFusionResult<ColumnarValue> {
83-
if args.args.len() != 1 {
84-
return exec_err!(
85-
"The '{}' function requires exactly one argument, got {}",
86-
self.name(),
87-
args.args.len()
88-
);
89-
}
90-
76+
// The signature check ensures we only get one argument
9177
match args.args.pop().expect("Expected exactly one argument") {
9278
ColumnarValue::Scalar(scalar) => {
9379
let field = scalar_to_json_union_field(scalar)?;

0 commit comments

Comments
 (0)