use re_arrow2::array::{BooleanArray, Utf8Array}; use re_arrow2::compute::regex_match::*; use re_arrow2::error::Result; use re_arrow2::offset::Offset; fn test_generic, &Utf8Array) -> Result>( lhs: Vec<&str>, pattern: Vec<&str>, op: F, expected: Vec, ) { let lhs = Utf8Array::::from_slice(lhs); let pattern = Utf8Array::::from_slice(pattern); let expected = BooleanArray::from_slice(expected); let result = op(&lhs, &pattern).unwrap(); assert_eq!(result, expected); } fn test_generic_scalar, &str) -> Result>( lhs: Vec<&str>, pattern: &str, op: F, expected: Vec, ) { let lhs = Utf8Array::::from_slice(lhs); let expected = BooleanArray::from_slice(expected); let result = op(&lhs, pattern).unwrap(); assert_eq!(result, expected); } #[test] fn test_like() { test_generic::( vec![ "arrow", "arrow", "arrow", "arrow", "arrow", "arrows", "arrow", ], vec!["arrow", "^ar", "ro", "foo", "arr$", "arrow.", "arrow."], regex_match, vec![true, true, true, false, false, true, false], ) } #[test] fn test_like_scalar() { test_generic_scalar::( vec!["arrow", "parquet", "datafusion", "flight"], "ar", regex_match_scalar, vec![true, true, false, false], ); test_generic_scalar::( vec!["arrow", "parquet", "datafusion", "flight"], "^ar", regex_match_scalar, vec![true, false, false, false], ) }