gstvg commented on code in PR #21193:
URL: https://github.com/apache/datafusion/pull/21193#discussion_r3208846802


##########
datafusion/substrait/src/logical_plan/producer/substrait_producer.rs:
##########
@@ -471,4 +551,109 @@ impl SubstraitProducer for DefaultSubstraitProducer<'_> {
             rel_type: Some(rel_type),
         }))
     }
+
+    fn push_lambda_parameters(
+        &mut self,
+        lambda_parameters: Vec<FieldRef>,
+    ) -> datafusion::common::Result<()> {
+        let lambda_parameters_map = lambda_parameters_map(self, 
lambda_parameters)?;
+
+        self.lambda_producer
+            .push_lambda_parameters(lambda_parameters_map);
+
+        Ok(())
+    }
+
+    fn pop_lambda_parameters(&mut self) -> datafusion::common::Result<()> {
+        self.lambda_producer.pop_lambda_parameters()
+    }
+
+    fn lambda_variable(&self, name: &str) -> datafusion::common::Result<(u32, 
i32)> {
+        self.lambda_producer.lambda_variable(name)
+    }
+
+    fn lambda_parameter_type(
+        &self,
+        name: &str,
+    ) -> datafusion::common::Result<substrait::proto::Type> {
+        self.lambda_producer.lambda_parameter_type(name)
+    }
+}
+
+/// Default implementation of lambda related methods of the 
[SubstraitProducer] trait
+///
+/// Can be embedded into a custom [SubstraitProducer] to implement them
+pub struct DefaultSubstraitLambdaProducer {

Review Comment:
   Same reason for the consumer. What get's decided there 
(https://github.com/apache/datafusion/pull/21193#discussion_r3182809458) I'll 
also apply here
   
   ```rust
   struct CustomSubstraitProducer {
       extensions: Extensions,
       state: Arc<SessionState>,
       // You can reuse existing producer code related to lambdas
       lambda_producer: DefaultSubstraitLambdaProducer,
   }
   
   impl SubstraitProducer for CustomSubstraitProducer {
       fn register_function(&mut self, signature: String) -> u32 {
           self.extensions.register_function(&signature)
       }
   
       fn register_type(&mut self, type_name: String) -> u32 {
           self.extensions.register_type(&type_name)
       }
   
       fn get_extensions(self) -> Extensions {
           self.extensions
       }
   
       fn push_lambda_parameters(
           &mut self,
           lambda_parameters: Vec<FieldRef>,
       ) -> datafusion::common::Result<()> {
           let lambda_parameters_map = lambda_parameters_map(self, 
lambda_parameters)?;
   
           self.lambda_producer
               .push_lambda_parameters(lambda_parameters_map);
   
           Ok(())
       }
   
       fn pop_lambda_parameters(&mut self) -> datafusion::common::Result<()> {
           self.lambda_producer.pop_lambda_parameters()
       }
   
       fn lambda_variable(&self, name: &str) -> 
datafusion::common::Result<(u32, i32)> {
           self.lambda_producer.lambda_variable(name)
       }
   
       fn lambda_parameter_type(
           &self,
           name: &str,
       ) -> datafusion::common::Result<substrait::proto::Type> {
           self.lambda_producer.lambda_parameter_type(name)
       }
   }
   ```



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