This is an automated email from the ASF dual-hosted git repository.

comphead pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 5f72234567 Implement `tree` explain for `JsonSink` (#15185)
5f72234567 is described below

commit 5f7223456709602e2401aede5ba3f040ae01d7ec
Author: irenjj <[email protected]>
AuthorDate: Thu Mar 13 05:47:31 2025 +0800

    Implement `tree` explain for `JsonSink` (#15185)
---
 datafusion/datasource-json/src/file_format.rs       |  6 ++++--
 datafusion/physical-plan/src/insert.rs              |  5 +----
 datafusion/sqllogictest/test_files/explain_tree.slt | 16 ++++++++++++++++
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/datafusion/datasource-json/src/file_format.rs 
b/datafusion/datasource-json/src/file_format.rs
index 2df49b5351..bec3a524f6 100644
--- a/datafusion/datasource-json/src/file_format.rs
+++ b/datafusion/datasource-json/src/file_format.rs
@@ -325,8 +325,10 @@ impl DisplayAs for JsonSink {
                 write!(f, ")")
             }
             DisplayFormatType::TreeRender => {
-                // TODO: collect info
-                write!(f, "")
+                if !self.config.file_groups.is_empty() {
+                    FileGroupDisplay(&self.config.file_groups).fmt_as(t, f)?;
+                }
+                Ok(())
             }
         }
     }
diff --git a/datafusion/physical-plan/src/insert.rs 
b/datafusion/physical-plan/src/insert.rs
index ff65f6154b..5272f0ab18 100644
--- a/datafusion/physical-plan/src/insert.rs
+++ b/datafusion/physical-plan/src/insert.rs
@@ -153,10 +153,7 @@ impl DisplayAs for DataSinkExec {
                 write!(f, "DataSinkExec: sink=")?;
                 self.sink.fmt_as(t, f)
             }
-            DisplayFormatType::TreeRender => {
-                // TODO: collect info
-                write!(f, "")
-            }
+            DisplayFormatType::TreeRender => self.sink().fmt_as(t, f),
         }
     }
 }
diff --git a/datafusion/sqllogictest/test_files/explain_tree.slt 
b/datafusion/sqllogictest/test_files/explain_tree.slt
index caae784c9d..bafc4d559b 100644
--- a/datafusion/sqllogictest/test_files/explain_tree.slt
+++ b/datafusion/sqllogictest/test_files/explain_tree.slt
@@ -1625,3 +1625,19 @@ physical_plan
 33)-----------------------------│    --------------------   │
 34)-----------------------------│        name: nodes        │
 35)-----------------------------└───────────────────────────┘
+
+query TT
+explain COPY (VALUES (1, 'foo', 1, '2023-01-01'), (2, 'bar', 2, '2023-01-02'), 
(3, 'baz', 3, '2023-01-03'))
+TO 'test_files/scratch/explain_tree/1.json';
+----
+physical_plan
+01)┌───────────────────────────┐
+02)│        DataSinkExec       │
+03)└─────────────┬─────────────┘
+04)┌─────────────┴─────────────┐
+05)│       DataSourceExec      │
+06)│    --------------------   │
+07)│        bytes: 2672        │
+08)│       format: memory      │
+09)│          rows: 1          │
+10)└───────────────────────────┘


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to