-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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 wrong query result when column value is Null #344
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good patch first.
CREATE TABLE `test_wrong_result` (
`a` int(11),
`b` tinyint(4),
`c` tinyint(4),
`d` bigint(20)
) ENGINE=OLAP
DUPLICATE KEY(`a`, `b`, `c`, `d`)
DISTRIBUTED BY HASH(`d`) BUCKETS 10;
SELECT c FROM test_wrong_result WHERE a = 3001 and b = 3 and d = 1090050;
There is something you miss. For your example query, there is no range filter for column c
, your patch can work in right way. If there is filter for column c
like c > 1
or c <=1
, your patch works in a wrong way. Because when column c
has any range filter, rows whose c
column's value is null
would not to be selected.
So, before you assign has_converted
to true, you have to check more conditions.
be/src/exec/olap_common.h
Outdated
@@ -662,6 +662,8 @@ Status OlapScanKeys::extend_scan_key(ColumnValueRange<T>& range) { | |||
return Status::OK; | |||
} | |||
|
|||
bool _has_converted = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only member variable's name starts with '_', so change it to has_converted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
@imay I think if there is filter for column c like c > 1 or c <=1, which will mean c could not be null. |
@kangkaisen I think you are right. When c has predicate, it should not scan NULL data in SQL semantics. |
When I try running the olap_common_test, there are a lot of compiling errors. I found recently some commits didn't update olap_common_test at the same time. So I think we should start a new issue to fix olap_common_test compiling error, and then I will add test cases to olap_common_test. |
This is the olap_common_test issue: 346 |
@kangkaisen Yes, c could not be null, however your change will add null to scan_keys |
@imay Hi, I think this patch won't add null to C column scan_keys. If c = 1 or c > 1, the code won't goto this branch
|
If |
@imay I see. I am sorry. I will update the commit. |
Update the commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Fix 343
The root cause for 343 is ScanKey is wrong.
So we should add null to ScanKey when ColumnValueRange convert_to_fixed_value.
I will add a test case to olap_common_test tomorrow