(
binary: BinaryExpr,
guarantees: &HashMap<&Expr, &NullableInterval>,
)
| 222 | } |
| 223 | |
| 224 | fn rewrite_binary_expr( |
| 225 | binary: BinaryExpr, |
| 226 | guarantees: &HashMap<&Expr, &NullableInterval>, |
| 227 | ) -> Result<Transformed<Expr>, DataFusionError> { |
| 228 | // The left or right side of expression might either have a guarantee |
| 229 | // or be a literal. Either way, we can resolve them to a NullableInterval. |
| 230 | let left_interval = guarantees |
| 231 | .get(binary.left.as_ref()) |
| 232 | .map(|interval| Cow::Borrowed(*interval)) |
| 233 | .or_else(|| { |
| 234 | if let Expr::Literal(value, _) = binary.left.as_ref() { |
| 235 | Some(Cow::Owned(value.clone().into())) |
| 236 | } else { |
| 237 | None |
| 238 | } |
| 239 | }); |
| 240 | let right_interval = guarantees |
| 241 | .get(binary.right.as_ref()) |
| 242 | .map(|interval| Cow::Borrowed(*interval)) |
| 243 | .or_else(|| { |
| 244 | if let Expr::Literal(value, _) = binary.right.as_ref() { |
| 245 | Some(Cow::Owned(value.clone().into())) |
| 246 | } else { |
| 247 | None |
| 248 | } |
| 249 | }); |
| 250 | |
| 251 | if let (Some(left_interval), Some(right_interval)) = (left_interval, right_interval) { |
| 252 | let result = left_interval.apply_operator(&binary.op, right_interval.as_ref())?; |
| 253 | if result.is_certainly_true() { |
| 254 | return Ok(Transformed::yes(lit(true))); |
| 255 | } else if result.is_certainly_false() { |
| 256 | return Ok(Transformed::yes(lit(false))); |
| 257 | } |
| 258 | } |
| 259 | Ok(Transformed::no(Expr::BinaryExpr(binary))) |
| 260 | } |
| 261 | |
| 262 | fn rewrite_inlist( |
| 263 | inlist: InList, |
no test coverage detected
searching dependent graphs…