xudong963 commented on code in PR #15954:
URL: https://github.com/apache/datafusion/pull/15954#discussion_r2105707191


##########
datafusion/physical-plan/src/aggregates/mod.rs:
##########
@@ -733,13 +733,33 @@ impl AggregateExec {
         &self.input_order_mode
     }
 
-    fn statistics_inner(&self) -> Result<Statistics> {
+    fn statistics_inner(&self, child_statistics: Statistics) -> 
Result<Statistics> {
         // TODO stats: group expressions:
         // - once expressions will be able to compute their own stats, use it 
here
         // - case where we group by on a column for which with have the 
`distinct` stat
         // TODO stats: aggr expression:
         // - aggregations sometimes also preserve invariants such as min, 
max...
-        let column_statistics = Statistics::unknown_column(&self.schema());
+
+        let column_statistics = {
+            // self.schema: [<group by exprs>, <aggregate exprs>]
+            let mut column_statistics = 
Statistics::unknown_column(&self.schema());
+
+            for (idx, (expr, _)) in self.group_by.expr.iter().enumerate() {

Review Comment:
   If we adjust the order of group by exprs in the test, does it still match?
   ```
   let group_by = PhysicalGroupBy::new_single(vec![
               (
                   binary(
                       lit(1),
                       Operator::Plus,
                       col("id", &scan_schema)?,
                       &scan_schema,
                   )?,
                   "expr".to_string(),
               ),
               (col("id", &scan_schema)?, "id".to_string()),
           ]);
   ```
   The `idx` will be 1,  and it'll point to the `date` column in the scan.
   
   Correct me if I missed something



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to