Jefffrey commented on issue #17269:
URL: https://github.com/apache/datafusion/issues/17269#issuecomment-3455535740

   I don't think this is a bug, rather it's what is expected for aggregate 
functions. We are consistent with other systems such as:
   
   **DuckDB**
   
   ```sql
   D with t as (select 1 as id, 2 as value where 1=0) select last(value order 
by id) from t;
   ┌─────────────────────────────┐
   │ "last"("value" ORDER BY id) │
   │            int32            │
   ├─────────────────────────────┤
   │            NULL             │
   └─────────────────────────────┘
   ```
   
   **Postgres**
   
   ```sql
   postgres=# with t as (select 1 as id, 2 as value where 1=0) select 
sum(value) from t where 1=0;
    sum
   -----
   
   (1 row)
   ```
   
   - Using `sum` as they don't have last/first (only for window functions)
   
   **Spark**
   
   ```python
   >>> spark.sql("with t as (select 1 as id, 2 as value where 1=0) select 
last(value) from t").show()
   +-----------+
   |last(value)|
   +-----------+
   |       NULL|
   +-----------+
   ```
   
   I'll close this as not planned, feel free to leave a comment if you think 
this should stay open 👍 


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to