goldmedal opened a new issue, #12602:
URL: https://github.com/apache/datafusion/issues/12602

   ### Is your feature request related to a problem or challenge?
   
   Currently, date_trunc function only accepts `TIMESTAMP` and `TIMESTAMP WITH 
TIME ZONE`
   ```
   > select date_trunc('MONTH', TIMESTAMP '2011-02-12 12:09:08');
   +-------------------------------------------------------+
   | date_trunc(Utf8("MONTH"),Utf8("2011-02-12 12:09:08")) |
   +-------------------------------------------------------+
   | 2011-02-01T00:00:00                                   |
   +-------------------------------------------------------+
   1 row(s) fetched. 
   Elapsed 0.003 seconds.
   
   > select date_trunc('MONTH', DATE '2011-02-12');
   Error during planning: The date_trunc function can only accept timestamp as 
the second arg.
   > select date_trunc('MONTH', current_date());
   Error during planning: The date_trunc function can only accept timestamp as 
the second arg.
   ```
   
   In other databases (e.g. DuckDB), `DATE` is also acceptable.
   ```
   D select date_trunc('MONTH', DATE '2011-02-12');
   ┌─────────────────────────────────────────────────┐
   │ date_trunc('MONTH', CAST('2011-02-12' AS DATE)) │
   │                      date                       │
   ├─────────────────────────────────────────────────┤
   │ 2011-02-01                                      │
   └─────────────────────────────────────────────────┘
   D select date_trunc('MONTH', current_date());
   ┌─────────────────────────────────────┐
   │ date_trunc('MONTH', current_date()) │
   │                date                 │
   ├─────────────────────────────────────┤
   │ 2024-09-01                          │
   └─────────────────────────────────────┘
   ```
   
   I think it's reasonable to support `DATE` type in DataFusion.
   
   
   ### Describe the solution you'd like
   
   Add `Date32` to the `return_type` match at `date_trunc.rs`
   
https://github.com/apache/datafusion/blob/6546479c862af9a31a50d36b700c0e4b485ef105/datafusion/functions/src/datetime/date_trunc.rs#L124-L135
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### 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...@datafusion.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to