MCPcopy Create free account
hub / github.com/apache/datafusion / try_new

Method try_new

datafusion/physical-expr/src/utils/guarantee.rs:394–428  ·  view source on GitHub ↗

Returns Some(ColOpLit) if the expression is either: 1. `col literal` 2. `literal col` 3. operator is `=` or `!=` Returns None otherwise

(expr: &'a Arc<dyn PhysicalExpr>)

Source from the content-addressed store, hash-verified

392 ///
393 /// Returns None otherwise
394 fn try_new(expr: &'a Arc<dyn PhysicalExpr>) -> Option<Self> {
395 let binary_expr = expr.downcast_ref::<crate::expressions::BinaryExpr>()?;
396
397 let (left, op, right) =
398 (binary_expr.left(), binary_expr.op(), binary_expr.right());
399 let guarantee = match op {
400 Operator::Eq => Guarantee::In,
401 Operator::NotEq => Guarantee::NotIn,
402 _ => return None,
403 };
404 // col <op> literal
405 if let (Some(col), Some(lit)) = (
406 left.downcast_ref::<crate::expressions::Column>(),
407 right.downcast_ref::<crate::expressions::Literal>(),
408 ) {
409 Some(Self {
410 col,
411 guarantee,
412 lit,
413 })
414 }
415 // literal <op> col
416 else if let (Some(lit), Some(col)) = (
417 left.downcast_ref::<crate::expressions::Literal>(),
418 right.downcast_ref::<crate::expressions::Column>(),
419 ) {
420 Some(Self {
421 col,
422 guarantee,
423 lit,
424 })
425 } else {
426 None
427 }
428 }
429}
430
431/// Represents a single `col [not]in literal` expression

Callers

nothing calls this directly

Calls 9

ColInListClass · 0.85
leftMethod · 0.45
opMethod · 0.45
rightMethod · 0.45
exprMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
listMethod · 0.45
negatedMethod · 0.45

Tested by

no test coverage detected