Skip to content

re-enable sort_query_fuzzer_runner #16491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions datafusion/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ apache-avro = { version = "0.17", default-features = false, features = [
arrow = { workspace = true }
arrow-ipc = { workspace = true }
base64 = "0.22.1"
chrono = { workspace = true }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is temporary until the upstream bug gets fixed in arrow, plus it's necessarily already in the dependency tree because arrow uses it.

half = { workspace = true }
hashbrown = { workspace = true }
indexmap = { workspace = true }
Expand Down
48 changes: 39 additions & 9 deletions datafusion/common/src/scalar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ use arrow::compute::kernels::{
};
use arrow::datatypes::{
i256, ArrowDictionaryKeyType, ArrowNativeType, ArrowTimestampType, DataType,
Date32Type, Date64Type, Field, Float32Type, Int16Type, Int32Type, Int64Type,
Int8Type, IntervalDayTimeType, IntervalMonthDayNanoType, IntervalUnit,
IntervalYearMonthType, TimeUnit, TimestampMicrosecondType, TimestampMillisecondType,
Date32Type, Field, Float32Type, Int16Type, Int32Type, Int64Type, Int8Type,
IntervalDayTimeType, IntervalMonthDayNanoType, IntervalUnit, IntervalYearMonthType,
TimeUnit, TimestampMicrosecondType, TimestampMillisecondType,
TimestampNanosecondType, TimestampSecondType, UInt16Type, UInt32Type, UInt64Type,
UInt8Type, UnionFields, UnionMode, DECIMAL128_MAX_PRECISION,
};
use arrow::util::display::{array_value_to_string, ArrayFormatter, FormatOptions};
use chrono::{Duration, NaiveDate};
use half::f16;
pub use struct_builder::ScalarStructBuilder;

Expand Down Expand Up @@ -3816,12 +3817,28 @@ impl fmt::Display for ScalarValue {
ScalarValue::List(arr) => fmt_list(arr.to_owned() as ArrayRef, f)?,
ScalarValue::LargeList(arr) => fmt_list(arr.to_owned() as ArrayRef, f)?,
ScalarValue::FixedSizeList(arr) => fmt_list(arr.to_owned() as ArrayRef, f)?,
ScalarValue::Date32(e) => {
format_option!(f, e.map(|v| Date32Type::to_naive_date(v).to_string()))?
}
ScalarValue::Date64(e) => {
format_option!(f, e.map(|v| Date64Type::to_naive_date(v).to_string()))?
}
ScalarValue::Date32(e) => format_option!(
f,
e.map(|v| {
let epoch = NaiveDate::from_ymd_opt(1970, 1, 1).unwrap();
match epoch.checked_add_signed(Duration::try_days(v as i64).unwrap())
{
Some(date) => date.to_string(),
None => "".to_string(),
}
})
)?,
ScalarValue::Date64(e) => format_option!(
f,
e.map(|v| {
let epoch = NaiveDate::from_ymd_opt(1970, 1, 1).unwrap();
match epoch.checked_add_signed(Duration::try_milliseconds(v).unwrap())
{
Some(date) => date.to_string(),
None => "".to_string(),
}
})
)?,
ScalarValue::Time32Second(e) => format_option!(f, e)?,
ScalarValue::Time32Millisecond(e) => format_option!(f, e)?,
ScalarValue::Time64Microsecond(e) => format_option!(f, e)?,
Expand Down Expand Up @@ -7229,6 +7246,19 @@ mod tests {
");
}

#[test]
fn test_display_date64_large_values() {
assert_eq!(
format!("{}", ScalarValue::Date64(Some(790179464505))),
"1995-01-15"
);
// This used to panic, see https://github.com/apache/arrow-rs/issues/7728
assert_eq!(
format!("{}", ScalarValue::Date64(Some(-790179464505600000))),
""
);
}

#[test]
fn test_struct_display_null() {
let fields = vec![Field::new("a", DataType::Int32, false)];
Expand Down
1 change: 0 additions & 1 deletion datafusion/core/tests/fuzz_cases/sort_query_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ use super::record_batch_generator::{get_supported_types_columns, RecordBatchGene
///
/// Now memory limiting is disabled by default. See TODOs in `SortQueryFuzzer`.
#[tokio::test(flavor = "multi_thread")]
#[ignore = "https://github.com/apache/datafusion/issues/16452"]
async fn sort_query_fuzzer_runner() {
let random_seed = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
Expand Down