Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "datafusion-functions-json"
version = "0.47.0"
version = "0.48.0"
edition = "2021"
description = "JSON functions for DataFusion"
readme = "README.md"
Expand All @@ -11,16 +11,16 @@ repository = "https://github.com/datafusion-contrib/datafusion-functions-json/"
rust-version = "1.82.0"

[dependencies]
datafusion = { version = "47", default-features = false }
datafusion = { version = "48", default-features = false }
jiter = "0.9"
paste = "1"
log = "0.4"

[dev-dependencies]
datafusion = { version = "47", default-features = false, features = ["nested_expressions"] }
datafusion = { version = "48", default-features = false, features = [
"nested_expressions",
] }
codspeed-criterion-compat = "2.6"
criterion = "0.5.1"
clap = "4"
tokio = { version = "1.43", features = ["full"] }

[lints.clippy]
Expand Down
4 changes: 2 additions & 2 deletions src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn unnest_json_calls(func: &ScalarFunction) -> Option<Transformed<Expr>> {
let mut args = inner_func.args.clone();
args.extend(outer_args_iter.cloned());
// See #23, unnest only when all lookup arguments are literals
if args.iter().skip(1).all(|arg| matches!(arg, Expr::Literal(_))) {
if args.iter().skip(1).all(|arg| matches!(arg, Expr::Literal(_, _))) {
Some(Transformed::yes(Expr::ScalarFunction(ScalarFunction {
func: func.func.clone(),
args,
Expand Down Expand Up @@ -149,7 +149,7 @@ fn expr_to_sql_repr(expr: &Expr) -> String {
.as_ref()
.map_or_else(|| name.clone(), |r| format!("{r}.{name}")),
Expr::Alias(alias) => alias.name.clone(),
Expr::Literal(scalar) => match scalar {
Expr::Literal(scalar, _) => match scalar {
ScalarValue::Utf8(Some(v)) | ScalarValue::Utf8View(Some(v)) | ScalarValue::LargeUtf8(Some(v)) => {
format!("'{v}'")
}
Expand Down
14 changes: 12 additions & 2 deletions tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,13 @@ fn test_json_get_utf8() {
let ColumnarValue::Scalar(sv) = json_get_str
.invoke_with_args(ScalarFunctionArgs {
args: args.to_vec(),
arg_fields: vec![
Arc::new(Field::new("arg_1", DataType::LargeUtf8, false)),
Arc::new(Field::new("arg_2", DataType::LargeUtf8, false)),
Arc::new(Field::new("arg_3", DataType::LargeUtf8, false)),
],
number_rows: 1,
return_type: &DataType::Utf8,
return_field: Arc::new(Field::new("ret_field", DataType::Utf8, false)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mark these as json?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what do you mean by marking as json? Do you mean marking the return_field as a json type? This test case is expecting json_get_str to return a ScalarValue::Utf8.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let json_metadata: HashMap<String, String> =

})
.unwrap()
else {
Expand All @@ -528,8 +533,13 @@ fn test_json_get_large_utf8() {
let ColumnarValue::Scalar(sv) = json_get_str
.invoke_with_args(ScalarFunctionArgs {
args: args.to_vec(),
arg_fields: vec![
Arc::new(Field::new("arg_1", DataType::LargeUtf8, false)),
Arc::new(Field::new("arg_2", DataType::LargeUtf8, false)),
Arc::new(Field::new("arg_3", DataType::LargeUtf8, false)),
],
number_rows: 1,
return_type: &DataType::LargeUtf8,
return_field: Arc::new(Field::new("ret_field", DataType::Utf8, false)),
})
.unwrap()
else {
Expand Down
Loading