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

Function test_deeply_nested_binary_expr

datafusion/physical-expr/src/planner.rs:713–735  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

711 #[test]
712 #[cfg_attr(not(feature = "recursive_protection"), ignore)]
713 fn test_deeply_nested_binary_expr() -> Result<()> {
714 // Create a deeply nested binary expression tree: ((((a + a) + a) + a) + ... )
715 // With 1000 levels of nesting, this would overflow the stack without recursion protection.
716 let depth = 1000;
717
718 let mut expr = col("a");
719 for _ in 0..depth {
720 expr = Expr::BinaryExpr(BinaryExpr {
721 left: Box::new(expr),
722 op: Operator::Plus,
723 right: Box::new(col("a")),
724 });
725 }
726
727 let schema = Schema::new(vec![Field::new("a", DataType::Int32, false)]);
728 let df_schema = DFSchema::try_from(schema)?;
729
730 // This should not stack overflow
731 let _physical_expr =
732 create_physical_expr(&expr, &df_schema, &ExecutionProps::new())?;
733
734 Ok(())
735 }
736}

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
create_physical_exprFunction · 0.85
colFunction · 0.50
BinaryExprClass · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…