You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "manuzhang (via GitHub)" <gi...@apache.org> on 2025/12/16 14:43:41 UTC
[PR] fix: format decimal to string when casting to integral type [datafusion-comet]
manuzhang opened a new pull request, #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #2914.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## How are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
Updated CometCastSuite.
--
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: [PR] fix: format decimal to string when casting to integral type [datafusion-comet]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#discussion_r2629165385
##########
native/spark-expr/src/conversion_funcs/cast.rs:
##########
@@ -755,11 +757,13 @@ macro_rules! cast_decimal_to_int32_up {
.map(|value| match value {
Some(value) => {
let divisor = 10_i128.pow($scale as u32);
- let (truncated, decimal) = (value / divisor, (value % divisor).abs());
+ let truncated = value / divisor;
let is_overflow = truncated.abs() > $max_dest_val.into();
+ let fmt_str =
Review Comment:
Can this be moved into the `if is_overflow {..}` block?
--
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: [PR] fix: format decimal to string when casting to short [datafusion-comet]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#issuecomment-3707850222
@manuzhang The `cast_decimal_to_int32_up` function also has a similar issue. Could you fix it as well?
Reproduce test case:
```
castTest(
generateDecimalsPrecision38Scale18(Seq(BigDecimal("-99999999999999999999.07"))),
DataTypes.LongType)
```
error:
```
"...9999999999999999999.[]70000000000000000BD ..." did not equal "...9999999999999999999.[0]70000000000000000BD ..."
```
--
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: [PR] fix: format decimal to string when casting to short [datafusion-comet]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#discussion_r2638756779
##########
native/spark-expr/src/conversion_funcs/cast.rs:
##########
@@ -755,11 +757,13 @@ macro_rules! cast_decimal_to_int32_up {
.map(|value| match value {
Some(value) => {
let divisor = 10_i128.pow($scale as u32);
- let (truncated, decimal) = (value / divisor, (value % divisor).abs());
+ let truncated = value / divisor;
let is_overflow = truncated.abs() > $max_dest_val.into();
+ let fmt_str =
Review Comment:
> Nope, `fmt_str` will be out of scope.
`fmt_str` seems to be needed only on error, we should avoid always creating it.
--
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: [PR] fix: format decimal to string when casting to integral type [datafusion-comet]
Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang commented on PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#issuecomment-3666043191
@rohitrastogi @andygrove Please help review when you find time. Thanks!
--
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: [PR] fix: format decimal to string when casting to short [datafusion-comet]
Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang closed pull request #2916: fix: format decimal to string when casting to short
URL: https://github.com/apache/datafusion-comet/pull/2916
--
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: [PR] fix: format decimal to string when casting to integral type [datafusion-comet]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#issuecomment-3661078092
## [Codecov](https://app.codecov.io/gh/apache/datafusion-comet/pull/2916?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 10.08%. Comparing base ([`f09f8af`](https://app.codecov.io/gh/apache/datafusion-comet/commit/f09f8af64c6599255e116a376f4f008f2fd63b43?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`7a47424`](https://app.codecov.io/gh/apache/datafusion-comet/commit/7a4742417d48916f54652f1c726817c98afd433c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 769 commits behind head on main.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #2916 +/- ##
=============================================
- Coverage 56.12% 10.08% -46.05%
+ Complexity 976 234 -742
=============================================
Files 119 167 +48
Lines 11743 15339 +3596
Branches 2251 2522 +271
=============================================
- Hits 6591 1547 -5044
- Misses 4012 13615 +9603
+ Partials 1140 177 -963
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/datafusion-comet/pull/2916?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
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: [PR] fix: format decimal to string when casting to integral type [datafusion-comet]
Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang commented on code in PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#discussion_r2629450588
##########
native/spark-expr/src/conversion_funcs/cast.rs:
##########
@@ -755,11 +757,13 @@ macro_rules! cast_decimal_to_int32_up {
.map(|value| match value {
Some(value) => {
let divisor = 10_i128.pow($scale as u32);
- let (truncated, decimal) = (value / divisor, (value % divisor).abs());
+ let truncated = value / divisor;
let is_overflow = truncated.abs() > $max_dest_val.into();
+ let fmt_str =
Review Comment:
Nope, `fmt_str` will be out of scope.
--
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: [PR] fix: format decimal to string when casting to integral type [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#discussion_r2632571707
##########
spark/src/test/scala/org/apache/comet/CometCastSuite.scala:
##########
@@ -1030,7 +1030,9 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper {
test("cast between decimals with higher precision than source") {
// cast between Decimal(10, 2) to Decimal(10,4)
- castTest(generateDecimalsPrecision10Scale2(), DataTypes.createDecimalType(10, 4))
+ castTest(
Review Comment:
@manuzhang I pulled these test changes locally using latest from main branch and they pass for me, so I'm not sure that these tests reproduce the problem that the fix is intended to address?
--
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: [PR] fix: format decimal to string when casting to short [datafusion-comet]
Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang commented on PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#issuecomment-3708157211
@wForget Thanks for the good suggestion. I was struggling with test case so I left the changes to `cast_decimal_to_int32_up` out. I've added tests for `cast DecimalType(38,18) to ShortType/IntegerType/LongType`.
--
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: [PR] fix: format decimal to string when casting to short [datafusion-comet]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#issuecomment-3709003717
Thanks @manuzhang, merged to main
--
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: [PR] fix: format decimal to string when casting to short [datafusion-comet]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget merged PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916
--
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: [PR] fix: format decimal to string when casting to short [datafusion-comet]
Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang commented on PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#issuecomment-3707528287
@andygrove @wForget Please help review again
--
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: [PR] fix: format decimal to string when casting to short [datafusion-comet]
Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang commented on code in PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#discussion_r2635601167
##########
spark/src/test/scala/org/apache/comet/CometCastSuite.scala:
##########
@@ -1030,7 +1030,9 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper {
test("cast between decimals with higher precision than source") {
// cast between Decimal(10, 2) to Decimal(10,4)
- castTest(generateDecimalsPrecision10Scale2(), DataTypes.createDecimalType(10, 4))
+ castTest(
Review Comment:
@andygrove I've reworked my PR. Could you please check again?
--
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: [PR] fix: format decimal to string when casting to short [datafusion-comet]
Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang closed pull request #2916: fix: format decimal to string when casting to short
URL: https://github.com/apache/datafusion-comet/pull/2916
--
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: [PR] fix: format decimal to string when casting to short [datafusion-comet]
Posted by "manuzhang (via GitHub)" <gi...@apache.org>.
manuzhang commented on PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#issuecomment-3677871717
Failed test is not related to this PR.
```
- Comet native operator after ShuffleQueryStage + ReusedExchange (1 second, 108 milliseconds)
Error: Exception in thread "ScalaTest-dispatcher" java.lang.NoClassDefFoundError: $anonfun$doPreserve$1
at org.scalatest.tools.PrettyPrinter.traverse(PrettyPrinter.scala:155)
at org.scalatest.tools.PrettyPrinter.format(PrettyPrinter.scala:231)
at org.scalatest.tools.PrettyPrinter.$anonfun$format$2(PrettyPrinter.scala:267)
at org.scalatest.tools.PrettyPrinter.$anonfun$format$2$adapted(PrettyPrinter.scala:267)
at org.scalatest.tools.XmlUtility$.sbToString(XmlUtility.scala:31)
at org.scalatest.tools.PrettyPrinter.format(PrettyPrinter.scala:267)
at org.scalatest.tools.JUnitXmlReporter.xmlify(JUnitXmlReporter.scala:385)
at org.scalatest.tools.JUnitXmlReporter.writeSuiteFile(JUnitXmlReporter.scala:77)
at org.scalatest.tools.JUnitXmlReporter.apply(JUnitXmlReporter.scala:59)
at org.scalatest.DispatchReporter$Propagator.$anonfun$run$10(DispatchReporter.scala:249)
at org.scalatest.DispatchReporter$Propagator.$anonfun$run$10$adapted(DispatchReporter.scala:248)
at scala.collection.immutable.List.foreach(List.scala:334)
at org.scalatest.DispatchReporter$Propagator.run(DispatchReporter.scala:248)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.ClassNotFoundException: $anonfun$doPreserve$1
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
... 14 more
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (concurrentHashTable.inline.hpp:678), pid=78523, tid=28931
# fatal error: aux_index does not match even or odd indices
#
# JRE version: OpenJDK Runtime Environment Zulu17.62+19-CRaC-CA (17.0.17+10) (build 17.0.17+10-LTS)
# Java VM: OpenJDK 64-Bit Server VM Zulu17.62+19-CRaC-CA (17.0.17+10-LTS, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/runner/work/datafusion-comet/datafusion-comet/spark/hs_err_pid78523.log
#
# If you would like to submit a bug report, please visit:
# http://www.azul.com/support/
#
```
--
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: [PR] fix: format decimal to string when casting to short [datafusion-comet]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #2916:
URL: https://github.com/apache/datafusion-comet/pull/2916#discussion_r2659481580
##########
spark/src/test/scala/org/apache/comet/CometCastSuite.scala:
##########
@@ -1030,7 +1030,9 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper {
test("cast between decimals with higher precision than source") {
// cast between Decimal(10, 2) to Decimal(10,4)
- castTest(generateDecimalsPrecision10Scale2(), DataTypes.createDecimalType(10, 4))
+ castTest(
Review Comment:
I verified locally that the newly added test case could reproduce the problem.
--
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