Skip to content

Commit

Permalink
Single quotes not backticks in errors to match DataFusion (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin authored May 5, 2024
1 parent 62743e3 commit fa40d57
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use jiter::{Jiter, JiterError, Peek};

pub fn check_args(args: &[DataType], fn_name: &str) -> DataFusionResult<()> {
let Some(first) = args.first() else {
return plan_err!("The `{fn_name}` function requires one or more arguments.");
return plan_err!("The '{fn_name}' function requires one or more arguments.");
};
if !matches!(first, DataType::Utf8 | DataType::LargeUtf8) {
return plan_err!("Unexpected argument type to `{fn_name}` at position 1, expected a string.");
return plan_err!("Unexpected argument type to '{fn_name}' at position 1, expected a string.");
}
args[1..].iter().enumerate().try_for_each(|(index, arg)| match arg {
DataType::Utf8 | DataType::LargeUtf8 | DataType::UInt64 | DataType::Int64 => Ok(()),
_ => plan_err!(
"Unexpected argument type to `{fn_name}` at position {}, expected string or int.",
"Unexpected argument type to '{fn_name}' at position {}, expected string or int.",
index + 2
),
})
Expand Down
2 changes: 1 addition & 1 deletion src/json_contains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl ScalarUDFImpl for JsonContains {

fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
if arg_types.len() < 2 {
plan_err!("The `json_contains` function requires two or more arguments.")
plan_err!("The 'json_contains' function requires two or more arguments.")
} else {
check_args(arg_types, self.name()).map(|()| DataType::Boolean)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async fn test_json_get_str_null() {

assert_eq!(
e.to_string(),
"Error during planning: Unexpected argument type to `json_get_str` at position 2, expected string or int."
"Error during planning: Unexpected argument type to 'json_get_str' at position 2, expected string or int."
);
}

Expand Down

0 comments on commit fa40d57

Please sign in to comment.