Skip to content

Commit

Permalink
Suppress deprecation warnings in tests
Browse files Browse the repository at this point in the history
To be followed-up on.
  • Loading branch information
findepi committed Nov 2, 2024
1 parent 13e57b2 commit b15ff5e
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions datafusion/functions/src/datetime/date_bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ mod tests {
use chrono::TimeDelta;

#[test]
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
fn test_date_bin() {
let res = DateBinFunc::new().invoke(&[
ColumnarValue::Scalar(ScalarValue::IntervalDayTime(Some(IntervalDayTime {
Expand Down Expand Up @@ -781,6 +782,7 @@ mod tests {
.map(|s| Some(string_to_timestamp_nanos(s).unwrap()))
.collect::<TimestampNanosecondArray>()
.with_timezone_opt(tz_opt.clone());
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = DateBinFunc::new()
.invoke(&[
ColumnarValue::Scalar(ScalarValue::new_interval_dt(1, 0)),
Expand Down
2 changes: 2 additions & 0 deletions datafusion/functions/src/datetime/date_trunc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ mod tests {
.map(|s| Some(string_to_timestamp_nanos(s).unwrap()))
.collect::<TimestampNanosecondArray>()
.with_timezone_opt(tz_opt.clone());
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = DateTruncFunc::new()
.invoke(&[
ColumnarValue::Scalar(ScalarValue::from("day")),
Expand Down Expand Up @@ -882,6 +883,7 @@ mod tests {
.map(|s| Some(string_to_timestamp_nanos(s).unwrap()))
.collect::<TimestampNanosecondArray>()
.with_timezone_opt(tz_opt.clone());
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = DateTruncFunc::new()
.invoke(&[
ColumnarValue::Scalar(ScalarValue::from("hour")),
Expand Down
8 changes: 8 additions & 0 deletions datafusion/functions/src/datetime/make_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ mod tests {

#[test]
fn test_make_date() {
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let res = MakeDateFunc::new()
.invoke(&[
ColumnarValue::Scalar(ScalarValue::Int32(Some(2024))),
Expand All @@ -248,6 +249,7 @@ mod tests {
panic!("Expected a scalar value")
}

#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let res = MakeDateFunc::new()
.invoke(&[
ColumnarValue::Scalar(ScalarValue::Int64(Some(2024))),
Expand All @@ -262,6 +264,7 @@ mod tests {
panic!("Expected a scalar value")
}

#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let res = MakeDateFunc::new()
.invoke(&[
ColumnarValue::Scalar(ScalarValue::Utf8(Some("2024".to_string()))),
Expand All @@ -279,6 +282,7 @@ mod tests {
let years = Arc::new((2021..2025).map(Some).collect::<Int64Array>());
let months = Arc::new((1..5).map(Some).collect::<Int32Array>());
let days = Arc::new((11..15).map(Some).collect::<UInt32Array>());
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let res = MakeDateFunc::new()
.invoke(&[
ColumnarValue::Array(years),
Expand All @@ -304,6 +308,7 @@ mod tests {
//

// invalid number of arguments
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let res = MakeDateFunc::new()
.invoke(&[ColumnarValue::Scalar(ScalarValue::Int32(Some(1)))]);
assert_eq!(
Expand All @@ -312,6 +317,7 @@ mod tests {
);

// invalid type
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let res = MakeDateFunc::new().invoke(&[
ColumnarValue::Scalar(ScalarValue::IntervalYearMonth(Some(1))),
ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(Some(1), None)),
Expand All @@ -323,6 +329,7 @@ mod tests {
);

// overflow of month
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let res = MakeDateFunc::new().invoke(&[
ColumnarValue::Scalar(ScalarValue::Int32(Some(2023))),
ColumnarValue::Scalar(ScalarValue::UInt64(Some(u64::MAX))),
Expand All @@ -334,6 +341,7 @@ mod tests {
);

// overflow of day
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let res = MakeDateFunc::new().invoke(&[
ColumnarValue::Scalar(ScalarValue::Int32(Some(2023))),
ColumnarValue::Scalar(ScalarValue::Int32(Some(22))),
Expand Down
6 changes: 6 additions & 0 deletions datafusion/functions/src/datetime/to_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ mod tests {
];

for (value, format, expected) in scalar_data {
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = ToCharFunc::new()
.invoke(&[ColumnarValue::Scalar(value), ColumnarValue::Scalar(format)])
.expect("that to_char parsed values without error");
Expand Down Expand Up @@ -458,6 +459,7 @@ mod tests {
];

for (value, format, expected) in scalar_array_data {
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = ToCharFunc::new()
.invoke(&[
ColumnarValue::Scalar(value),
Expand Down Expand Up @@ -583,6 +585,7 @@ mod tests {
];

for (value, format, expected) in array_scalar_data {
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = ToCharFunc::new()
.invoke(&[
ColumnarValue::Array(value as ArrayRef),
Expand All @@ -599,6 +602,7 @@ mod tests {
}

for (value, format, expected) in array_array_data {
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = ToCharFunc::new()
.invoke(&[
ColumnarValue::Array(value),
Expand All @@ -619,6 +623,7 @@ mod tests {
//

// invalid number of arguments
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = ToCharFunc::new()
.invoke(&[ColumnarValue::Scalar(ScalarValue::Int32(Some(1)))]);
assert_eq!(
Expand All @@ -627,6 +632,7 @@ mod tests {
);

// invalid type
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = ToCharFunc::new().invoke(&[
ColumnarValue::Scalar(ScalarValue::Int32(Some(1))),
ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(Some(1), None)),
Expand Down
8 changes: 8 additions & 0 deletions datafusion/functions/src/datetime/to_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ mod tests {
}

fn test_scalar(sv: ScalarValue, tc: &TestCase) {
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let to_date_result = ToDateFunc::new().invoke(&[ColumnarValue::Scalar(sv)]);

match to_date_result {
Expand All @@ -233,6 +234,7 @@ mod tests {
A: From<Vec<&'static str>> + Array + 'static,
{
let date_array = A::from(vec![tc.date_str]);
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let to_date_result =
ToDateFunc::new().invoke(&[ColumnarValue::Array(Arc::new(date_array))]);

Expand Down Expand Up @@ -323,6 +325,7 @@ mod tests {
fn test_scalar(sv: ScalarValue, tc: &TestCase) {
let format_scalar = ScalarValue::Utf8(Some(tc.format_str.to_string()));

#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let to_date_result = ToDateFunc::new().invoke(&[
ColumnarValue::Scalar(sv),
ColumnarValue::Scalar(format_scalar),
Expand All @@ -347,6 +350,7 @@ mod tests {
let date_array = A::from(vec![tc.formatted_date]);
let format_array = A::from(vec![tc.format_str]);

#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let to_date_result = ToDateFunc::new().invoke(&[
ColumnarValue::Array(Arc::new(date_array)),
ColumnarValue::Array(Arc::new(format_array)),
Expand Down Expand Up @@ -382,6 +386,7 @@ mod tests {
let format1_scalar = ScalarValue::Utf8(Some("%Y-%m-%d".into()));
let format2_scalar = ScalarValue::Utf8(Some("%Y/%m/%d".into()));

#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let to_date_result = ToDateFunc::new().invoke(&[
ColumnarValue::Scalar(formatted_date_scalar),
ColumnarValue::Scalar(format1_scalar),
Expand Down Expand Up @@ -410,6 +415,7 @@ mod tests {
for date_str in test_cases {
let formatted_date_scalar = ScalarValue::Utf8(Some(date_str.into()));

#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let to_date_result =
ToDateFunc::new().invoke(&[ColumnarValue::Scalar(formatted_date_scalar)]);

Expand All @@ -428,6 +434,7 @@ mod tests {
let date_str = "20241231";
let date_scalar = ScalarValue::Utf8(Some(date_str.into()));

#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let to_date_result =
ToDateFunc::new().invoke(&[ColumnarValue::Scalar(date_scalar)]);

Expand All @@ -449,6 +456,7 @@ mod tests {
let date_str = "202412311";
let date_scalar = ScalarValue::Utf8(Some(date_str.into()));

#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let to_date_result =
ToDateFunc::new().invoke(&[ColumnarValue::Scalar(date_scalar)]);

Expand Down
1 change: 0 additions & 1 deletion datafusion/functions/src/datetime/to_unixtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use super::to_timestamp::ToTimestampSecondsFunc;
use crate::datetime::common::*;
use arrow::datatypes::{DataType, TimeUnit};
use criterion::BatchSize;
use datafusion_common::{exec_err, Result};
use datafusion_expr::scalar_doc_sections::DOC_SECTION_DATETIME;
use datafusion_expr::{
Expand Down
1 change: 1 addition & 0 deletions datafusion/functions/src/string/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ mod tests {
])));
let args = &[c0, c1, c2];

#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = ConcatFunc::new().invoke(args)?;
let expected =
Arc::new(StringArray::from(vec!["foo,x", "bar,", "baz,z"])) as ArrayRef;
Expand Down
2 changes: 2 additions & 0 deletions datafusion/functions/src/string/concat_ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ mod tests {
])));
let args = &[c0, c1, c2];

#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = ConcatWsFunc::new().invoke(args)?;
let expected =
Arc::new(StringArray::from(vec!["foo,x", "bar", "baz,z"])) as ArrayRef;
Expand All @@ -492,6 +493,7 @@ mod tests {
])));
let args = &[c0, c1, c2];

#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = ConcatWsFunc::new().invoke(args)?;
let expected =
Arc::new(StringArray::from(vec![Some("foo,x"), None, Some("baz+z")]))
Expand Down
1 change: 1 addition & 0 deletions datafusion/functions/src/string/contains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ mod test {
Some("yyy?()"),
])));
let scalar = ColumnarValue::Scalar(ScalarValue::Utf8(Some("x?(".to_string())));
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let actual = udf.invoke(&[array, scalar]).unwrap();
let expect = ColumnarValue::Array(Arc::new(BooleanArray::from(vec![
Some(true),
Expand Down
1 change: 1 addition & 0 deletions datafusion/functions/src/string/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ mod tests {
fn to_lower(input: ArrayRef, expected: ArrayRef) -> Result<()> {
let func = LowerFunc::new();
let args = vec![ColumnarValue::Array(input)];
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = match func.invoke(&args)? {
ColumnarValue::Array(result) => result,
_ => unreachable!(),
Expand Down
1 change: 1 addition & 0 deletions datafusion/functions/src/string/upper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ mod tests {
fn to_upper(input: ArrayRef, expected: ArrayRef) -> Result<()> {
let func = UpperFunc::new();
let args = vec![ColumnarValue::Array(input)];
#[allow(deprecated)] // TODO migrate UDF invoke to invoke_batch
let result = match func.invoke(&args)? {
ColumnarValue::Array(result) => result,
_ => unreachable!(),
Expand Down

0 comments on commit b15ff5e

Please sign in to comment.