This is an automated email from the ASF dual-hosted git repository.

houqp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/master by this push:
     new e6657f0  Improve error messages when operations are not supported 
(#1158)
e6657f0 is described below

commit e6657f0894df75de49833bc7497b7a73f8c8b4c0
Author: Andrew Lamb <[email protected]>
AuthorDate: Fri Oct 22 00:30:49 2021 -0400

    Improve error messages when operations are not supported (#1158)
---
 datafusion/src/physical_optimizer/pruning.rs       |  4 +--
 datafusion/src/physical_plan/expressions/binary.rs | 39 +++++++++++-----------
 2 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/datafusion/src/physical_optimizer/pruning.rs 
b/datafusion/src/physical_optimizer/pruning.rs
index 29a196d..ba01865 100644
--- a/datafusion/src/physical_optimizer/pruning.rs
+++ b/datafusion/src/physical_optimizer/pruning.rs
@@ -1382,7 +1382,7 @@ mod tests {
         let result = p.prune(&statistics).unwrap_err();
         assert!(
             result.to_string().contains(
-                "Data type Boolean not supported for scalar operation on dyn 
array"
+                "Data type Boolean not supported for scalar operation 'lt_eq' 
on dyn array"
             ),
             "{}",
             result
@@ -1399,7 +1399,7 @@ mod tests {
         let result = p.prune(&statistics).unwrap_err();
         assert!(
             result.to_string().contains(
-                "Data type Boolean not supported for scalar operation on dyn 
array"
+                "Data type Boolean not supported for scalar operation 'lt_eq' 
on dyn array"
             ),
             "{}",
             result
diff --git a/datafusion/src/physical_plan/expressions/binary.rs 
b/datafusion/src/physical_plan/expressions/binary.rs
index 4a3ef58..456e8d4 100644
--- a/datafusion/src/physical_plan/expressions/binary.rs
+++ b/datafusion/src/physical_plan/expressions/binary.rs
@@ -118,7 +118,8 @@ macro_rules! compute_utf8_op_scalar {
             )?))
         } else {
             Err(DataFusionError::Internal(format!(
-                "compute_utf8_op_scalar failed to cast literal value {}",
+                "compute_utf8_op_scalar for '{}' failed to cast literal value 
{}",
+                stringify!($OP),
                 $RIGHT
             )))
         }
@@ -171,8 +172,8 @@ macro_rules! binary_string_array_op_scalar {
         let result: Result<Arc<dyn Array>> = match $LEFT.data_type() {
             DataType::Utf8 => compute_utf8_op_scalar!($LEFT, $RIGHT, $OP, 
StringArray),
             other => Err(DataFusionError::Internal(format!(
-                "Data type {:?} not supported for scalar operation on string 
array",
-                other
+                "Data type {:?} not supported for scalar operation '{}' on 
string array",
+                other, stringify!($OP)
             ))),
         };
         Some(result)
@@ -184,8 +185,8 @@ macro_rules! binary_string_array_op {
         match $LEFT.data_type() {
             DataType::Utf8 => compute_utf8_op!($LEFT, $RIGHT, $OP, 
StringArray),
             other => Err(DataFusionError::Internal(format!(
-                "Data type {:?} not supported for binary operation on string 
arrays",
-                other
+                "Data type {:?} not supported for binary operation '{}' on 
string arrays",
+                other, stringify!($OP)
             ))),
         }
     }};
@@ -208,8 +209,8 @@ macro_rules! binary_primitive_array_op {
             DataType::Float32 => compute_op!($LEFT, $RIGHT, $OP, Float32Array),
             DataType::Float64 => compute_op!($LEFT, $RIGHT, $OP, Float64Array),
             other => Err(DataFusionError::Internal(format!(
-                "Data type {:?} not supported for binary operation on 
primitive arrays",
-                other
+                "Data type {:?} not supported for binary operation '{}' on 
primitive arrays",
+                other, stringify!($OP)
             ))),
         }
     }};
@@ -232,8 +233,8 @@ macro_rules! binary_primitive_array_op_scalar {
             DataType::Float32 => compute_op_scalar!($LEFT, $RIGHT, $OP, 
Float32Array),
             DataType::Float64 => compute_op_scalar!($LEFT, $RIGHT, $OP, 
Float64Array),
             other => Err(DataFusionError::Internal(format!(
-                "Data type {:?} not supported for scalar operation on 
primitive array",
-                other
+                "Data type {:?} not supported for scalar operation '{}' on 
primitive array",
+                other, stringify!($OP)
             ))),
         };
         Some(result)
@@ -276,8 +277,8 @@ macro_rules! binary_array_op_scalar {
                 compute_op_scalar!($LEFT, $RIGHT, $OP, Date64Array)
             }
             other => Err(DataFusionError::Internal(format!(
-                "Data type {:?} not supported for scalar operation on dyn 
array",
-                other
+                "Data type {:?} not supported for scalar operation '{}' on dyn 
array",
+                other, stringify!($OP)
             ))),
         };
         Some(result)
@@ -320,8 +321,8 @@ macro_rules! binary_array_op {
                 compute_op!($LEFT, $RIGHT, $OP, Date64Array)
             }
             other => Err(DataFusionError::Internal(format!(
-                "Data type {:?} not supported for binary operation on dyn 
arrays",
-                other
+                "Data type {:?} not supported for binary operation '{}' on dyn 
arrays",
+                other, stringify!($OP)
             ))),
         }
     }};
@@ -352,8 +353,8 @@ macro_rules! binary_string_array_flag_op {
                 compute_utf8_flag_op!($LEFT, $RIGHT, $OP, LargeStringArray, 
$NOT, $FLAG)
             }
             other => Err(DataFusionError::Internal(format!(
-                "Data type {:?} not supported for binary_string_array_flag_op 
operation on string array",
-                other
+                "Data type {:?} not supported for binary_string_array_flag_op 
operation '{}' on string array",
+                other, stringify!($OP)
             ))),
         }
     }};
@@ -394,8 +395,8 @@ macro_rules! binary_string_array_flag_op_scalar {
                 compute_utf8_flag_op_scalar!($LEFT, $RIGHT, $OP, 
LargeStringArray, $NOT, $FLAG)
             }
             other => Err(DataFusionError::Internal(format!(
-                "Data type {:?} not supported for 
binary_string_array_flag_op_scalar operation on string array",
-                other
+                "Data type {:?} not supported for 
binary_string_array_flag_op_scalar operation '{}' on string array",
+                other, stringify!($OP)
             ))),
         };
         Some(result)
@@ -420,8 +421,8 @@ macro_rules! compute_utf8_flag_op_scalar {
             Ok(Arc::new(array))
         } else {
             Err(DataFusionError::Internal(format!(
-                "compute_utf8_flag_op_scalar failed to cast literal value {}",
-                $RIGHT
+                "compute_utf8_flag_op_scalar failed to cast literal value {} 
for operation '{}'",
+                $RIGHT, stringify!($OP)
             )))
         }
     }};

Reply via email to