martin-g commented on code in PR #3647:
URL: https://github.com/apache/datafusion-comet/pull/3647#discussion_r2916945340


##########
native/spark-expr/src/predicate_funcs/rlike.rs:
##########
@@ -165,3 +181,26 @@ impl PhysicalExpr for RLike {
         Display::fmt(self, f)
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use datafusion::physical_expr::expressions::Literal;
+
+    #[test]
+    fn test_rlike_scalar_utf8_literal() {
+        let expr = RLike::try_new(
+            
Arc::new(Literal::new(ScalarValue::Utf8(Some("Rose".to_string())))),

Review Comment:
   This tests the happy path (`Utf8(Some)`).
   It would be good to also add a test case for `Utf8(None)`.
   
   You could also extend it to cover the LargeUtf8 and Utf8View paths too:
   ```rust
   for scalar in &[ScalarValue::Utf8(Some("Utf8".to_string())), 
ScalarValue::LargeUtf8(Some("LargeUtf8".to_string())), 
ScalarValue::Utf8View(Some("Utf8View".to_string()))] { ... }
   ```
   
   and some non-Utf8 type, e.g. ScalarValue::Boolean to trigger the error.



##########
native/spark-expr/src/predicate_funcs/rlike.rs:
##########
@@ -140,8 +140,24 @@ impl PhysicalExpr for RLike {
                 let array = self.is_match(inputs);
                 Ok(ColumnarValue::Array(Arc::new(array)))
             }
-            ColumnarValue::Scalar(_) => {
-                internal_err!("non scalar regexp patterns are not supported")
+            ColumnarValue::Scalar(scalar) => {
+                if scalar.is_null() {
+                    return 
Ok(ColumnarValue::Scalar(ScalarValue::Boolean(None)));
+                }
+
+                let is_match = match scalar {
+                    ScalarValue::Utf8(Some(s))
+                    | ScalarValue::LargeUtf8(Some(s))
+                    | ScalarValue::Utf8View(Some(s)) => 
self.pattern.is_match(s.as_str()),

Review Comment:
   ```suggestion
                       | ScalarValue::Utf8View(Some(s)) => 
self.pattern.is_match(&s),
   ```



-- 
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