viirya opened a new issue, #6191:
URL: https://github.com/apache/arrow-datafusion/issues/6191

   ### Describe the bug
   
   As discussed in 
https://github.com/apache/arrow-datafusion/pull/6175#pullrequestreview-1407610779,
 `sum` and `avg` cannot handle inputs of Dictionary but `min` and `max` can. We 
should make them consistent in Dictionary input handling by adding the support 
to `sum` and `avg`.
   
   ### To Reproduce
   
   ```sql
   ❯ create table value(x bigint) as values (1), (2), (3), (4), (5);
   0 rows in set. Query took 0.006 seconds.
   ❯ create table value_dict as select arrow_cast(x, 'Dictionary(Int64, 
Int32)') as x_dict from value;
   0 rows in set. Query took 0.003 seconds.
   ❯ select * from value_dict;
   +--------+
   | x_dict |
   +--------+
   | 1      |
   | 2      |
   | 3      |
   | 4      |
   | 5      |
   +--------+
   5 rows in set. Query took 0.002 seconds.
   ❯ select sum(x_dict) from value_dict;
   Error during planning: The function Sum does not support inputs of type 
Dictionary(Int64, Int32).
   ❯ select avg(x_dict) from value_dict;
   Error during planning: The function Avg does not support inputs of type 
Dictionary(Int64, Int32).
   ❯ select min(x_dict) from value_dict;
   +------------------------+
   | MIN(value_dict.x_dict) |
   +------------------------+
   | 1                      |
   +------------------------+
   1 row in set. Query took 0.005 seconds.
   ❯ select max(x_dict) from value_dict;
   +------------------------+
   | MAX(value_dict.x_dict) |
   +------------------------+
   | 5                      |
   +------------------------+
   1 row in set. Query took 0.004 seconds.
   ```
   
   
   ### Expected behavior
   
   `sum` and `avg` should be able to take Dictionary inputs.
   
   ### Additional context
   
   _No response_


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

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

Reply via email to