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

Function test_build_dag

datafusion/physical-expr/src/utils/mod.rs:471–534  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

469
470 #[test]
471 fn test_build_dag() -> Result<()> {
472 let schema = Schema::new(vec![
473 Field::new("0", DataType::Int32, true),
474 Field::new("1", DataType::Int32, true),
475 Field::new("2", DataType::Int32, true),
476 ]);
477 let expr = binary(
478 cast(
479 binary(
480 col("0", &schema)?,
481 Operator::Plus,
482 col("1", &schema)?,
483 &schema,
484 )?,
485 &schema,
486 DataType::Int64,
487 )?,
488 Operator::Gt,
489 binary(
490 cast(col("2", &schema)?, &schema, DataType::Int64)?,
491 Operator::Plus,
492 lit(ScalarValue::Int64(Some(10))),
493 &schema,
494 )?,
495 &schema,
496 )?;
497 let mut vector_dummy_props = vec![];
498 let (root, graph) = build_dag(expr, &make_dummy_node)?;
499 let mut bfs = Bfs::new(&graph, root);
500 while let Some(node_index) = bfs.next(&graph) {
501 let node = &graph[node_index];
502 vector_dummy_props.push(node.property.clone());
503 }
504
505 assert_eq!(
506 vector_dummy_props
507 .iter()
508 .filter(|property| property.expr_type == "Binary")
509 .count(),
510 3
511 );
512 assert_eq!(
513 vector_dummy_props
514 .iter()
515 .filter(|property| property.expr_type == "Column")
516 .count(),
517 3
518 );
519 assert_eq!(
520 vector_dummy_props
521 .iter()
522 .filter(|property| property.expr_type == "Literal")
523 .count(),
524 1
525 );
526 assert_eq!(
527 vector_dummy_props
528 .iter()

Callers

nothing calls this directly

Calls 9

newFunction · 0.85
binaryFunction · 0.85
build_dagFunction · 0.85
castFunction · 0.50
colFunction · 0.50
litFunction · 0.50
nextMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…