Dimchikkk commented on code in PR #13414:
URL: https://github.com/apache/datafusion/pull/13414#discussion_r1842910817


##########
datafusion/functions/src/regex/regexpcount.rs:
##########
@@ -548,16 +549,22 @@ where
     }
 }
 
-fn compile_and_cache_regex<'a>(
-    regex: &'a str,
-    flags: Option<&'a str>,
-    regex_cache: &'a mut HashMap<String, Regex>,
-) -> Result<&'a Regex, ArrowError> {
-    if !regex_cache.contains_key(regex) {

Review Comment:
   yep,
   
    so without this fix the test fails with counting middle value to 0 instead 
of 1:
   ```rs
           let values = A::from(vec!["aaa", "Aaa", "aaa"]);
           let regex = A::from(vec!["aaa", "aaa", "aaa"]);
           let start = Int64Array::from(vec![1, 1, 1]);
           let flags = A::from(vec!["", "i", ""]);
   
           let expected = Int64Array::from(vec![1, 1, 1]);
   
           let re = regexp_count_func(&[
               Arc::new(values),
               Arc::new(regex),
               Arc::new(start),
               Arc::new(flags),
           ])
           .unwrap();
           assert_eq!(re.as_ref(), &expected);
    ```
    notice regex are different only by flags, so cache has 2 regex after this 
fix and only 1 before the fix.
   



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to