Skip to content

Commit 440ee8d

Browse files
committed
fix(sql): apply table-scan rewrite before EXPLAIN display
The EXPLAIN display path in VirtualExecutionPlan::fmt_as was generating SQL from the pre-rewrite plan, causing EXPLAIN output to not reflect the actual pushed-down query. Apply RewriteTableScanAnalyzer::rewrite before SQL rendering so EXPLAIN output matches final_sql().
1 parent 68d41cf commit 440ee8d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • datafusion-federation/src/sql

datafusion-federation/src/sql/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,12 @@ impl DisplayAs for VirtualExecutionPlan {
281281
if let Some(ctx) = self.executor.compute_context() {
282282
write!(f, " compute_context={ctx}")?;
283283
};
284-
let mut plan = self.plan.clone();
284+
let mut plan = match RewriteTableScanAnalyzer::rewrite(self.plan.clone()) {
285+
Ok(plan) => plan,
286+
Err(_) => self.plan.clone(),
287+
};
285288
if let Ok(statement) = self.plan_to_statement(&plan) {
286-
write!(f, " initial_sql={statement}")?;
289+
write!(f, " base_sql={statement}")?;
287290
}
288291

289292
let (logical_optimizers, ast_analyzers) = match gather_analyzers(&plan) {

0 commit comments

Comments
 (0)