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

Function test_with_expr_planners

datafusion/core/src/execution/session_state.rs:2565–2601  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2563 /// an `expr_planners` method for `SessionState`.
2564 #[tokio::test]
2565 async fn test_with_expr_planners() -> Result<()> {
2566 // A helper method for planning count wildcard with or without expr planners.
2567 async fn plan_count_wildcard(
2568 with_expr_planners: bool,
2569 ) -> Result<Arc<dyn ExecutionPlan>> {
2570 let mut context_provider = MyContextProvider::new().with_table(
2571 "t",
2572 provider_as_source(Arc::new(EmptyTable::new(Schema::empty().into()))),
2573 );
2574 if with_expr_planners {
2575 context_provider = context_provider.with_expr_planners();
2576 }
2577
2578 let state = &context_provider.state;
2579 let statement =
2580 state.sql_to_statement("select count(*) from t", &Dialect::MySQL)?;
2581 let plan = SqlToRel::new(&context_provider).statement_to_plan(statement)?;
2582 state.create_physical_plan(&plan).await
2583 }
2584
2585 // Planning count wildcard without expr planners should fail.
2586 let got = plan_count_wildcard(false).await;
2587 assert_contains!(
2588 got.unwrap_err().to_string(),
2589 "Physical plan does not support logical expression Wildcard"
2590 );
2591
2592 // Planning count wildcard with expr planners should succeed.
2593 let got = plan_count_wildcard(true).await?;
2594 let displayable = DisplayableExecutionPlan::new(got.as_ref());
2595 assert_eq!(
2596 displayable.indent(false).to_string(),
2597 "ProjectionExec: expr=[0 as count(*)]\n PlaceholderRowExec\n"
2598 );
2599
2600 Ok(())
2601 }
2602
2603 /// A `ContextProvider` based on `SessionState`.
2604 ///

Callers

nothing calls this directly

Calls 3

plan_count_wildcardFunction · 0.85
newFunction · 0.85
as_refMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…