goldmedal commented on code in PR #13880: URL: https://github.com/apache/datafusion/pull/13880#discussion_r1895366799
########## datafusion/sql/src/unparser/plan.rs: ########## @@ -121,6 +124,40 @@ impl Unparser<'_> { } } + /// Try to unparse a [UserDefinedLogicalNode] to a SQL statement. + /// If multiple unparsers are registered for the same [UserDefinedLogicalNode], + /// the last unparsing result will be returned. + fn extension_to_statement( + &self, + node: &dyn UserDefinedLogicalNode, + ) -> Result<ast::Statement> { + let mut statement = None; + for unparser in &self.udlp_unparsers { + statement = unparser.unparse_to_statement(node, self)?; + } + if let Some(statement) = statement { + Ok(statement) + } else { + not_impl_err!("Unsupported extension node: {node:?}") + } + } + + /// Try to unparse a [UserDefinedLogicalNode] to a SQL statement. + /// If multiple unparsers are registered for the same [UserDefinedLogicalNode], + /// all of them will be called in order. + fn extension_to_sql( + &self, + node: &dyn UserDefinedLogicalNode, + query: &mut Option<&mut QueryBuilder>, + select: &mut Option<&mut SelectBuilder>, + relation: &mut Option<&mut RelationBuilder>, + ) -> Result<()> { + for unparser in &self.udlp_unparsers { Review Comment: Sound greats. I think we could provide some `enum` for it like ``` UnparsedResult::Unparsed() UnparsedResult::Original() .. ``` I'll try it -- 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