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

alamb 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 d5d53c5a78 Implement tree explain for CoalescePartitionsExec (#15225)
d5d53c5a78 is described below

commit d5d53c5a78c1dced69dc7f94373020ad6aa2fb74
Author: Shreyas (Lua) <[email protected]>
AuthorDate: Sat Mar 15 05:08:01 2025 -0700

    Implement tree explain for CoalescePartitionsExec (#15225)
    
    * Implement tree explain for CoalescePartitionsExec
    
    * fix fmt
    
    * Update datafusion/physical-plan/src/coalesce_partitions.rs
    
    Co-authored-by: Alex Huang <[email protected]>
    
    * update expected
    
    ---------
    
    Co-authored-by: Andrew Lamb <[email protected]>
    Co-authored-by: Alex Huang <[email protected]>
---
 .../physical-plan/src/coalesce_partitions.rs       | 10 +--
 datafusion/sqllogictest/test_files/alias.slt       |  2 +-
 .../sqllogictest/test_files/explain_tree.slt       | 77 +++++++++++++++++++---
 3 files changed, 76 insertions(+), 13 deletions(-)

diff --git a/datafusion/physical-plan/src/coalesce_partitions.rs 
b/datafusion/physical-plan/src/coalesce_partitions.rs
index 8fb40640dc..95a0c8f6ce 100644
--- a/datafusion/physical-plan/src/coalesce_partitions.rs
+++ b/datafusion/physical-plan/src/coalesce_partitions.rs
@@ -92,10 +92,12 @@ impl DisplayAs for CoalescePartitionsExec {
                 }
                 None => write!(f, "CoalescePartitionsExec"),
             },
-            DisplayFormatType::TreeRender => {
-                // TODO: collect info
-                write!(f, "")
-            }
+            DisplayFormatType::TreeRender => match self.fetch {
+                Some(fetch) => {
+                    write!(f, "limit: {fetch}")
+                }
+                None => write!(f, ""),
+            },
         }
     }
 }
diff --git a/datafusion/sqllogictest/test_files/alias.slt 
b/datafusion/sqllogictest/test_files/alias.slt
index 340ffb6078..5339179db4 100644
--- a/datafusion/sqllogictest/test_files/alias.slt
+++ b/datafusion/sqllogictest/test_files/alias.slt
@@ -56,4 +56,4 @@ statement count 0
 drop table t1;
 
 statement count 0
-drop table t2;
\ No newline at end of file
+drop table t2;
diff --git a/datafusion/sqllogictest/test_files/explain_tree.slt 
b/datafusion/sqllogictest/test_files/explain_tree.slt
index 83d2edee70..8d7e0f30ab 100644
--- a/datafusion/sqllogictest/test_files/explain_tree.slt
+++ b/datafusion/sqllogictest/test_files/explain_tree.slt
@@ -133,6 +133,26 @@ AS SELECT
 FROM
   hashjoin_datatype_table_t2_source
 
+statement ok
+CREATE UNBOUNDED EXTERNAL TABLE sink_table (
+        c1  VARCHAR NOT NULL,
+        c2  TINYINT NOT NULL,
+        c3  SMALLINT NOT NULL,
+        c4  SMALLINT NOT NULL,
+        c5  INTEGER NOT NULL,
+        c6  BIGINT NOT NULL,
+        c7  SMALLINT NOT NULL,
+        c8  INT NOT NULL,
+        c9  INT UNSIGNED NOT NULL,
+        c10 BIGINT UNSIGNED NOT NULL,
+        c11 FLOAT NOT NULL,
+        c12 DOUBLE NOT NULL,
+        c13 VARCHAR NOT NULL
+    )
+STORED AS CSV
+LOCATION '../../testing/data/csv/aggregate_test_100.csv'
+OPTIONS ('format.has_header' 'true');
+
 statement ok
 CREATE TABLE limit_table AS
 SELECT * FROM table1
@@ -257,14 +277,16 @@ explain SELECT * FROM limit_table LIMIT 10;
 physical_plan
 01)┌───────────────────────────┐
 02)│   CoalescePartitionsExec  │
-03)└─────────────┬─────────────┘
-04)┌─────────────┴─────────────┐
-05)│       DataSourceExec      │
-06)│    --------------------   │
-07)│        bytes: 3120        │
-08)│       format: memory      │
-09)│          rows: 2          │
-10)└───────────────────────────┘
+03)│    --------------------   │
+04)│         limit: 10         │
+05)└─────────────┬─────────────┘
+06)┌─────────────┴─────────────┐
+07)│       DataSourceExec      │
+08)│    --------------------   │
+09)│        bytes: 3120        │
+10)│       format: memory      │
+11)│          rows: 2          │
+12)└───────────────────────────┘
 
 # 2 Joins
 query TT
@@ -1990,3 +2012,42 @@ physical_plan
 05)│ generate_series: start=1, │
 06)│  end=100, batch_size=8192 │
 07)└───────────────────────────┘
+
+# Test explain tree for CoalescePartitionsExec
+query TT
+EXPLAIN SELECT c1, c2, c3 FROM sink_table WHERE c3 > 0 LIMIT 5;
+----
+physical_plan
+01)┌───────────────────────────┐
+02)│   CoalescePartitionsExec  │
+03)│    --------------------   │
+04)│          limit: 5         │
+05)└─────────────┬─────────────┘
+06)┌─────────────┴─────────────┐
+07)│    CoalesceBatchesExec    │
+08)│    --------------------   │
+09)│          limit: 5         │
+10)│                           │
+11)│     target_batch_size:    │
+12)│            8192           │
+13)└─────────────┬─────────────┘
+14)┌─────────────┴─────────────┐
+15)│         FilterExec        │
+16)│    --------------------   │
+17)│    predicate: c3@2 > 0    │
+18)└─────────────┬─────────────┘
+19)┌─────────────┴─────────────┐
+20)│      RepartitionExec      │
+21)│    --------------------   │
+22)│  output_partition_count:  │
+23)│             1             │
+24)│                           │
+25)│    partitioning_scheme:   │
+26)│     RoundRobinBatch(4)    │
+27)└─────────────┬─────────────┘
+28)┌─────────────┴─────────────┐
+29)│     StreamingTableExec    │
+30)│    --------------------   │
+31)│       infinite: true      │
+32)│        limit: None        │
+33)└───────────────────────────┘


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

Reply via email to