You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/29 08:51:51 UTC

[GitHub] [arrow-rs] liukun4515 opened a new issue, #3223: precision is not considered when cast value to decimal

liukun4515 opened a new issue, #3223:
URL: https://github.com/apache/arrow-rs/issues/3223

   **Describe the bug**
   <!--
   A clear and concise description of what the bug is.
   -->
   
   If the `CastOptions {safe: true}` and cast INT32(120) to decimal(3,1), the result should be `None`, but 
   we get the result of `decimal(Some(1200),3,1)`
   
   **To Reproduce**
   <!--
   Steps to reproduce the behavior:
   -->
   
   **Expected behavior**
   <!--
   A clear and concise description of what you expected to happen.
   -->
   
   **Additional context**
   <!--
   Add any other context about the problem here.
   -->


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

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


[GitHub] [arrow-rs] liukun4515 commented on issue #3223: precision is not considered when cast value to decimal

Posted by GitBox <gi...@apache.org>.
liukun4515 commented on issue #3223:
URL: https://github.com/apache/arrow-rs/issues/3223#issuecomment-1331566959

   @viirya @tustvold  thanks for your advice.
   In the user case, some cases want to get the error when the data is overflow for the precision, and some cases don't want to get the error instead of the None for the overflowed slot in the array.


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

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


[GitHub] [arrow-rs] liukun4515 commented on issue #3223: precision is not considered when cast value to decimal

Posted by GitBox <gi...@apache.org>.
liukun4515 commented on issue #3223:
URL: https://github.com/apache/arrow-rs/issues/3223#issuecomment-1330290366

   Do you have any thoughts about this? cc @tustvold @viirya 


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

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


[GitHub] [arrow-rs] tustvold commented on issue #3223: precision is not considered when cast value to decimal

Posted by GitBox <gi...@apache.org>.
tustvold commented on issue #3223:
URL: https://github.com/apache/arrow-rs/issues/3223#issuecomment-1330294030

   I thought we had agreed to only care about overflow of the underlying type, and leave it to users to validate decimals if they care about precision. Provided we aren't overflowing and losing data, I'm not sure why we would validate precision at all?


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

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


[GitHub] [arrow-rs] viirya commented on issue #3223: precision is not considered when cast value to decimal

Posted by GitBox <gi...@apache.org>.
viirya commented on issue #3223:
URL: https://github.com/apache/arrow-rs/issues/3223#issuecomment-1331210091

   Currently we did as @tustvold mentioned. We validate decimals by `validate_decimal_precision` after casting and put nulls for overflowing slots in an array.
   
   I think it is trivial to do by users. Okay for me if you want to add something like `null_if_overflowed_precision` to do that.


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

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


[GitHub] [arrow-rs] liukun4515 commented on issue #3223: precision is not considered when cast value to decimal

Posted by GitBox <gi...@apache.org>.
liukun4515 commented on issue #3223:
URL: https://github.com/apache/arrow-rs/issues/3223#issuecomment-1330304809

   > I thought we had agreed to only care about overflow of the underlying type, and leave it to users to validate decimals if 
   they care about precision. Provided we aren't overflowing and losing data, I'm not sure why we would validate precision at all?
   
   Now arrow-rs has the API of `pub fn validate_decimal_precision(&self, precision: u8) -> Result<(), ArrowError> ` to check the precision for the decimal array.
   I think we need a method to do the above requirements, if the value is overflow the precision, and it should be converted to None.
   Maybe we should provide the api to change the `null_bit_map` in the DecimalArray, If user want to validate precision to get `None` or `Error`.
   
   @tustvold 


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

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


[GitHub] [arrow-rs] tustvold closed issue #3223: precision is not considered when cast value to decimal

Posted by GitBox <gi...@apache.org>.
tustvold closed issue #3223: precision is not considered when cast value to decimal
URL: https://github.com/apache/arrow-rs/issues/3223


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

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


[GitHub] [arrow-rs] tustvold commented on issue #3223: precision is not considered when cast value to decimal

Posted by GitBox <gi...@apache.org>.
tustvold commented on issue #3223:
URL: https://github.com/apache/arrow-rs/issues/3223#issuecomment-1330357195

   Adding a `null_if_overflowed_precision` method makes sense to me


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

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