jackwener commented on code in PR #5963:
URL: https://github.com/apache/arrow-datafusion/pull/5963#discussion_r1164098426


##########
datafusion-examples/examples/rewrite_expr.rs:
##########
@@ -66,11 +75,61 @@ fn observe(plan: &LogicalPlan, rule: &dyn OptimizerRule) {
     )
 }
 
-struct MyRule {}
+/// An example analyzer rule that changes Int64 literals to UInt64
+struct MyAnalyzerRule {}
+
+impl AnalyzerRule for MyAnalyzerRule {
+    fn analyze(&self, plan: LogicalPlan, _config: &ConfigOptions) -> 
Result<LogicalPlan> {
+        Self::analyze_internal(&plan)
+    }
+
+    fn name(&self) -> &str {
+        "my_analyzer_rule"
+    }
+}
+
+impl MyAnalyzerRule {
+    fn analyze_internal(plan: &LogicalPlan) -> Result<LogicalPlan> {
+        // optimize child plans first
+        let mut new_inputs = plan
+            .inputs()
+            .iter()
+            .map(|p| Self::analyze_internal(p))
+            .collect::<Result<Vec<_>>>()?;

Review Comment:
   we can use `transform_up`



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

Reply via email to