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

[GitHub] [arrow-datafusion] alamb opened a new issue, #5595: Make median return `null` on empty input rather than error

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

   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   @Jefffrey  notes in https://github.com/apache/arrow-datafusion/pull/5560#pullrequestreview-1336092803 that we are inconsistent with polars, which seems to return null for empty inputs:
   
   >>> df = pl.DataFrame({"foo": []})
   >>> df.median()
   shape: (1, 1)
   ┌──────┐
   │ foo  │
   │ ---  │
   │ f32  │
   ╞══════╡
   │ null │
   └──────┘
   >>>
   
   
   **Describe the solution you'd like**
   Be consistent with polars (return null) .
   
   While postgres does not support `median` so we can't use its behavior as a guide, returning `null` on empty input would be consistent with the other sql aggregate functions such as `sum`
   
   For example:
   
   ```sql
   
   postgres=# create table t as values (1);
   SELECT 1
   postgres=#  select median(column1) from t where column1 < 0;
   ERROR:  function median(integer) does not exist
   LINE 1: select median(column1) from t where column1 < 0;
                  ^
   HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
   postgres=#  select sum(column1) from t where column1 < 0;
    sum
   -----
   
   (1 row)
   ```
   
   **Describe alternatives you've considered**
   Leave as error
   
   **Additional context**
   


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

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


[GitHub] [arrow-datafusion] alamb closed issue #5595: Make median return `null` on empty input rather than error

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #5595: Make median return `null` on empty input rather than error
URL: https://github.com/apache/arrow-datafusion/issues/5595


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


[GitHub] [arrow-datafusion] toppyy commented on issue #5595: Make median return `null` on empty input rather than error

Posted by "toppyy (via GitHub)" <gi...@apache.org>.
toppyy commented on issue #5595:
URL: https://github.com/apache/arrow-datafusion/issues/5595#issuecomment-1470651513

   Hi! I've never contributed before, but could take a look if this is up for grabs?


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


[GitHub] [arrow-datafusion] alamb commented on issue #5595: Make median return `null` on empty input rather than error

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #5595:
URL: https://github.com/apache/arrow-datafusion/issues/5595#issuecomment-1470281984

   I think this is a good first issue as the desired behavior is well defined and there are existing tests


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


[GitHub] [arrow-datafusion] jhorstmann commented on issue #5595: Make median return `null` on empty input rather than error

Posted by "jhorstmann (via GitHub)" <gi...@apache.org>.
jhorstmann commented on issue #5595:
URL: https://github.com/apache/arrow-datafusion/issues/5595#issuecomment-1470266735

   The corresponding postgres syntax would be
   
   ```
   SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY column1) FROM ...
   ```
   
   Which returns NULL on empty inputs.


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


[GitHub] [arrow-datafusion] alamb commented on issue #5595: Make median return `null` on empty input rather than error

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #5595:
URL: https://github.com/apache/arrow-datafusion/issues/5595#issuecomment-1470656775

   >  Hi! I've never contributed before, but could take a look if this is up for grabs?
   
   
   
   Please do @toppyy, and  welcome!


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