You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jiangzhx (via GitHub)" <gi...@apache.org> on 2023/03/05 04:30:40 UTC

[GitHub] [arrow-datafusion] jiangzhx commented on a diff in pull request #5468: Apply workaround for #5444 to `DataFrame::describe`

jiangzhx commented on code in PR #5468:
URL: https://github.com/apache/arrow-datafusion/pull/5468#discussion_r1125596047


##########
datafusion/core/src/dataframe.rs:
##########
@@ -344,24 +344,42 @@ impl DataFrame {
             .collect::<Vec<_>>();
         describe_schemas.insert(0, Field::new("describe", DataType::Utf8, false));
 
+        //count aggregation
+        let cnt = self.clone().aggregate(
+            vec![],
+            original_schema_fields
+                .clone()
+                .map(|f| count(col(f.name())))

Review Comment:
   **.map(|f| count(col(f.name())).alias(f.name()))   not work, missing select projection.** 
   ```
   ProjectionExec: expr=[7300 as COUNT(id), 7300 as COUNT(bool_col), 7300 as COUNT(tinyint_col), 7300 as COUNT(smallint_col), 7300 as COUNT(int_col), 7300 as COUNT(bigint_col), 7300 as COUNT(float_col), 7300 as COUNT(double_col), 7300 as COUNT(date_string_col), 7300 as COUNT(string_col), 7300 as COUNT(timestamp_col), 7300 as COUNT(year), 7300 as COUNT(month)]         
       EmptyExec: produce_one_row=true
   ```
   
   
   | COUNT(id) | COUNT(bool_col) | COUNT(tinyint_col) | COUNT(smallint_col) | COUNT(int_col) | COUNT(bigint_col) | COUNT(float_col) | COUNT(double_col) | COUNT(date_string_col) | COUNT(string_col) | COUNT(timestamp_col) | COUNT(year) | COUNT(month) |
   |-----------|-----------------|--------------------|---------------------|----------------|-------------------|------------------|-------------------|------------------------|-------------------|----------------------|-------------|--------------|
   | 7300      | 7300            | 7300               | 7300                | 7300           | 7300              | 7300             | 7300              | 7300                   | 7300              | 7300                 | 7300        | 7300         |
   
   
   
   
   **.map(|f| count(col(f.name())))  work,aggregation with projection** 
   ```
   ProjectionExec: expr=[COUNT(?table?.id)@0 as id, COUNT(?table?.bool_col)@1 as bool_col, COUNT(?table?.tinyint_col)@2 as tinyint_col, COUNT(?table?.smallint_col)@3 as smallint_col, COUNT(?table?.int_col)@4 as int_col, COUNT(?table?.bigint_col)@5 as bigint_col, COUNT(?table?.float_col)@6 as float_col, COUNT(?table?.double_col)@7 as double_col, COUNT(?table?.date_string_col)@8 as date_string_col, COUNT(?table?.string_col)@9 as string_col, COUNT(?table?.timestamp_col)@10 as timestamp_col, COUNT(?table?.year)@11 as year, COUNT(?table?.month)@12 as month] 
           ProjectionExec: expr=[7300 as COUNT(id), 7300 as COUNT(bool_col), 7300 as COUNT(tinyint_col), 7300 as COUNT(smallint_col), 7300 as COUNT(int_col), 7300 as COUNT(bigint_col), 7300 as COUNT(float_col), 7300 as COUNT(double_col), 7300 as COUNT(date_string_col), 7300 as COUNT(string_col), 7300 as COUNT(timestamp_col), 7300 as COUNT(year), 7300 as COUNT(month)]                                                                                                                                                                                                    
               EmptyExec: produce_one_row=true                     
   ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
   | id   | bool_col | tinyint_col | smallint_col | int_col | bigint_col | float_col | double_col | date_string_col | string_col | timestamp_col | year | month |
   |------|----------|-------------|--------------|---------|------------|-----------|------------|-----------------|------------|---------------|------|-------|
   | 7300 | 7300     | 7300        | 7300         | 7300    | 7300       | 7300      | 7300       | 7300            | 7300       | 7300          | 7300 | 7300  |
   
   



-- 
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-unsubscribe@arrow.apache.org

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