From d873c11dad0e13f1e934a62ae999f057a7cb2d57 Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Mon, 11 Jan 2021 22:14:42 +0300 Subject: [PATCH] ARROW-11209: [Rust] DF - Provider better error message on unsupported GROUP BY --- rust/arrow/src/datatypes.rs | 6 ++++++ rust/datafusion/src/physical_plan/hash_aggregate.rs | 7 ++++--- rust/datafusion/src/physical_plan/hash_join.rs | 7 ++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/rust/arrow/src/datatypes.rs b/rust/arrow/src/datatypes.rs index 3c525937fa5..95ee4d286b4 100644 --- a/rust/arrow/src/datatypes.rs +++ b/rust/arrow/src/datatypes.rs @@ -956,6 +956,12 @@ impl ToByteSlice for T { } } +impl fmt::Display for DataType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:?}", self) + } +} + impl DataType { /// Parse a data type from a JSON representation pub(crate) fn from(json: &Value) -> Result { diff --git a/rust/datafusion/src/physical_plan/hash_aggregate.rs b/rust/datafusion/src/physical_plan/hash_aggregate.rs index b17b8ef609c..a902584b391 100644 --- a/rust/datafusion/src/physical_plan/hash_aggregate.rs +++ b/rust/datafusion/src/physical_plan/hash_aggregate.rs @@ -828,9 +828,10 @@ pub(crate) fn create_group_by_values( } _ => { // This is internal because we should have caught this before. - return Err(DataFusionError::Internal( - "Unsupported GROUP BY data type".to_string(), - )); + return Err(DataFusionError::Internal(format!( + "Unsupported GROUP BY for {}", + col.data_type(), + ))); } } } diff --git a/rust/datafusion/src/physical_plan/hash_join.rs b/rust/datafusion/src/physical_plan/hash_join.rs index e9119bdddd8..7ed06792b03 100644 --- a/rust/datafusion/src/physical_plan/hash_join.rs +++ b/rust/datafusion/src/physical_plan/hash_join.rs @@ -449,9 +449,10 @@ pub(crate) fn create_key( } _ => { // This is internal because we should have caught this before. - return Err(DataFusionError::Internal( - "Unsupported GROUP BY data type".to_string(), - )); + return Err(DataFusionError::Internal(format!( + "Unsupported GROUP BY for {}", + col.data_type(), + ))); } } }