-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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](agg) Aggregating string types with null values may result in incorrect result #42067
Conversation
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
run buildall |
clang-tidy review says "All clean, LGTM! 👍" |
TPC-H: Total hot run time: 48910 ms
|
TeamCity be ut coverage result: |
TPC-DS: Total hot run time: 211904 ms
|
ClickBench: Total hot run time: 31.79 s
|
Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
|
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
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
…correct result (#42067) Aggregating string types with null values may result in incorrect result because using the replace_column_data function can cause incorrect offsets in the column. A reproducible case: ``` CREATE TABLE `test_scan_keys_with_bool_type` ( `col1` tinyint NOT NULL, `col2` int NOT NULL, `col3` tinyint NOT NULL, `col5` boolean REPLACE NOT NULL, `col4` datetime(2) REPLACE NOT NULL, `col6` double REPLACE_IF_NOT_NULL NULL, `col7` varchar(100) REPLACE_IF_NOT_NULL NULL ) ENGINE=OLAP AGGREGATE KEY(`col1`, `col2`, `col3`) DISTRIBUTED BY HASH(`col1`, `col2`, `col3`) BUCKETS 1 PROPERTIES ( "replication_allocation" = "tag.location.default: 1", "disable_auto_compaction" = "true" ); insert into test_scan_keys_with_bool_type values ( -100 , 1 , -82 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , NULL ), ( -100 , 0 , -82 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , "hi" ), ( -100 , 1 , 92 , 1 , '2024-02-16 04:37:37.00' , 23423423.0324234 , NULL ); insert into test_scan_keys_with_bool_type values ( -100 , 1 , 1 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , "doris" ); MySQL [test]> select * from test_scan_keys_with_bool_type; +------+------+------+------+------------------------+---------------------+-------+ | col1 | col2 | col3 | col5 | col4 | col6 | col7 | +------+------+------+------+------------------------+---------------------+-------+ | -100 | 0 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | hi | | -100 | 1 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | NULL | | -100 | 1 | 1 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | hidor | | -100 | 1 | 92 | 1 | 2024-02-16 04:37:37.00 | 23423423.0324234 | NULL | +------+------+------+------+------------------------+---------------------+-------+ 4 rows in set (0.057 sec) MySQL [test]> set skip_storage_engine_merge = true; select * from test_scan_keys_with_bool_type; +------+------+------+------+------------------------+---------------------+-------+ | col1 | col2 | col3 | col5 | col4 | col6 | col7 | +------+------+------+------+------------------------+---------------------+-------+ | -100 | 0 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | hi | | -100 | 1 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | NULL | | -100 | 1 | 92 | 1 | 2024-02-16 04:37:37.00 | 23423423.0324234 | NULL | | -100 | 1 | 1 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | doris | +------+------+------+------+------------------------+---------------------+-------+ 4 rows in set (0.023 sec) ``` #33493 By supporting variant type aggregation, this issue has been resolved.So versions after 2.1 do not have this issue.
…correct result (#42067) Aggregating string types with null values may result in incorrect result because using the replace_column_data function can cause incorrect offsets in the column. A reproducible case: ``` CREATE TABLE `test_scan_keys_with_bool_type` ( `col1` tinyint NOT NULL, `col2` int NOT NULL, `col3` tinyint NOT NULL, `col5` boolean REPLACE NOT NULL, `col4` datetime(2) REPLACE NOT NULL, `col6` double REPLACE_IF_NOT_NULL NULL, `col7` varchar(100) REPLACE_IF_NOT_NULL NULL ) ENGINE=OLAP AGGREGATE KEY(`col1`, `col2`, `col3`) DISTRIBUTED BY HASH(`col1`, `col2`, `col3`) BUCKETS 1 PROPERTIES ( "replication_allocation" = "tag.location.default: 1", "disable_auto_compaction" = "true" ); insert into test_scan_keys_with_bool_type values ( -100 , 1 , -82 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , NULL ), ( -100 , 0 , -82 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , "hi" ), ( -100 , 1 , 92 , 1 , '2024-02-16 04:37:37.00' , 23423423.0324234 , NULL ); insert into test_scan_keys_with_bool_type values ( -100 , 1 , 1 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , "doris" ); MySQL [test]> select * from test_scan_keys_with_bool_type; +------+------+------+------+------------------------+---------------------+-------+ | col1 | col2 | col3 | col5 | col4 | col6 | col7 | +------+------+------+------+------------------------+---------------------+-------+ | -100 | 0 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | hi | | -100 | 1 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | NULL | | -100 | 1 | 1 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | hidor | | -100 | 1 | 92 | 1 | 2024-02-16 04:37:37.00 | 23423423.0324234 | NULL | +------+------+------+------+------------------------+---------------------+-------+ 4 rows in set (0.057 sec) MySQL [test]> set skip_storage_engine_merge = true; select * from test_scan_keys_with_bool_type; +------+------+------+------+------------------------+---------------------+-------+ | col1 | col2 | col3 | col5 | col4 | col6 | col7 | +------+------+------+------+------------------------+---------------------+-------+ | -100 | 0 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | hi | | -100 | 1 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | NULL | | -100 | 1 | 92 | 1 | 2024-02-16 04:37:37.00 | 23423423.0324234 | NULL | | -100 | 1 | 1 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | doris | +------+------+------+------+------------------------+---------------------+-------+ 4 rows in set (0.023 sec) ``` #33493 By supporting variant type aggregation, this issue has been resolved.So versions after 2.1 do not have this issue.
…correct result (#42067) Aggregating string types with null values may result in incorrect result because using the replace_column_data function can cause incorrect offsets in the column. A reproducible case: ``` CREATE TABLE `test_scan_keys_with_bool_type` ( `col1` tinyint NOT NULL, `col2` int NOT NULL, `col3` tinyint NOT NULL, `col5` boolean REPLACE NOT NULL, `col4` datetime(2) REPLACE NOT NULL, `col6` double REPLACE_IF_NOT_NULL NULL, `col7` varchar(100) REPLACE_IF_NOT_NULL NULL ) ENGINE=OLAP AGGREGATE KEY(`col1`, `col2`, `col3`) DISTRIBUTED BY HASH(`col1`, `col2`, `col3`) BUCKETS 1 PROPERTIES ( "replication_allocation" = "tag.location.default: 1", "disable_auto_compaction" = "true" ); insert into test_scan_keys_with_bool_type values ( -100 , 1 , -82 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , NULL ), ( -100 , 0 , -82 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , "hi" ), ( -100 , 1 , 92 , 1 , '2024-02-16 04:37:37.00' , 23423423.0324234 , NULL ); insert into test_scan_keys_with_bool_type values ( -100 , 1 , 1 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , "doris" ); MySQL [test]> select * from test_scan_keys_with_bool_type; +------+------+------+------+------------------------+---------------------+-------+ | col1 | col2 | col3 | col5 | col4 | col6 | col7 | +------+------+------+------+------------------------+---------------------+-------+ | -100 | 0 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | hi | | -100 | 1 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | NULL | | -100 | 1 | 1 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | hidor | | -100 | 1 | 92 | 1 | 2024-02-16 04:37:37.00 | 23423423.0324234 | NULL | +------+------+------+------+------------------------+---------------------+-------+ 4 rows in set (0.057 sec) MySQL [test]> set skip_storage_engine_merge = true; select * from test_scan_keys_with_bool_type; +------+------+------+------+------------------------+---------------------+-------+ | col1 | col2 | col3 | col5 | col4 | col6 | col7 | +------+------+------+------+------------------------+---------------------+-------+ | -100 | 0 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | hi | | -100 | 1 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | NULL | | -100 | 1 | 92 | 1 | 2024-02-16 04:37:37.00 | 23423423.0324234 | NULL | | -100 | 1 | 1 | 1 | 2024-02-16 04:37:37.00 | -1299962421.9042821 | doris | +------+------+------+------+------------------------+---------------------+-------+ 4 rows in set (0.023 sec) ``` #33493 By supporting variant type aggregation, this issue has been resolved.So versions after 2.1 do not have this issue.
Aggregating string types with null values may result in incorrect result because using the replace_column_data function can cause incorrect offsets in the column.
A reproducible case:
#33493 By supporting variant type aggregation, this issue has been resolved.So versions after 2.1 do not have this issue.