Fix logical functions with UInt8 numbers, when they not equal to 1.#7795
Fix logical functions with UInt8 numbers, when they not equal to 1.#7795CurtizJ wants to merge 1 commit intoClickHouse:masterfrom
Conversation
|
@Akazz Ok, but need to check if there is any difference in performance. |
|
I suspect that usual WHERE clause with comparison and logical expressions may slow down. |
Akazz
left a comment
There was a problem hiding this comment.
I suspect that usual WHERE clause with comparison and logical expressions may slow down.
I also admit that some minor performance decline is to be expected here, although all of the column conversion is easily vectorized by compiler.
| @@ -0,0 +1 @@ | |||
| select toUInt8(number) as n from numbers(100) where bitAnd(n, 1) and bitAnd(n, 2) and bitAnd(n, 4); | |||
There was a problem hiding this comment.
Okay, so right now we have a problem with UInt8 representation of bolean values. I suggest that we add a few more tests and a comment may be, because this line is far from being self explanatory. It is not clear from the line why we need 3 arguments for and in where expression and exactly why this is being checked. Probably it'd be nice to have the same checks for constants as well.
There was a problem hiding this comment.
select materialize(1) and materialize(2) and materialize(4)
expected to be true
|
@Akazz have you checked the performance manually? |
|
I've ran not very presice benchmark on 19.17 vs version with this patch and it showed about 10% performance degradation. Query with 100 This patch result: v.19.17 result: |
|
@CurtizJ Let's add this query to performance tests in separate PR? |
What was the cause of this error? Maybe we are using bit ANDs instead of logical ANDs to avoid less efficient short-curcuit code in multiple AND chains? |
Yes, we use them, but for another reason. I've tried to expalin it in comment. |
|
This performance regression is almost acceptable but not quite. |
|
Still relevant. |
|
@blinkov This PR is significant. |
|
I have reworked it somewhat and I am to push new changes within this week. |
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Changelog category (leave one):
Changelog entry (up to few sentences, required except for Non-significant/Documentation categories):
Fix logical functions with UInt8 numbers, when they not equal to 1.
Fixes #7772.