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

   ### Is your feature request related to a problem or challenge?
   
   `LogicalPlan::Extension` allows the user to implement their custom logical 
plan. I think it makes sense to allow to define custom unparsing behavior for 
it. 
   
   ### Describe the solution you'd like
   
   I would like to introduce a new method for  `UserDefinedLogicalNode`
   ```rust
       /// User-defined nodes can override this method to provide a custom
       /// implementation for the unparser.
       fn unparse(
           &self,
           unparser: &Unparser,
           query: &mut Option<QueryBuilder>,
           select: &mut Option<SelectBuilder>,
           relation: &mut Option<RelationBuilder>,
           table_with_joins: &mut Option<TableWithJoinsBuilder>,
       ) -> Result<()> {
           not_impl_err!("custom unparsing not implemented")
       }
   ```
   Then, we can handle `LogicalPlan::Extension`  in the unparser like
   ```rust
       LogicalPlan::Extension(extension) => {
           extension.node.unparse(self, plan, query, Some(select), 
Some(relation), None)
       },
   ```
   
   However, the required builders haven't been made public yet. 
`UserDefinedLogicalNode` can't access the builders.
   As per the comment in `ast.rs`, we planned to move builders to sqlparser-rs.
   
https://github.com/apache/datafusion/blob/6ac199919f323f1121f1662349ed93de3446c72a/datafusion/sql/src/unparser/ast.rs#L18-L22
   
   I'm contemplating whether this move is required. When implementing a new 
unparsing feature, we may need to add some additional helper functions to the 
builder (e.g., `SelectBuilder::already_projection`). If we move it to the 
upstream crate, it would be difficult to add helper functions when required.
   
   I prefer to move builders to `datafusion-common` and make them public for 
the user and `datafusion-expr`, where the `UserDefinedLogicalNode` is located.
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to