alamb commented on code in PR #11985:
URL: https://github.com/apache/datafusion/pull/11985#discussion_r1717563164


##########
datafusion/expr-common/src/type_coercion/binary.rs:
##########
@@ -1048,11 +1048,23 @@ pub fn like_coercion(lhs_type: &DataType, rhs_type: 
&DataType) -> Option<DataTyp
         .or_else(|| null_coercion(lhs_type, rhs_type))
 }
 
+/// coercion rules for regular expression comparison operations with NULL 
input.
+fn regex_null_coercion(lhs_type: &DataType, rhs_type: &DataType) -> 
Option<DataType> {
+    use arrow::datatypes::DataType::*;
+    match (lhs_type, rhs_type) {
+        (DataType::Null, Utf8View | Utf8 | LargeUtf8) => 
Some(rhs_type.clone()),
+        (Utf8View | Utf8 | LargeUtf8, DataType::Null) => 
Some(lhs_type.clone()),
+        (DataType::Null, DataType::Null) => Some(Utf8),

Review Comment:
   I wonder if there is any reason to explicitly list out the types?
   
   Like maybe you could simplify this a bit like
   
   ```rust
   let lhs_null = matches!(lhs_type, DataType::Null);
   let rhs_null = matches!(rhs_type, DataType::Null);
   math (lhs_null, rhs_null) {
     (true, false) => Some(rhs_type.clone()),
     (false, true) => Some(lhs_type.clone())
     (true, true) => Some(Utf8)
     (false, false) => None,
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to