alamb opened a new issue, #15107:
URL: https://github.com/apache/datafusion/issues/15107

   ### Is your feature request related to a problem or challenge?
   
   - Part of https://github.com/apache/datafusion/issues/14914
   
   Thanks to @Standing-Man , tree explains are looking nice
   - https://github.com/apache/datafusion/pull/15082
   
   The current display of expressions makes it possible to understand their 
inner structure (what is casted, etc)
   
   However, it is quite hard for normal users to read. For example
   
   ```
   | physical_plan | ┌───────────────────────────┐                              
                                           |
   |               | │       ProjectionExec      │                              
                                           |
   |               | │    --------------------   │                              
                                           |
   |               | │ foo.int_column + Int64(100│                              
                                           |
   |               | │             ):            │                              
                                           |
   |               | │ CAST(int_column@0 AS Int64│                              
                                           |
   |               | │          ) + 100          │                              
                                           |
   |               | │                           │                              
                                           |
   |               | │  substr(foo.string_column │                              
                                           |
   |               | │    ,Int64(1),Int64(2)):   │                              
                                           |
   |               | │ substr(string_column@1, 1,│                              
                                           |
   |               | │             2)            │                              
                                           |
   |               | └─────────────┬─────────────┘      
   ```
   
   
   For example
   ```sql
   > explain select int_column + 100, substr(string_column, 1, 2) from foo 
where string_column = 'bar';
   
+---------------+-------------------------------------------------------------------------------------------------------+
   | plan_type     | plan                                                       
                                           |
   
+---------------+-------------------------------------------------------------------------------------------------------+
   | logical_plan  | Projection: CAST(foo.int_column AS Int64) + Int64(100), 
substr(foo.string_column, Int64(1), Int64(2)) |
   |               |   Filter: foo.string_column = Utf8("bar")                  
                                           |
   |               |     TableScan: foo projection=[int_column, string_column]  
                                           |
   | physical_plan | ┌───────────────────────────┐                              
                                           |
   |               | │       ProjectionExec      │                              
                                           |
   |               | │    --------------------   │                              
                                           |
   |               | │ foo.int_column + Int64(100│                              
                                           |
   |               | │             ):            │                              
                                           |
   |               | │ CAST(int_column@0 AS Int64│                              
                                           |
   |               | │          ) + 100          │                              
                                           |
   |               | │                           │                              
                                           |
   |               | │  substr(foo.string_column │                              
                                           |
   |               | │    ,Int64(1),Int64(2)):   │                              
                                           |
   |               | │ substr(string_column@1, 1,│                              
                                           |
   |               | │             2)            │                              
                                           |
   |               | └─────────────┬─────────────┘                              
                                           |
   |               | ┌─────────────┴─────────────┐                              
                                           |
   |               | │      RepartitionExec      │                              
                                           |
   |               | └─────────────┬─────────────┘                              
                                           |
   |               | ┌─────────────┴─────────────┐                              
                                           |
   |               | │    CoalesceBatchesExec    │                              
                                           |
   |               | └─────────────┬─────────────┘                              
                                           |
   |               | ┌─────────────┴─────────────┐                              
                                           |
   |               | │         FilterExec        │                              
                                           |
   |               | │    --------------------   │                              
                                           |
   |               | │         predicate:        │                              
                                           |
   |               | │   string_column@1 = bar   │                              
                                           |
   |               | └─────────────┬─────────────┘                              
                                           |
   |               | ┌─────────────┴─────────────┐                              
                                           |
   |               | │       DataSourceExec      │                              
                                           |
   |               | │    --------------------   │                              
                                           |
   |               | │        bytes: 1320        │                              
                                           |
   |               | │       format: memory      │                              
                                           |
   |               | │          rows: 1          │                              
                                           |
   |               | └───────────────────────────┘                              
                                           |
   |               |                                                            
                                           |
   
+---------------+-------------------------------------------------------------------------------------------------------+
   2 row(s) fetched.
   Elapsed 0.012 seconds.
   ```
   
   ### Describe the solution you'd like
   
   
   I would like the expressions to be nicely formatted
   
   For example instead of above it would be great to see
   
   
   ```
   | physical_plan | ┌───────────────────────────┐                              
                                           |
   |               | │       ProjectionExec      │                              
                                           |
   |               | │    --------------------   │                              
                                           |
   |               | │ foo.int_column + 100      │                              
                                           |
   |               | │                           │                              
                                           |
   |               | │ substr(string_column, 1, 2)│                             
                                            |
   |               | └─────────────┬─────────────┘      
   ```
   
   ### Describe alternatives you've considered
   
   `PhysicalExpr` already has `Debug` and `Display` impls with varying levels 
of detail. 
   
   
   One way to add another way of displaying `PhysicalExpr`, would be to add a 
new method to the `PhysicalExpr` trait for "simplified display"
   
   Maybe something like
   ```rust
       fn simply_fmt(&self, f: &mut Formatter<'_>) -> Result;
   ```
   
   We could then make this work with normal `write!` style macros
   
   
   
   
   
   ### Additional context
   
   _No response_


-- 
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.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

Reply via email to