crepererum commented on code in PR #13343:
URL: https://github.com/apache/datafusion/pull/13343#discussion_r1850131803


##########
datafusion/substrait/src/logical_plan/context.rs:
##########
@@ -0,0 +1,63 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::sync::Arc;
+
+use async_trait::async_trait;
+use datafusion::{
+    catalog::TableProvider,
+    error::{DataFusionError, Result},
+    execution::{registry::SerializerRegistry, FunctionRegistry, SessionState},
+    sql::TableReference,
+};
+
+/// This trait provides the context needed to transform a substrait plan into a
+/// [`datafusion::logical_expr::LogicalPlan`] (via 
[`super::consumer::from_substrait_plan`])
+/// and back again into a substrait plan (via 
[`super::producer::to_substrait_plan`]).
+///
+/// The context is declared as a trait to decouple the substrait plan encoder /
+/// decoder from the [`SessionState`], potentially allowing users to define
+/// their own slimmer context just for serializing and deserializing substrait.
+///
+/// [`SessionState`] implements this trait.
+#[async_trait]
+pub trait SubstraitPlanningContext: Sync + Send + FunctionRegistry {
+    /// Return [SerializerRegistry] for extensions
+    fn serializer_registry(&self) -> &Arc<dyn SerializerRegistry>;
+
+    async fn table(
+        &self,
+        reference: &TableReference,
+    ) -> Result<Option<Arc<dyn TableProvider>>>;
+}
+
+#[async_trait]
+impl SubstraitPlanningContext for SessionState {

Review Comment:
   One nitpick: since we have `SessionContext` as well, this gets rather 
confusing. Could you rename the trait to `SubstraitPlanningState`?



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