ccciudatu commented on code in PR #13803: URL: https://github.com/apache/datafusion/pull/13803#discussion_r1888961320
########## datafusion/substrait/tests/cases/roundtrip_logical_plan.rs: ########## @@ -977,6 +984,43 @@ async fn new_test_grammar() -> Result<()> { .await } +struct MockSubstraitConsumer { + extensions: Extensions, + state: SessionState, +} + +#[async_trait] +impl SubstraitConsumer for MockSubstraitConsumer { + async fn resolve_table_ref( + &self, + _: &TableReference, + ) -> Result<Option<Arc<dyn TableProvider>>> { + not_impl_err!("MockSubstraitConsumer does not implement resolve_table_ref") + } + + fn get_extensions(&self) -> &Extensions { + &self.extensions + } + + fn get_state(&self) -> &SessionState { + &self.state + } + + async fn consume_extension_leaf( + &self, + rel: &ExtensionLeafRel, + ) -> Result<LogicalPlan> { + let Some(ext_detail) = &rel.detail else { + return substrait_err!("Unexpected empty detail in ExtensionLeafRel"); + }; + let plan = self + .state + .serializer_registry() + .deserialize_logical_plan(&ext_detail.type_url, &ext_detail.value)?; Review Comment: One drawback of the current implementation is that it's abusing the `type_url` field in `proto::Any` (which is quite [clearly specified](https://protobuf.dev/reference/java/api-docs/com/google/protobuf/AnyOrBuilder.html#getTypeUrl--)). Working with Substrait objects directly would eliminate the need for hacks like encoding node names as Any::type_url. As a side note, this may sound hypocritical, given that I made it even worse [with my PR](https://github.com/apache/datafusion/pull/13772) by setting it to table names as well. But I only did it for consistency. :) -- 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