From 6206694343411913c06bd61bf0345e2f6cd7d858 Mon Sep 17 00:00:00 2001 From: jackwener Date: Thu, 9 Feb 2023 17:59:59 +0800 Subject: [PATCH 1/3] fix: fix expect error in test `cast_string_to_time` --- datafusion/core/tests/sql/timestamp.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/datafusion/core/tests/sql/timestamp.rs b/datafusion/core/tests/sql/timestamp.rs index fc9b99f14dd0..38225d192651 100644 --- a/datafusion/core/tests/sql/timestamp.rs +++ b/datafusion/core/tests/sql/timestamp.rs @@ -1070,7 +1070,9 @@ async fn cast_string_to_time() { let result = try_execute_to_batches(&ctx, sql).await; assert_eq!( result.err().unwrap().to_string(), - "Arrow error: Cast error: Cannot cast string 'not a time' to value of Time64(Nanosecond) type" + "simplify_expressions\ncaused by\nInternal error: Optimizer rule 'simplify_expressions' failed due to unexpected error: \ + Arrow error: Cast error: Cannot cast string 'not a time' to value of Time64(Nanosecond) type. \ + This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker" ); // An invalid time @@ -1078,7 +1080,9 @@ async fn cast_string_to_time() { let result = try_execute_to_batches(&ctx, sql).await; assert_eq!( result.err().unwrap().to_string(), - "Arrow error: Cast error: Cannot cast string '24:01:02' to value of Time64(Nanosecond) type" + "simplify_expressions\ncaused by\nInternal error: Optimizer rule 'simplify_expressions' failed due to unexpected error: \ + Arrow error: Cast error: Cannot cast string '24:01:02' to value of Time64(Nanosecond) type. \ + This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker" ); } From ee54b5a51c4d02f6d6090c96e214323c2a215e2d Mon Sep 17 00:00:00 2001 From: jackwener Date: Thu, 9 Feb 2023 18:18:18 +0800 Subject: [PATCH 2/3] fix: fix expect error in test `in_list_types_struct_literal` --- datafusion/core/src/physical_plan/planner.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/datafusion/core/src/physical_plan/planner.rs b/datafusion/core/src/physical_plan/planner.rs index 65b4a6ed462c..40cee14a0c9d 100644 --- a/datafusion/core/src/physical_plan/planner.rs +++ b/datafusion/core/src/physical_plan/planner.rs @@ -2191,7 +2191,12 @@ mod tests { .build()?; let e = plan(&logical_plan).await.unwrap_err().to_string(); - assert_contains!(&e, "The data type inlist should be same, the value type is Boolean, one of list expr type is Struct([Field { name: \"foo\", data_type: Boolean, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }])"); + assert_contains!( + &e, + r#"type_coercion +caused by +Internal error: Optimizer rule 'type_coercion' failed due to unexpected error: Error during planning: Can not find compatible types to compare Boolean with [Struct([Field { name: "foo", data_type: Boolean, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }]), Utf8]. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker"# + ); Ok(()) } From cef3735f10710a79230718a1e5d29f565579b320 Mon Sep 17 00:00:00 2001 From: jackwener Date: Fri, 10 Feb 2023 14:09:25 +0800 Subject: [PATCH 3/3] bugfix: fix error when `get_coerced_window_frame` meet `utf8` --- datafusion/core/src/physical_plan/planner.rs | 3 +-- datafusion/core/tests/sql/timestamp.rs | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/datafusion/core/src/physical_plan/planner.rs b/datafusion/core/src/physical_plan/planner.rs index 40cee14a0c9d..b6269a560386 100644 --- a/datafusion/core/src/physical_plan/planner.rs +++ b/datafusion/core/src/physical_plan/planner.rs @@ -1892,8 +1892,7 @@ mod tests { fn make_session_state() -> SessionState { let runtime = Arc::new(RuntimeEnv::default()); let config = SessionConfig::new().with_target_partitions(4); - // TODO we should really test that no optimizer rules are failing here - // let config = config.set_bool(crate::config::OPT_OPTIMIZER_SKIP_FAILED_RULES, false); + let config = config.set_bool("datafusion.optimizer.skip_failed_rules", false); SessionState::with_config_rt(config, runtime) } diff --git a/datafusion/core/tests/sql/timestamp.rs b/datafusion/core/tests/sql/timestamp.rs index 38225d192651..128ee1639e3f 100644 --- a/datafusion/core/tests/sql/timestamp.rs +++ b/datafusion/core/tests/sql/timestamp.rs @@ -17,6 +17,7 @@ use super::*; use datafusion::from_slice::FromSlice; +use datafusion_common::ScalarValue; use std::ops::Add; #[tokio::test] @@ -1046,7 +1047,11 @@ async fn sub_interval_day() -> Result<()> { #[tokio::test] async fn cast_string_to_time() { - let ctx = SessionContext::new(); + let config = SessionConfig::new().set( + "datafusion.optimizer.skip_failed_rules", + ScalarValue::Boolean(Some(false)), + ); + let ctx = SessionContext::with_config(config); let sql = "select \ time '08:09:10.123456789' as time_nano, \