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


##########
datafusion/substrait/src/logical_plan/context.rs:
##########
@@ -0,0 +1,54 @@
+// 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,
+};
+
+#[async_trait]
+pub trait Context: Sync + Send + FunctionRegistry {

Review Comment:
   Could we please add some documentation here explaining
   1. What this trait is used for (provide the needed API to substrait 
encoding/deocing)
   2. That it is implemented for SessionState? 
   
   Also as `Context` is fairly generic, perhaps we could rename it to something 
like `SubstraitContext` or `SubstraitPlanningContext`



##########
datafusion/substrait/src/logical_plan/context.rs:
##########
@@ -0,0 +1,54 @@
+// 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,
+};
+
+#[async_trait]
+pub trait Context: 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 Context for SessionState {

Review Comment:
   What would you think about also `impl Context` for `SessionContext` ? That 
would minimize the potential API changes on downstream users (also it would 
likely allow you to avoid many of the changes in this PR to the tests)?



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