Skip to content

Commit d8a0bf1

Browse files
update to datafusion 46 (#75)
Co-authored-by: Adrian Garcia Badaracco <[email protected]>
1 parent 1620453 commit d8a0bf1

File tree

6 files changed

+49
-19
lines changed

6 files changed

+49
-19
lines changed

Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ license = "Apache-2.0"
88
keywords = ["datafusion", "JSON", "SQL"]
99
categories = ["database-implementations", "parsing"]
1010
repository = "https://github.com/datafusion-contrib/datafusion-functions-json/"
11-
rust-version = "1.81.0"
11+
rust-version = "1.82.0"
1212

1313
[dependencies]
14-
datafusion = { version = "45", default-features = false }
15-
jiter = "0.8"
14+
datafusion = { version = "46", default-features = false }
15+
jiter = "0.9"
1616
paste = "1"
1717
log = "0.4"
1818

1919
[dev-dependencies]
20-
datafusion = { version = "45", default-features = false, features = ["nested_expressions"] }
20+
datafusion = { version = "46", default-features = false, features = ["nested_expressions"] }
2121
codspeed-criterion-compat = "2.6"
2222
criterion = "0.5.1"
2323
clap = "4"
24-
tokio = { version = "1.38", features = ["full"] }
24+
tokio = { version = "1.43", features = ["full"] }
2525

2626
[lints.clippy]
2727
dbg_macro = "deny"

src/json_length.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ make_udf_function!(
1414
JsonLength,
1515
json_length,
1616
json_data path,
17-
r#"Get the length of the array or object at the given path."#
17+
r"Get the length of the array or object at the given path."
1818
);
1919

2020
#[derive(Debug)]

src/json_object_keys.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ make_udf_function!(
1414
JsonObjectKeys,
1515
json_object_keys,
1616
json_data path,
17-
r#"Get the keys of a JSON object as an array."#
17+
r"Get the keys of a JSON object as an array."
1818
);
1919

2020
#[derive(Debug)]

src/rewrite.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ impl std::fmt::Display for JsonOperator {
141141
/// Convert an Expr to a String representatiion for use in alias names.
142142
fn expr_to_sql_repr(expr: &Expr) -> String {
143143
match expr {
144-
Expr::Column(Column { name, relation }) => relation
144+
Expr::Column(Column {
145+
name,
146+
relation,
147+
spans: _,
148+
}) => relation
145149
.as_ref()
146150
.map_or_else(|| name.clone(), |r| format!("{r}.{name}")),
147151
Expr::Alias(alias) => alias.name.clone(),

tests/main.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1310,9 +1310,12 @@ fn check_for_null_dictionary_values(array: &dyn Array) {
13101310
if values_array.is_null(i) {
13111311
// keys should not contain
13121312
if keys.contains(&i) {
1313-
println!("keys: {:?}", keys);
1314-
println!("values: {:?}", values_array);
1315-
panic!("keys should not contain null values");
1313+
#[allow(clippy::print_stdout)]
1314+
{
1315+
println!("keys: {keys:?}");
1316+
println!("values: {values_array:?}");
1317+
panic!("keys should not contain null values");
1318+
}
13161319
}
13171320
}
13181321
}
@@ -1341,7 +1344,7 @@ async fn test_dict_get_no_null_values() {
13411344
"| |",
13421345
"+------------+",
13431346
];
1344-
let batches = ctx.sql(&sql).await.unwrap().collect().await.unwrap();
1347+
let batches = ctx.sql(sql).await.unwrap().collect().await.unwrap();
13451348
assert_batches_eq!(expected, &batches);
13461349
for batch in batches {
13471350
check_for_null_dictionary_values(batch.column(0).as_ref());
@@ -1352,7 +1355,7 @@ async fn test_dict_get_no_null_values() {
13521355
"+------+", "| v |", "+------+", "| |", "| fizz |", "| |", "| abcd |", "| |", "| fizz |",
13531356
"| fizz |", "| fizz |", "| fizz |", "| |", "+------+",
13541357
];
1355-
let batches = ctx.sql(&sql).await.unwrap().collect().await.unwrap();
1358+
let batches = ctx.sql(sql).await.unwrap().collect().await.unwrap();
13561359
assert_batches_eq!(expected, &batches);
13571360
for batch in batches {
13581361
check_for_null_dictionary_values(batch.column(0).as_ref());

tests/utils/mod.rs

+29-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub async fn create_context() -> Result<SessionContext> {
2020
Ok(ctx)
2121
}
2222

23+
#[expect(clippy::too_many_lines)]
2324
async fn create_test_table(large_utf8: bool, dict_encoded: bool) -> Result<SessionContext> {
2425
let ctx = create_context().await?;
2526

@@ -42,7 +43,7 @@ async fn create_test_table(large_utf8: bool, dict_encoded: bool) -> Result<Sessi
4243
if dict_encoded {
4344
json_data_type = DataType::Dictionary(DataType::Int32.into(), json_data_type.into());
4445
json_array = Arc::new(DictionaryArray::<Int32Type>::new(
45-
Int32Array::from_iter_values(0..(json_array.len() as i32)),
46+
Int32Array::from_iter_values(0..(i32::try_from(json_array.len()).expect("fits in a i32"))),
4647
json_array,
4748
));
4849
}
@@ -160,13 +161,23 @@ async fn create_test_table(large_utf8: bool, dict_encoded: bool) -> Result<Sessi
160161
])),
161162
vec![
162163
Arc::new(DictionaryArray::<UInt32Type>::new(
163-
UInt32Array::from_iter_values(dict_data.iter().enumerate().map(|(id, _)| id as u32)),
164+
UInt32Array::from_iter_values(
165+
dict_data
166+
.iter()
167+
.enumerate()
168+
.map(|(id, _)| u32::try_from(id).expect("fits in a u32")),
169+
),
164170
Arc::new(StringArray::from(
165171
dict_data.iter().map(|(json, _, _, _)| *json).collect::<Vec<_>>(),
166172
)),
167173
)),
168174
Arc::new(DictionaryArray::<UInt8Type>::new(
169-
UInt8Array::from_iter_values(dict_data.iter().enumerate().map(|(id, _)| id as u8)),
175+
UInt8Array::from_iter_values(
176+
dict_data
177+
.iter()
178+
.enumerate()
179+
.map(|(id, _)| u8::try_from(id).expect("fits in a u8")),
180+
),
170181
Arc::new(LargeStringArray::from(
171182
dict_data
172183
.iter()
@@ -175,7 +186,12 @@ async fn create_test_table(large_utf8: bool, dict_encoded: bool) -> Result<Sessi
175186
)),
176187
)),
177188
Arc::new(DictionaryArray::<UInt8Type>::new(
178-
UInt8Array::from_iter_values(dict_data.iter().enumerate().map(|(id, _)| id as u8)),
189+
UInt8Array::from_iter_values(
190+
dict_data
191+
.iter()
192+
.enumerate()
193+
.map(|(id, _)| u8::try_from(id).expect("fits in a u8")),
194+
),
179195
Arc::new(StringViewArray::from(
180196
dict_data
181197
.iter()
@@ -184,9 +200,16 @@ async fn create_test_table(large_utf8: bool, dict_encoded: bool) -> Result<Sessi
184200
)),
185201
)),
186202
Arc::new(DictionaryArray::<Int64Type>::new(
187-
Int64Array::from_iter_values(dict_data.iter().enumerate().map(|(id, _)| id as i64)),
203+
Int64Array::from_iter_values(
204+
dict_data
205+
.iter()
206+
.enumerate()
207+
.map(|(id, _)| i64::try_from(id).expect("fits in a i64")),
208+
),
188209
Arc::new(UInt64Array::from_iter_values(
189-
dict_data.iter().map(|(_, _, _, int_key)| *int_key as u64),
210+
dict_data
211+
.iter()
212+
.map(|(_, _, _, int_key)| u64::try_from(*int_key).expect("not negative")),
190213
)),
191214
)),
192215
],

0 commit comments

Comments
 (0)