@@ -54,7 +54,7 @@ pub struct BinaryExpr {
54
54
right : Arc < dyn PhysicalExpr > ,
55
55
/// Specifies whether an error is returned on overflow or not
56
56
fail_on_overflow : bool ,
57
- /// Only used when evaluating literal regex expressions. Example regex expression: c1 ~ '^a'
57
+ /// Only used when evaluating literal regex expressions. Example regex expression: c1 ~ '^a'
58
58
/// It's helpful saving time of compiling literal pattern string for each execution.
59
59
precompiled_regexp : Option < regex:: Regex > ,
60
60
}
@@ -102,37 +102,32 @@ impl BinaryExpr {
102
102
& self . op
103
103
}
104
104
105
- /// Get pre-compiled regexp
106
- fn precompile_regexp_pattern ( op : & Operator , lit : & Arc < dyn PhysicalExpr > ) -> Option < regex:: Regex > {
105
+ /// Get pre-compiled regexp
106
+ fn precompile_regexp_pattern (
107
+ op : & Operator ,
108
+ lit : & Arc < dyn PhysicalExpr > ,
109
+ ) -> Option < regex:: Regex > {
107
110
match op {
108
- Operator :: RegexMatch |
109
- Operator :: RegexNotMatch |
110
- Operator :: RegexIMatch |
111
- Operator :: RegexNotIMatch => {
112
- lit
111
+ Operator :: RegexMatch
112
+ | Operator :: RegexNotMatch
113
+ | Operator :: RegexIMatch
114
+ | Operator :: RegexNotIMatch => lit
113
115
. as_any ( )
114
116
. downcast_ref :: < Literal > ( )
115
- . and_then ( |pattern| {
116
- match pattern. value ( ) {
117
- ScalarValue :: Utf8 ( pattern) |
118
- ScalarValue :: LargeUtf8 ( pattern) => {
119
- pattern
120
- . as_ref ( )
121
- . and_then ( |p| {
122
- let string_value = match op {
123
- Operator :: RegexIMatch |
124
- Operator :: RegexNotIMatch => {
117
+ . and_then ( |pattern| match pattern. value ( ) {
118
+ ScalarValue :: Utf8 ( pattern) | ScalarValue :: LargeUtf8 ( pattern) => {
119
+ pattern. as_ref ( ) . and_then ( |p| {
120
+ let string_value = match op {
121
+ Operator :: RegexIMatch | Operator :: RegexNotIMatch => {
125
122
vec ! [ "(?i)" , p. as_str( ) ] . join ( "" )
126
- } ,
127
- _ => p. clone ( ) ,
128
- } ;
129
- Some ( regex:: Regex :: new ( string_value. as_str ( ) ) . unwrap ( ) )
130
- } )
131
- } ,
132
- _ => None
123
+ }
124
+ _ => p. clone ( ) ,
125
+ } ;
126
+ Some ( regex:: Regex :: new ( string_value. as_str ( ) ) . unwrap ( ) )
127
+ } )
133
128
}
134
- } )
135
- } ,
129
+ _ => None ,
130
+ } ) ,
136
131
_ => None ,
137
132
}
138
133
}
@@ -4191,13 +4186,13 @@ mod tests {
4191
4186
4192
4187
macro_rules! test_regex_match_scalar {
4193
4188
(
4194
- $A_ARRAY: ident,
4195
- $A_TYPE: expr,
4196
- $A_VEC: expr,
4197
- $B_SCALAR: expr,
4198
- $OP: expr,
4199
- $C_ARRAY: ident,
4200
- $C_TYPE: expr,
4189
+ $A_ARRAY: ident,
4190
+ $A_TYPE: expr,
4191
+ $A_VEC: expr,
4192
+ $B_SCALAR: expr,
4193
+ $OP: expr,
4194
+ $C_ARRAY: ident,
4195
+ $C_TYPE: expr,
4201
4196
$VEC: expr,
4202
4197
) => { {
4203
4198
let schema = Schema :: new( vec![
0 commit comments