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

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   
   DataFusion supports a few literal expression types for a `VALUES` list 
clause:
   
   ```sql
   SELECT
   * 
   FROM (
     VALUES (5, 'foo')
   ) as t (col1, col2)
   ```
   
   However, typed string literals, like a `TIMESTAMP` are not supported:
   
   ```sql
   select * from (VALUES (TIMESTAMP '2021-06-10 17:01:00Z')) as t (time);
   ```
   ```
   NotImplemented("Unsupported value TypedString { data_type: Timestamp, value: 
\"2021-06-10 17:01:00Z\" } in a values list expression")
   ```
   
   Every time we wish to refer to the `time` column as a `TIMESTAMP`, we have 
to `CAST` it first, such as in this contrived example:
   
   ```sql
   SELECT DATE_TRUNC('minute', CAST(time AS TIMESTAMP)) AS time 
   FROM (
     VALUES ('2021-06-10 17:01:30Z')
   ) as t (time) 
   WHERE CAST(time AS TIMESTAMP) > TIMESTAMP '2021-01-01 00:00:00';
   ```
   ```
   +---------------------+
   | time                |
   +---------------------+
   | 2021-06-10 17:01:00 |
   +---------------------+
   1 row in set. Query took 0.004 seconds.
   ```
   
   See the next section for the improved user experience.
   
   **Describe the solution you'd like**
   
   Add support for typed string literals to a `VALUES` list. As demonstrated 
below, the SQL statement becomes less verbose and  strict typing:
   
   ```sql
   SELECT DATE_TRUNC('minute', time) AS time 
   FROM (
     VALUES (TIMESTAMP '2021-06-10 17:01:30Z')) as t (time) 
   WHERE time > TIMESTAMP '2021-01-01 00:00:00';
   ```
   ```
   +---------------------+
   | time                |
   +---------------------+
   | 2021-06-10 17:01:00 |
   +---------------------+
   1 row in set. Query took 0.007 seconds.
   ```
   
   **Describe alternatives you've considered**
   
   A workaround is possible, however, PostgreSQL supports this syntax, so it 
would be consistent for DataFusion to provide a similar experience.
   
   


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

Reply via email to