You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/05/27 20:08:26 UTC

[GitHub] [arrow-datafusion] alamb commented on a change in pull request #434: test: display of each query plan during plan generation

alamb commented on a change in pull request #434:
URL: https://github.com/apache/arrow-datafusion/pull/434#discussion_r640931526



##########
File path: datafusion/tests/sql.rs
##########
@@ -1573,6 +1575,101 @@ async fn csv_explain() {
     assert_eq!(expected, actual);
 }
 
+#[tokio::test]
+async fn csv_explain_plans() {
+    // This test verify the look of each plan in its full cycle plan creation
+
+    let mut ctx = ExecutionContext::new();
+    register_aggregate_csv_by_sql(&mut ctx).await;
+    let sql = "EXPLAIN SELECT c1 FROM aggregate_test_100 where c2 > 10";
+
+    // Logical plan
+    // Create plan
+    let msg = format!("Creating logical plan for '{}'", sql);
+    let plan = ctx.create_logical_plan(&sql).expect(&msg);
+    let logical_schema = plan.schema();
+    // 
+    println!("SQL: {}", sql);
+    // Verify schema
+    let expected = "Explain [plan_type:Utf8, plan:Utf8]";
+    let actual = format!("{}", plan.display_indent_schema());
+    assert_eq!(expected, actual);
+    // Verify the text format of the plan
+    let expected = "Explain";

Review comment:
       I think including the plan tree like
   ```
   Explain
     Project
       Filter
         Scan
   ```
   
   Makes more sense than the current output of:
   ```
   Explain
   ```
   

##########
File path: datafusion/tests/sql.rs
##########
@@ -1573,6 +1575,101 @@ async fn csv_explain() {
     assert_eq!(expected, actual);
 }
 
+#[tokio::test]
+async fn csv_explain_plans() {
+    // This test verify the look of each plan in its full cycle plan creation
+
+    let mut ctx = ExecutionContext::new();
+    register_aggregate_csv_by_sql(&mut ctx).await;
+    let sql = "EXPLAIN SELECT c1 FROM aggregate_test_100 where c2 > 10";
+
+    // Logical plan
+    // Create plan
+    let msg = format!("Creating logical plan for '{}'", sql);
+    let plan = ctx.create_logical_plan(&sql).expect(&msg);
+    let logical_schema = plan.schema();
+    // 
+    println!("SQL: {}", sql);
+    // Verify schema
+    let expected = "Explain [plan_type:Utf8, plan:Utf8]";
+    let actual = format!("{}", plan.display_indent_schema());
+    assert_eq!(expected, actual);
+    // Verify the text format of the plan
+    let expected = "Explain";
+    let actual = format!("{}", plan.display_indent());
+    assert_eq!(expected, actual);
+    // verify the grahviz format of the plan
+    let expected = "// Begin DataFusion GraphViz Plan (see https://graphviz.org)\n
+    digraph {\n
+      subgraph cluster_1\n
+      {\n
+        graph[label=\"LogicalPlan\"]\n
+        2[shape=box label=\"Explain\"]\n
+      }\n
+      subgraph cluster_3\n
+      {\n
+        graph[label=\"Detailed LogicalPlan\"]\n
+        4[shape=box label=\"Explain\\nSchema: [plan_type:Utf8, plan:Utf8]\"]\n
+      }\n
+    }\n
+    // End DataFusion GraphViz Plan";

Review comment:
       I think it should include the actual plan that is being explained




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org