forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix](scan) Incorrect scan keys lead to wrong query results. (apache#…
…40814) ``` mysql [doris_14555]>select * from table_9436528_3; +------+------+------+------+------------------------+--------------------+------+ | col1 | col2 | col3 | col5 | col4 | col6 | col7 | +------+------+------+------+------------------------+--------------------+------+ | -100 | 1 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.904282 | NULL | | -100 | 1 | 92 | 1 | 2024-02-16 04:37:37.00 | 23423423.0324234 | NULL | | -100 | 0 | -82 | 0 | 2023-11-11 10:49:43.00 | 840968969.872149 | NULL | ``` wrong result: ``` mysql [doris_14555]>select * from table_9436528_3 where col1 <= -100 and col2 in (true, false) and col3 = -82; +------+------+------+------+------------------------+--------------------+------+ | col1 | col2 | col3 | col5 | col4 | col6 | col7 | +------+------+------+------+------------------------+--------------------+------+ | -100 | 1 | -82 | 1 | 2024-02-16 04:37:37.00 | -1299962421.904282 | NULL | | -100 | 1 | 92 | 1 | 2024-02-16 04:37:37.00 | 23423423.0324234 | NULL | +------+------+------+------+------------------------+--------------------+------+ ```
- Loading branch information
Showing
5 changed files
with
181 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
regression-test/data/correctness/test_scan_keys_with_bool_type.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select1 -- | ||
-100 false -82 false 2023-11-11T10:49:43 8.40968969872149E8 \N | ||
-100 true -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
-100 true 92 true 2024-02-16T04:37:37 2.34234230324234E7 \N | ||
|
||
-- !select2 -- | ||
-100 false -82 false 2023-11-11T10:49:43 8.40968969872149E8 \N | ||
-100 true -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
|
||
-- !select3 -- | ||
-100 false -82 false 2023-11-11T10:49:43 8.40968969872149E8 \N | ||
-100 true -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
|
||
-- !select3 -- | ||
-100 0 -82 false 2023-11-11T10:49:43 8.40968969872149E8 \N | ||
-100 1 -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
-100 1 92 true 2024-02-16T04:37:37 2.34234230324234E7 \N | ||
-100 2 -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
|
||
-- !select4 -- | ||
-100 1 -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
-100 2 -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
|
||
-- !select5 -- | ||
-100 0 -82 false 2023-11-11T10:49:43 8.40968969872149E8 \N | ||
-100 1 -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
-100 2 -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
|
||
-- !select6 -- | ||
-100 a -82 false 2023-11-11T10:49:43 8.40968969872149E8 \N | ||
-100 b -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
-100 b 92 true 2024-02-16T04:37:37 2.34234230324234E7 \N | ||
-100 c 92 true 2024-02-16T04:37:37 2.34234230324234E7 \N | ||
|
||
-- !select7 -- | ||
-100 a -82 false 2023-11-11T10:49:43 8.40968969872149E8 \N | ||
-100 b -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
|
||
-- !select8 -- | ||
-100 a -82 false 2023-11-11T10:49:43 8.40968969872149E8 \N | ||
-100 b -82 true 2024-02-16T04:37:37 -1.299962421904282E9 \N | ||
|
110 changes: 110 additions & 0 deletions
110
regression-test/suites/correctness/test_scan_keys_with_bool_type.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
suite("test_scan_keys_with_bool_type") { | ||
sql """ DROP TABLE IF EXISTS test_scan_keys_with_bool_type """ | ||
|
||
sql """ | ||
CREATE TABLE `test_scan_keys_with_bool_type` ( | ||
`col1` tinyint NOT NULL, | ||
`col2` boolean 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` datetime(3) 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" | ||
); | ||
""" | ||
|
||
sql """ insert into test_scan_keys_with_bool_type values | ||
( -100 , 0 , -82 , 0 , '2023-11-11 10:49:43.00' , 840968969.872149 , NULL ), | ||
( -100 , 1 , -82 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , NULL ), | ||
( -100 , 1 , 92 , 1 , '2024-02-16 04:37:37.00' , 23423423.0324234 , NULL ); | ||
""" | ||
|
||
qt_select1 " select * from test_scan_keys_with_bool_type order by 1, 2, 3, 4, 5, 6, 7; " | ||
qt_select2 " select * from test_scan_keys_with_bool_type where col1 <= -100 and col2 in (true, false) and col3 = -82 order by 1, 2, 3, 4, 5, 6, 7; " | ||
qt_select3 " select * from test_scan_keys_with_bool_type where col1 <= -100 and col3 = -82 order by 1, 2, 3, 4, 5, 6, 7; " | ||
sql """ DROP TABLE IF EXISTS test_scan_keys_with_bool_type2 """ | ||
|
||
sql """ | ||
CREATE TABLE `test_scan_keys_with_bool_type2` ( | ||
`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` datetime(3) 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" | ||
); | ||
""" | ||
|
||
sql """ insert into test_scan_keys_with_bool_type2 values | ||
( -100 , 0 , -82 , 0 , '2023-11-11 10:49:43.00' , 840968969.872149 , NULL ), | ||
( -100 , 1 , -82 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , NULL ), | ||
( -100 , 2 , -82 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , NULL ), | ||
( -100 , 1 , 92 , 1 , '2024-02-16 04:37:37.00' , 23423423.0324234 , NULL ); | ||
""" | ||
|
||
qt_select3 " select * from test_scan_keys_with_bool_type2 order by 1, 2, 3, 4, 5, 6, 7; " | ||
qt_select4 " select * from test_scan_keys_with_bool_type2 where col1 <= -100 and col2 in (1, 2) and col3 = -82 order by 1, 2, 3, 4, 5, 6, 7; " | ||
qt_select5 " select * from test_scan_keys_with_bool_type2 where col1 <= -100 and col3 = -82 order by 1, 2, 3, 4, 5, 6, 7; " | ||
|
||
|
||
sql """ DROP TABLE IF EXISTS test_scan_keys_with_bool_type3 """ | ||
|
||
sql """ | ||
CREATE TABLE `test_scan_keys_with_bool_type3` ( | ||
`col1` tinyint NOT NULL, | ||
`col2` char 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` datetime(3) 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" | ||
); | ||
""" | ||
|
||
sql """ insert into test_scan_keys_with_bool_type3 values | ||
( -100 , 'a' , -82 , 0 , '2023-11-11 10:49:43.00' , 840968969.872149 , NULL ), | ||
( -100 , 'b', -82 , 1 , '2024-02-16 04:37:37.00' , -1299962421.904282 , NULL ), | ||
( -100 , 'b' , 92 , 1 , '2024-02-16 04:37:37.00' , 23423423.0324234 , NULL ), | ||
( -100 , 'c' , 92 , 1 , '2024-02-16 04:37:37.00' , 23423423.0324234 , NULL ); | ||
""" | ||
|
||
qt_select6 " select * from test_scan_keys_with_bool_type3 order by 1, 2, 3, 4, 5, 6, 7; " | ||
qt_select7 " select * from test_scan_keys_with_bool_type3 where col1 <= -100 and col2 in ('a', 'b') and col3 = -82 order by 1, 2, 3, 4, 5, 6, 7; " | ||
qt_select8 " select * from test_scan_keys_with_bool_type3 where col1 <= -100 and col3 = -82 order by 1, 2, 3, 4, 5, 6, 7; " | ||
} |