Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Hive Parquet test failure on certain Arm machines #15185

Merged
merged 2 commits into from
Nov 24, 2022

Conversation

findepi
Copy link
Member

@findepi findepi commented Nov 24, 2022

No description provided.

The code used double-precision calculation to find bounds for decimal
values. This is prone to double rounding errors and indeed produces
"approximate" results (the approximation is rather poor for decimal
precision > 17). On some computers, this could lead to `start` or `end`
being beyond allowed range for the type (exceeding precision), so test
would fail due to a test value overflow. Failure could result in a NPE
because Hive replaces overflows with nulls.

For example, printing `BigDecimal.valueOf(Math.pow(10,
29)).subtract(BigDecimal.valueOf(1)).negate().toBigInteger()` was
observed producing
"-100000000000000009999999999999" (30 characters and the minus sign)
"-99999999999999999999999999999" (29 characters and the minus sign)
on two different laptops.
Do not use `BigDecimal` where `BigInteger` would suffice.
@cla-bot cla-bot bot added the cla-signed label Nov 24, 2022
@findepi findepi added test no-release-notes This pull request does not require release notes entry labels Nov 24, 2022
@skrzypo987
Copy link
Member

Can you share what is the difference between architectures here. This seems really interesting.

@findepi
Copy link
Member Author

findepi commented Nov 24, 2022

@skrzypo987 see first commit message

@skrzypo987
Copy link
Member

@skrzypo987 see first commit message

Wow. I guess the problem was on M1 cpu. I wonder if common server ARMs suffer the same "feature"

@findepi
Copy link
Member Author

findepi commented Nov 24, 2022

Wow. I guess the problem was on M1 cpu. I wonder if common server ARMs suffer the same "feature"

Shall we assume that Math.pow(10d, 29d) has deterministic result (except for Apple M1)?

@skrzypo987
Copy link
Member

Wow. I guess the problem was on M1 cpu. I wonder if common server ARMs suffer the same "feature"

Shall we assume that Math.pow(10d, 29d) has deterministic result (except for Apple M1)?

Nothing calculated using floating point arithmetic has deterministic result anywhere. I wouldn't be surprised if the result from M1 was correct, because it's a new CPU and they forgot to make it wrong to be compatible with older ones.

@findepi
Copy link
Member Author

findepi commented Nov 24, 2022

CI #15187

@findepi findepi merged commit 1179f14 into trinodb:master Nov 24, 2022
@github-actions github-actions bot added this to the 404 milestone Nov 24, 2022
@findepi findepi deleted the findepi/fix-parq-test branch November 24, 2022 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed no-release-notes This pull request does not require release notes entry test
Development

Successfully merging this pull request may close these issues.

3 participants