Throw an error in bitShift* if the shift position is out-of-bounds#65838
Conversation
|
This is an automated comment for commit 13f4d0d with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
|
I think it should also throw an exception when we are trying to shift for more than type width. |
Done! Even though at first I was a bit reluctant of this change because for |
One of tests actually uncovered a casting error :)
bitShift* if the shift positions is out-of-bounds
bitShift* if the shift positions is out-of-boundsbitShift* if the shift position is out-of-bounds
divanik
left a comment
There was a problem hiding this comment.
Please, pay attention to all broken test in CI after resolving the issues and right a comment with a report, why do you think that broken tests have nothing in common with your pr
The case for > bit_limit is already covered in previous branch, so we just need to cover the other case. This also fixes an overflow that was caused in previous check. e.g. b > B(word_size * n) if sizeof(B) is 1 byte but n is huge
Unrelated Unrelated possible deadlock. The test that hung has 0 references to any Unrelated test failure, 02247_read_bools_as_numbers_json failed due to an assertion in jemalloc. It's failed quite a few times lately, so I've created an issue for it: #66029 All of the tests reported have no relation with these changes. None use Unrelated test error: Seems it failed to install the deb package: Unrelated to the PR. There's already an issue for it: #65946 Unrelated test |
|
I'm sorry, my request to enumerate all the crashed tests was formulated a bit harsh. Next time just write a comment, that you scanned all the crashed jobs and all of them seems unrelated to your PR or are already flaky It would be great if you create issues about some unreported crashes from your CI run. Usually these crashes are already reported, but sometimes some new bugs can be found |
Ok, no worries. Understood.
I had already created an issue that it was clearly a flaky test. I've reviewed again the rest and created issues for those missing. I edited my comment with the new issues created. Let me know if there's anything else missing in the PR that I need to address. |
Could you take a look at comment about the right part of the expression const UInt256 bit_limit = word_size * n? |
@divanik I don't see any comment anywhere 😢 . Are you sure you submitted the review/comment? If so, please share a link to the comment, because there's nothing I can see as of now. |
* [GLUTEN-1632][CH]Daily Update Clickhouse Version (20240706) * Fix build due to ClickHouse/ClickHouse#63636 * Revert "[GLUTEN-1632][CH]Daily Update Clickhouse Version (20240705) (#6338)" This reverts commit 4a674e5. * exclude"shift left", "shift right","shift right unsigned" due to ClickHouse/ClickHouse#65838 --------- Co-authored-by: kyligence-git <gluten@kyligence.io> Co-authored-by: Chang Chen <baibaichen@gmail.com>
It's "wrong" CH always try to use least type possible, so in case of literals, you will get different behavior based on typed value itself. https://fiddle.clickhouse.com/9c0486da-172c-4b1b-b145-248eb5a3c51e |
As a workaround in ClickHouse you can always cast to whatever you want to bypass this exception: SELECT bitShiftLeft(256, 10);
SELECT bitShiftLeft(1::Int64, 10)https://fiddle.clickhouse.com/856ae8e4-746d-4966-a2c1-6922512d7d09 |
So, basically, it does mean that you "always" need to do additional cast within bitShift operator, because there are functions exist in CH, which return smaller types than arguments. (modulo as example). If "accurate" behavior is needed, it make more sense to introduce additional set of functions, like |
Fixes #65516
Fix bitShift by throwing an error for out of bounds shift positions.
Negative values or those greater than the bit width of the value are considered out of bounds.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
bitShiftLeftandbitShitfRightreturn an error for out of bounds shift positions (issuebitShiftLeftmay produce unexpected result. #65516)