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

   ### Describe the bug
   
   ```
   > SELECT CAST('0' AS decimal(38,0));
   Arrow error: Cast error: Cannot cast string '0' to value of Decimal128(38, 
10) type
   ```
   
   ### To Reproduce
   
   ```sql
   SELECT CAST('0' AS decimal(38,0));
   ```
   
   ### Expected behavior
   
   ```
   0
   ```
   
   also, the type in the message is wrong. cast was to `decimal(38,0)`, not to 
`(38, 10)`
   
   ### Additional context
   
   Many similar casts work
   
   from integer 0
   ```
   > SELECT CAST(0 AS decimal(38,0));
   +----------+
   | Int64(0) |
   +----------+
   | 0        |
   +----------+
   ```
   
   from string 1
   
   ```
   > SELECT CAST('1' AS decimal(38,0));
   +-----------+
   | Utf8("1") |
   +-----------+
   | 1         |
   +-----------+
   ```
   
   to other type than `decimal(p,0)`
   
   ```
   > SELECT CAST('0' AS decimal(38,1));
   +-----------+
   | Utf8("0") |
   +-----------+
   | 0.0       |
   +-----------+
   1 row(s) fetched.
   ```
   
   ```
   


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