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

   ### Describe the bug
   
   There is a regression in `first_value` coercsion after 
https://github.com/apache/datafusion/pull/10648 is merged. 
   
   The error message looks like: `Error during planning: Coercion from 
[Timestamp(Nanosecond, Some("+00:00"))] to the signature 
OneOf([ArraySignature(Array), Uniform(1, [Int8, Int16, Int32, Int64, UInt8, 
UInt16, UInt32, UInt64, Float32, Float64])]) failed.`
   
   ### To Reproduce
   
   1. Pull the latest datafusion and build `datafusion-cli` locally
   2. Write data
   ```sql
   ~/datafusion/datafusion-cli$ ./target/debug/datafusion-cli
   DataFusion CLI v38.0.0
   > CREATE TABLE table1 (
       bar DECIMAL(10,1),
       foo VARCHAR(10),
       time TIMESTAMP WITH TIME ZONE
   );
   
   INSERT INTO table1 (bar, foo, time) VALUES
   (200.0, 'me', '1970-01-01T00:00:00.000000010Z'),
   (1.0, 'me', '1970-01-01T00:00:00.000000030Z'),
   (1.0, 'me', '1970-01-01T00:00:00.000000040Z'),
   (2.0, 'you', '1970-01-01T00:00:00.000000020Z');
   
   0 row(s) fetched.
   Elapsed 0.053 seconds.
   ```
   3. Query using `first_value` errors
   ```sql
   > SELECT foo, first_value(time ORDER BY time DESC NULLS LAST) AS time FROM 
table1 GROUP BY foo ORDER BY foo;
   type_coercion
   caused by
   Error during planning: Coercion from [Timestamp(Nanosecond, Some("+00:00"))] 
to the signature OneOf([ArraySignature(Array), Uniform(1, [Int8, Int16, Int32, 
Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64])]) failed.
   ```
   
   ### Expected behavior
   
   ```sql
   > SELECT foo, first_value(time ORDER BY time DESC NULLS LAST) AS time FROM 
table1 GROUP BY foo ORDER BY foo;
   +-----+--------------------------------+
   | foo | time                           |
   +-----+--------------------------------+
   | me  | 1970-01-01T00:00:00.000000040Z |
   | you | 1970-01-01T00:00:00.000000020Z |
   +-----+--------------------------------+
   2 row(s) fetched.
   Elapsed 0.031 seconds.
   ```
   
   ### 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