@@ -94,7 +94,7 @@ impl LiteralGuarantee {
94
94
/// create these structures from an predicate (boolean expression).
95
95
fn try_new < ' a > (
96
96
column_name : impl Into < String > ,
97
- op : & Operator ,
97
+ op : Operator ,
98
98
literals : impl IntoIterator < Item = & ' a ScalarValue > ,
99
99
) -> Option < Self > {
100
100
let guarantee = match op {
@@ -199,7 +199,7 @@ struct GuaranteeBuilder<'a> {
199
199
200
200
/// Key is the (column name, operator type)
201
201
/// Value is the index into `guarantees`
202
- map : HashMap < ( & ' a crate :: expressions:: Column , & ' a Operator ) , usize > ,
202
+ map : HashMap < ( & ' a crate :: expressions:: Column , Operator ) , usize > ,
203
203
}
204
204
205
205
impl < ' a > GuaranteeBuilder < ' a > {
@@ -233,7 +233,7 @@ impl<'a> GuaranteeBuilder<'a> {
233
233
fn aggregate_multi_conjunct (
234
234
mut self ,
235
235
col : & ' a crate :: expressions:: Column ,
236
- op : & ' a Operator ,
236
+ op : Operator ,
237
237
new_values : impl IntoIterator < Item = & ' a ScalarValue > ,
238
238
) -> Self {
239
239
let key = ( col, op) ;
@@ -290,7 +290,7 @@ impl<'a> GuaranteeBuilder<'a> {
290
290
// new_values are combined with OR, so we can only create a
291
291
// multi-column guarantee for `=` (or a single value).
292
292
// (e.g. ignore `a != foo OR a != bar`)
293
- if op == & Operator :: Eq || new_values. len ( ) == 1 {
293
+ if op == Operator :: Eq || new_values. len ( ) == 1 {
294
294
if let Some ( guarantee) =
295
295
LiteralGuarantee :: try_new ( col. name ( ) , op, new_values)
296
296
{
@@ -314,7 +314,7 @@ impl<'a> GuaranteeBuilder<'a> {
314
314
/// Represents a single `col <op> literal` expression
315
315
struct ColOpLit < ' a > {
316
316
col : & ' a crate :: expressions:: Column ,
317
- op : & ' a Operator ,
317
+ op : Operator ,
318
318
lit : & ' a crate :: expressions:: Literal ,
319
319
}
320
320
@@ -340,14 +340,15 @@ impl<'a> ColOpLit<'a> {
340
340
left. downcast_ref :: < crate :: expressions:: Column > ( ) ,
341
341
right. downcast_ref :: < crate :: expressions:: Literal > ( ) ,
342
342
) {
343
- Some ( Self { col, op, lit } )
343
+ Some ( Self { col, op : * op , lit } )
344
344
}
345
345
// literal <op> col
346
346
else if let ( Some ( lit) , Some ( col) ) = (
347
347
left. downcast_ref :: < crate :: expressions:: Literal > ( ) ,
348
348
right. downcast_ref :: < crate :: expressions:: Column > ( ) ,
349
349
) {
350
- Some ( Self { col, op, lit } )
350
+ // Used swapped operator operator, if possible
351
+ op. swap ( ) . map ( |op| Self { col, op, lit } )
351
352
} else {
352
353
None
353
354
}
@@ -667,7 +668,7 @@ mod test {
667
668
S : Into < ScalarValue > + ' a ,
668
669
{
669
670
let literals: Vec < _ > = literals. into_iter ( ) . map ( |s| s. into ( ) ) . collect ( ) ;
670
- LiteralGuarantee :: try_new ( column, & Operator :: Eq , literals. iter ( ) ) . unwrap ( )
671
+ LiteralGuarantee :: try_new ( column, Operator :: Eq , literals. iter ( ) ) . unwrap ( )
671
672
}
672
673
673
674
/// Guarantee that the expression is true if the column is NOT any of the specified values
@@ -677,7 +678,7 @@ mod test {
677
678
S : Into < ScalarValue > + ' a ,
678
679
{
679
680
let literals: Vec < _ > = literals. into_iter ( ) . map ( |s| s. into ( ) ) . collect ( ) ;
680
- LiteralGuarantee :: try_new ( column, & Operator :: NotEq , literals. iter ( ) ) . unwrap ( )
681
+ LiteralGuarantee :: try_new ( column, Operator :: NotEq , literals. iter ( ) ) . unwrap ( )
681
682
}
682
683
683
684
/// Convert a logical expression to a physical expression (without any simplification, etc)
0 commit comments