-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](planner) fix no data issue when use datetimev1/datatimev2 & datev2 as function coalesce's parameter in legacy planner #36583
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](planner) fix no data issue when use datetimev1/datatimev2 & datev2 as function coalesce's parameter in legacy planner #36583
Conversation
…ameter in legacy planner
|
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
|
run buildall |
TPC-H: Total hot run time: 50046 ms |
TPC-DS: Total hot run time: 202968 ms |
ClickBench: Total hot run time: 30.65 s |
|
Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G' |
|
run p0 |
|
run buildall |
TPC-H: Total hot run time: 49726 ms |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
TPC-DS: Total hot run time: 202630 ms |
ClickBench: Total hot run time: 30.93 s |
|
Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G' |
lide-reed
left a comment
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
…sce & ifnull (#36724) cherry-pick from branch-2.0 #36688, #36640, #36583 How to Reproduce: Issue1: use datetimev1 and datev2 as parameters in function coalesce admin set frontend config ("enable_date_conversion"="false"); admin set frontend config ("disable_datev1"="false"); drop table test_cls; CREATE TABLE `test_cls` ( `id` int(11) NOT NULL COMMENT '', `name` varchar(32) NOT NULL COMMENT '', `dt` datetime NOT NULL ) ENGINE=OLAP UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 2 PROPERTIES( "replication_allocation" = "tag.location.default: 1" ); SET enable_nereids_planner=false; select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01'; return no data, which is wrong. when see the excution plan SET enable_nereids_planner=false; explain select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01'; you can see error predicate: CAST(coalesce(CAST(`dt` AS BIGINT), 20230601) AS DOUBLE) >= NULL after fix: CAST(coalesce(`dt`, '2023-06-01') AS DATETIMEV2(0)) >= '2023-06-01 00:00:00' Issue2: use datetimev2 and datev2 as parameters in function coalesce admin set frontend config ("enable_date_conversion"="true"); admin set frontend config ("disable_datev1"="true"); drop table test_cls; CREATE TABLE `test_cls` ( `id` int(11) NOT NULL COMMENT '', `name` varchar(32) NOT NULL COMMENT '', `dt` datetime NOT NULL ) ENGINE=OLAP UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 2 PROPERTIES( "replication_allocation" = "tag.location.default: 1" ); SET enable_nereids_planner=false; select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01'; return no data, which is wrong when see the excution plan SET enable_nereids_planner=false; explain select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01'; you can see error predicate: CAST(coalesce(CAST(`dt` AS BIGINT), 20230601) AS DOUBLE) >= NULL after fix: coalesce(`dt`, '2023-06-01') >= '2023-06-01 00:00:00' Issue3: extend it to multiple parameters. Steps to reproduce: admin set frontend config ("enable_date_conversion"="false"); admin set frontend config ("disable_datev1"="false"); drop table test_cls; CREATE TABLE `test_cls` ( `id` int(11) NOT NULL COMMENT '', `name` varchar(32) NOT NULL COMMENT '', `dt` datetime NOT NULL ) ENGINE=OLAP UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 2 PROPERTIES( "replication_allocation" = "tag.location.default: 1" ); SET enable_nereids_planner=false; error sql: select dt from test_cls where coalesce (dt, dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01'; explain it and find wrong predicate: CAST(coalesce(CAST(`dt` AS BIGINT), CAST(`dt` AS BIGINT), 20230601) AS DOUBLE) >= NULL after fix: explain it coalesce(CAST(`dt` AS DATETIMEV2(0)), CAST(`dt` AS DATETIMEV2(0)), '2023-06-01 00:00:00') >= '2023-06-01 00:00:00' Issue3: nereids has the same issue with legacy planner
…sce & ifnull (#36724) cherry-pick from branch-2.0 #36688, #36640, #36583 How to Reproduce: Issue1: use datetimev1 and datev2 as parameters in function coalesce admin set frontend config ("enable_date_conversion"="false"); admin set frontend config ("disable_datev1"="false"); drop table test_cls; CREATE TABLE `test_cls` ( `id` int(11) NOT NULL COMMENT '', `name` varchar(32) NOT NULL COMMENT '', `dt` datetime NOT NULL ) ENGINE=OLAP UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 2 PROPERTIES( "replication_allocation" = "tag.location.default: 1" ); SET enable_nereids_planner=false; select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01'; return no data, which is wrong. when see the excution plan SET enable_nereids_planner=false; explain select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01'; you can see error predicate: CAST(coalesce(CAST(`dt` AS BIGINT), 20230601) AS DOUBLE) >= NULL after fix: CAST(coalesce(`dt`, '2023-06-01') AS DATETIMEV2(0)) >= '2023-06-01 00:00:00' Issue2: use datetimev2 and datev2 as parameters in function coalesce admin set frontend config ("enable_date_conversion"="true"); admin set frontend config ("disable_datev1"="true"); drop table test_cls; CREATE TABLE `test_cls` ( `id` int(11) NOT NULL COMMENT '', `name` varchar(32) NOT NULL COMMENT '', `dt` datetime NOT NULL ) ENGINE=OLAP UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 2 PROPERTIES( "replication_allocation" = "tag.location.default: 1" ); SET enable_nereids_planner=false; select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01'; return no data, which is wrong when see the excution plan SET enable_nereids_planner=false; explain select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01'; you can see error predicate: CAST(coalesce(CAST(`dt` AS BIGINT), 20230601) AS DOUBLE) >= NULL after fix: coalesce(`dt`, '2023-06-01') >= '2023-06-01 00:00:00' Issue3: extend it to multiple parameters. Steps to reproduce: admin set frontend config ("enable_date_conversion"="false"); admin set frontend config ("disable_datev1"="false"); drop table test_cls; CREATE TABLE `test_cls` ( `id` int(11) NOT NULL COMMENT '', `name` varchar(32) NOT NULL COMMENT '', `dt` datetime NOT NULL ) ENGINE=OLAP UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 2 PROPERTIES( "replication_allocation" = "tag.location.default: 1" ); SET enable_nereids_planner=false; error sql: select dt from test_cls where coalesce (dt, dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01'; explain it and find wrong predicate: CAST(coalesce(CAST(`dt` AS BIGINT), CAST(`dt` AS BIGINT), 20230601) AS DOUBLE) >= NULL after fix: explain it coalesce(CAST(`dt` AS DATETIMEV2(0)), CAST(`dt` AS DATETIMEV2(0)), '2023-06-01 00:00:00') >= '2023-06-01 00:00:00' Issue3: nereids has the same issue with legacy planner
…ev2 as function coalesce's parameter in legacy planner (apache#36583)
How to Reproduce:
Issue1: use datetimev1 and datev2 as parameters in function coalesce
sql
SET enable_nereids_planner=false; select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01';return no data, which is wrongwhen see the excution plan
SET enable_nereids_planner=false; explain select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01';you can see error predicate:
CAST(coalesce(CAST(
dtAS BIGINT), 20230601) AS DOUBLE) >= NULLafter fix:
CAST(coalesce(
dt, '2023-06-01') AS DATETIMEV2(0)) >= '2023-06-01 00:00:00'Issue2: use datetimev2 and datev2 as parameters in function coalesce
sql
SET enable_nereids_planner=false; select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01';return no data, which is wrongwhen see the excution plan
SET enable_nereids_planner=false; explain select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01';you can see error predicate:
CAST(coalesce(CAST(
dtAS BIGINT), 20230601) AS DOUBLE) >= NULLafter fix:
coalesce(
dt, '2023-06-01') >= '2023-06-01 00:00:00'