Skip to content

Commit 424ef47

Browse files
zhuqi-lucasclaude
andcommitted
Fix FilterExec tree render missing fetch display
When `FilterExec` has a `fetch` (limit pushed down), the `TreeRender` display format does not show it, while `Default`/`Verbose` formats do. This makes `EXPLAIN FORMAT TREE` output incomplete for queries with LIMIT pushed into FilterExec. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1a0af76 commit 424ef47

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

datafusion/physical-plan/src/filter.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,11 @@ impl DisplayAs for FilterExec {
505505
)
506506
}
507507
DisplayFormatType::TreeRender => {
508-
write!(f, "predicate={}", fmt_sql(self.predicate.as_ref()))
508+
write!(f, "predicate={}", fmt_sql(self.predicate.as_ref()))?;
509+
if let Some(fetch) = self.fetch {
510+
write!(f, ", fetch={fetch}")?;
511+
}
512+
Ok(())
509513
}
510514
}
511515
}

datafusion/sqllogictest/test_files/limit.slt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,25 @@ SELECT COUNT(*) FROM (SELECT a FROM t1 WHERE a > 3 LIMIT 3 OFFSET 6);
385385
----
386386
1
387387

388+
# Verify that EXPLAIN FORMAT TREE shows fetch on FilterExec
389+
query TT
390+
EXPLAIN FORMAT TREE SELECT a FROM t1 WHERE a > 3 LIMIT 5;
391+
----
392+
physical_plan
393+
01)┌───────────────────────────┐
394+
02)│ FilterExec │
395+
03)│ -------------------- │
396+
04)│ predicate: │
397+
05)│ a > 3, fetch=5 │
398+
06)└─────────────┬─────────────┘
399+
07)┌─────────────┴─────────────┐
400+
08)│ DataSourceExec │
401+
09)│ -------------------- │
402+
10)│ bytes: 160 │
403+
11)│ format: memory │
404+
12)│ rows: 1 │
405+
13)└───────────────────────────┘
406+
388407
# generate BIGINT data from 1 to 1000 in multiple partitions
389408
statement ok
390409
CREATE TABLE t1000 (i BIGINT) AS
@@ -867,7 +886,7 @@ limit 1000;
867886

868887
# Config reset
869888

870-
# The SLT runner sets `target_partitions` to 4 instead of using the default, so
889+
# The SLT runner sets `target_partitions` to 4 instead of using the default, so
871890
# reset it explicitly.
872891
statement ok
873892
set datafusion.execution.target_partitions = 4;

0 commit comments

Comments
 (0)