You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "findepi (via GitHub)" <gi...@apache.org> on 2024/10/11 13:18:30 UTC

[I] Cannot cast varchar `'0'` to `decimal(p,0)` [datafusion]

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: github-unsubscribe@datafusion.apache.org.apache.org

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


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


Re: [I] Cannot cast varchar `'0'` to `decimal(p,0)` [datafusion]

Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on issue #12870:
URL: https://github.com/apache/datafusion/issues/12870#issuecomment-2407492580

   Proposed fix: https://github.com/apache/arrow-rs/pull/6547


-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [I] Cannot cast varchar `'0'` to `decimal(p,0)` [datafusion]

Posted by "blaginin (via GitHub)" <gi...@apache.org>.
blaginin commented on issue #12870:
URL: https://github.com/apache/datafusion/issues/12870#issuecomment-2501825020

   @findepi maybe we can close  this issue? seems to work for me after your change
   
   ```sql
   > SELECT CAST('0' AS decimal(38,0));
   +-----------+
   | Utf8("0") |
   +-----------+
   | 0         |
   +-----------+
   1 row(s) fetched. 
   Elapsed 0.003 seconds.
   ```


-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [I] Cannot cast varchar `'0'` to `decimal(p,0)` [datafusion]

Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on issue #12870:
URL: https://github.com/apache/datafusion/issues/12870#issuecomment-2407482636

   take


-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [I] Cannot cast varchar `'0'` to `decimal(p,0)` [datafusion]

Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao closed issue #12870: Cannot cast varchar `'0'` to `decimal(p,0)`
URL: https://github.com/apache/datafusion/issues/12870


-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [I] Cannot cast varchar `'0'` to `decimal(p,0)` [datafusion]

Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on issue #12870:
URL: https://github.com/apache/datafusion/issues/12870#issuecomment-2501828623

   thanks @blaginin! it's likely fixed by recent arrow update
   let's maybe add one regression test in slt?


-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [I] Cannot cast varchar `'0'` to `decimal(p,0)` [datafusion]

Posted by "blaginin (via GitHub)" <gi...@apache.org>.
blaginin commented on issue #12870:
URL: https://github.com/apache/datafusion/issues/12870#issuecomment-2501830984

   happy to help 🫡


-- 
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-unsubscribe@datafusion.apache.org

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


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