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

Method plan_binary_op

datafusion/core/tests/user_defined/expr_planner.rs:37–66  ·  view source on GitHub ↗
(
        &self,
        expr: RawBinaryExpr,
        _schema: &DFSchema,
    )

Source from the content-addressed store, hash-verified

35
36impl ExprPlanner for MyCustomPlanner {
37 fn plan_binary_op(
38 &self,
39 expr: RawBinaryExpr,
40 _schema: &DFSchema,
41 ) -> Result<PlannerResult<RawBinaryExpr>> {
42 match &expr.op {
43 BinaryOperator::Arrow => {
44 Ok(PlannerResult::Planned(Expr::BinaryExpr(BinaryExpr {
45 left: Box::new(expr.left.clone()),
46 right: Box::new(expr.right.clone()),
47 op: Operator::StringConcat,
48 })))
49 }
50 BinaryOperator::LongArrow => {
51 Ok(PlannerResult::Planned(Expr::BinaryExpr(BinaryExpr {
52 left: Box::new(expr.left.clone()),
53 right: Box::new(expr.right.clone()),
54 op: Operator::Plus,
55 })))
56 }
57 BinaryOperator::Question => {
58 Ok(PlannerResult::Planned(Expr::Alias(Alias::new(
59 Expr::Literal(ScalarValue::Boolean(Some(true)), None),
60 None::<&str>,
61 format!("{} ? {}", expr.left, expr.right),
62 ))))
63 }
64 _ => Ok(PlannerResult::Original(expr)),
65 }
66 }
67}
68
69async fn plan_and_collect(sql: &str) -> Result<Vec<RecordBatch>> {

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
AliasClass · 0.85
BinaryExprClass · 0.50
LiteralInterface · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected