irenjj commented on code in PR #15253: URL: https://github.com/apache/datafusion/pull/15253#discussion_r1997046455
########## datafusion/expr/src/expr.rs: ########## @@ -2596,6 +2600,43 @@ impl Display for SchemaDisplay<'_> { } } +struct SqlDisplay<'a>(&'a Expr); +impl Display for SqlDisplay<'_> { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + match self.0 { + Expr::Column(c) => { + write!(f, "{}", c.name) + } + Expr::Literal(_) => { + write!(f, "aa") + } + Expr::ScalarVariable(..) => { + write!(f, "bb") + } + Expr::OuterReferenceColumn(..) => { + write!(f, "cc") + } + Expr::Placeholder(_) => { + write!(f, "dd") + } + Expr::Wildcard { .. } => { + write!(f, "ee") + } + Expr::AggregateFunction(AggregateFunction { func, params }) => { + match func.sql_name(params) { + Ok(name) => { + write!(f, "{name}") + } + Err(e) => { + write!(f, "got error from schema_name {}", e) + } + } + } + _ => write!(f, "{}", self.0.schema_name()), + } + } +} + Review Comment: Just a demo here. `AggregateFunctionExpr`'s `name` is constructed at logical expr phase, we need a new member `sql_name` for tree explain, and a new constructor `SqlDisplay` to handle the inner `Expr` recursively. cc @alamb 👀 ########## datafusion/sqllogictest/test_files/explain_tree.slt: ########## @@ -1338,7 +1336,7 @@ physical_plan 12)-----------------------------┌─────────────┴─────────────┐ 13)-----------------------------│ AggregateExec │ 14)-----------------------------│ -------------------- │ -15)-----------------------------│ aggr: count(Int64(1)) │ +15)-----------------------------│ aggr: count(aa) │ Review Comment: We can see the final display changed. -- 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. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org