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

Function csv_explain_plans

datafusion/core/tests/sql/explain_analyze.rs:329–495  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

327
328#[tokio::test]
329async fn csv_explain_plans() {
330 // This test verify the look of each plan in its full cycle plan creation
331
332 let ctx = SessionContext::new();
333 register_aggregate_csv_by_sql(&ctx).await;
334 let sql = "EXPLAIN SELECT c1 FROM aggregate_test_100 where c2 > 10";
335
336 // Logical plan
337 // Create plan
338 let msg = format!("Creating logical plan for '{sql}'");
339 let dataframe = ctx.sql(sql).await.expect(&msg);
340 let logical_schema = dataframe.schema();
341 let plan = dataframe.logical_plan();
342
343 //
344 println!("SQL: {sql}");
345 //
346 // Verify schema
347 let formatted = plan.display_indent_schema().to_string();
348 let actual = formatted.trim();
349 assert_snapshot!(
350 actual,
351 @r"
352 Explain [plan_type:Utf8, plan:Utf8]
353 Projection: aggregate_test_100.c1 [c1:Utf8View]
354 Filter: aggregate_test_100.c2 > Int64(10) [c1:Utf8View, c2:Int8, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:UInt32, c10:UInt64, c11:Float32, c12:Float64, c13:Utf8View]
355 TableScan: aggregate_test_100 [c1:Utf8View, c2:Int8, c3:Int16, c4:Int16, c5:Int32, c6:Int64, c7:Int16, c8:Int32, c9:UInt32, c10:UInt64, c11:Float32, c12:Float64, c13:Utf8View]
356 "
357 );
358 //
359 // Verify the text format of the plan
360 let formatted = plan.display_indent().to_string();
361 let actual = formatted.trim();
362 assert_snapshot!(
363 actual,
364 @r"
365 Explain
366 Projection: aggregate_test_100.c1
367 Filter: aggregate_test_100.c2 > Int64(10)
368 TableScan: aggregate_test_100
369 "
370 );
371 //
372 // verify the grahviz format of the plan
373 let formatted = plan.display_graphviz().to_string();
374 let actual = formatted.trim();
375 assert_snapshot!(
376 actual,
377 @r#"
378 // Begin DataFusion GraphViz Plan,
379 // display it online here: https://dreampuf.github.io/GraphvizOnline
380
381 digraph {
382 subgraph cluster_1
383 {
384 graph[label="LogicalPlan"]
385 2[shape=box label="Explain"]
386 3[shape=box label="Projection: aggregate_test_100.c1"]

Callers

nothing calls this directly

Calls 15

newFunction · 0.85
result_vecFunction · 0.85
sqlMethod · 0.80
display_indent_schemaMethod · 0.80
trimMethod · 0.80
display_indentMethod · 0.80
display_graphvizMethod · 0.80
collectFunction · 0.50
schemaMethod · 0.45
logical_planMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…