LiaCastaneda commented on code in PR #20337:
URL: https://github.com/apache/datafusion/pull/20337#discussion_r2850046622
##########
datafusion-examples/examples/custom_data_source/custom_datasource.rs:
##########
@@ -283,4 +284,20 @@ impl ExecutionPlan for CustomExec {
None,
)?))
}
+
+ fn apply_expressions(
+ &self,
+ f: &mut dyn FnMut(
+ &dyn datafusion::physical_plan::PhysicalExpr,
+ ) -> Result<TreeNodeRecursion>,
+ ) -> Result<TreeNodeRecursion> {
+ // Visit expressions in the output ordering from equivalence properties
+ let mut tnr = TreeNodeRecursion::Continue;
+ if let Some(ordering) = self.cache.output_ordering() {
+ for sort_expr in ordering {
+ tnr = tnr.visit_sibling(|| f(sort_expr.expr.as_ref()))?;
Review Comment:
It took me a while to understand `visit_sibling` -- iiuc it basically short
circuits the loop for us. Once` f `returns Stop, every subsequent
`tnr.visit_sibling(...) `call just skips the next `f` and passes `Stop`
through, so we don't need a manual match + early return after each call. I
added a small test in ExecutionPlan to test it works when it returns `Stop`
--
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]