Dandandan commented on code in PR #7192:
URL: https://github.com/apache/arrow-datafusion/pull/7192#discussion_r1284084809


##########
datafusion/core/src/physical_optimizer/limit_aggregation.rs:
##########
@@ -0,0 +1,67 @@
+use std::sync::Arc;
+use datafusion_common::config::ConfigOptions;
+use crate::physical_optimizer::PhysicalOptimizerRule;
+use crate::physical_plan::ExecutionPlan;
+use crate::physical_plan::sorts::sort::SortExec;
+use datafusion_common::{DataFusionError, Result};
+use crate::physical_plan::aggregates::AggregateExec;
+
+pub struct LimitAggregation {
+
+}
+
+impl LimitAggregation {
+    pub fn new() -> Self {
+        Self {}
+    }
+
+    fn recurse(plan: Arc<dyn ExecutionPlan>) -> Result<Arc<dyn ExecutionPlan>> 
{
+        if let Some(sort) = plan.as_any().downcast_ref::<SortExec>() {
+            let children = sort.children();
+            let child = match children.as_slice() {
+                [] => Err(DataFusionError::Execution("Sorts should have 
children".to_string()))?,
+                [child] => child,
+                _ => Err(DataFusionError::Execution("Sorts should have 1 
child".to_string()))?,
+            };
+            let binding = (*child).as_any();
+            if let Some(aggr) = binding.downcast_ref::<AggregateExec>() {

Review Comment:
   Ah I see it was added in `AggregateExec` - is it possible to perform the 
check in the rule?



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