Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for AVG(Timestamp) types #200

Closed
Tracked by #3148
alamb opened this issue Apr 26, 2021 · 5 comments
Closed
Tracked by #3148

Add support for AVG(Timestamp) types #200

alamb opened this issue Apr 26, 2021 · 5 comments
Labels
datafusion Changes in the datafusion crate

Comments

@alamb
Copy link
Contributor

alamb commented Apr 26, 2021

Note: migrated from original JIRA: https://issues.apache.org/jira/browse/ARROW-12318

This is a follow on to ARROW-12277

Background: Support for Min/Max/Sum/Count were added for DataType::Timestamp(*) types in apache/arrow#9970.

This ticket tracks adding support for Avg, which is slightly more involved as currently Avg assumes the output type is always F64, and in this case I think Avg(timestamp) should also be (timestamp). We should double check what postgres does in this case and follow its example

@alamb alamb added the datafusion Changes in the datafusion crate label Apr 26, 2021
@alamb
Copy link
Contributor Author

alamb commented Apr 26, 2021

Comment from Andrew Lamb(alamb) @ 2021-04-11T09:48:09.161+0000:

[~Dandandan] notes that PostgreSQL doesn't support SUM or AVG for timestamps: https://www.postgresql.org/docs/13/functions-aggregate.html


so perhaps we should not support it in DataFusion either :thinking_face:

@waitingkuo
Copy link
Contributor

@alamb

Postgresql has AVG and SUM for time but not timestamps

Should we close this and submit another ticket for AVG(Time) and SUM(Time)?

@alamb
Copy link
Contributor Author

alamb commented Aug 15, 2022

@waitingkuo -- I think that sounds like a good idea. I will do so.

@waitingkuo
Copy link
Contributor

@alamb i just tested postgrseql, looks like SUM and AVG cast Time to Interval and then SUM / AVG them

willy=# select pg_typeof(SUM(time '00:00:00')),  pg_typeof(AVg(time '00:00:00'));
 pg_typeof | pg_typeof 
-----------+-----------
 interval  | interval
(1 row)

this make sense otherwise SUM(Time) is just quite strange

@alamb
Copy link
Contributor Author

alamb commented Aug 15, 2022

#3166 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate
Projects
None yet
Development

No branches or pull requests

2 participants