-- https://github.com/apache/incubator-doris/issues/4833
drop database if exists issue_4833

create database issue_4833
use issue_4833

CREATE TABLE `test_t` (`dt` bigint(20) NULL, `id` bigint(20) NULL, `name` varchar(100) NULL) ENGINE=OLAP DUPLICATE KEY(`dt`, `id`, `name`) PARTITION BY RANGE(`dt`) (PARTITION p20201001 VALUES [("19700101"), ("20201001")), PARTITION p20201002 VALUES [("20201001"), ("20201002")), PARTITION p20201003 VALUES [("20201002"), ("20201003")), PARTITION p20201004 VALUES [("20201003"), ("20201004")), PARTITION p20201005 VALUES [("20201004"), ("20201005")), PARTITION p20201006 VALUES [("20201005"), ("20201006")), PARTITION p20201007 VALUES [("20201006"), ("20201007")), PARTITION p20201008 VALUES [("20201007"), ("20201008")), PARTITION p20201009 VALUES [("20201008"), ("20201009")), PARTITION p20201010 VALUES [("20201009"), ("20201010")), PARTITION p20201011 VALUES [("20201010"), ("20201011")), PARTITION p20201012 VALUES [("20201011"), ("20201012")), PARTITION p20201013 VALUES [("20201012"), ("20201013")), PARTITION p20201014 VALUES [("20201013"), ("20201014")), PARTITION p20201015 VALUES [("20201014"), ("20201015")), PARTITION p20201016 VALUES [("20201015"), ("20201016")), PARTITION p20201017 VALUES [("20201016"), ("20201017")), PARTITION p20201018 VALUES [("20201017"), ("20201018")), PARTITION p20201019 VALUES [("20201018"), ("20201019")), PARTITION p20201020 VALUES [("20201019"), ("20201020")), PARTITION p20201021 VALUES [("20201020"), ("20201021")), PARTITION p20201022 VALUES [("20201021"), ("20201022")), PARTITION p20201023 VALUES [("20201022"), ("20201023")), PARTITION p20201024 VALUES [("20201023"), ("20201024")), PARTITION p20201025 VALUES [("20201024"), ("20201025")), PARTITION p20201026 VALUES [("20201025"), ("20201026")), PARTITION p20201027 VALUES [("20201026"), ("20201027")), PARTITION p20201028 VALUES [("20201027"), ("20201028")), PARTITION p20201029 VALUES [("20201028"), ("20201029")), PARTITION p20201030 VALUES [("20201029"), ("20201030")), PARTITION p20201031 VALUES [("20201030"), ("20201031"))) DISTRIBUTED BY HASH(`id`) BUCKETS 5 PROPERTIES ( "replication_num" = "1", "in_memory" = "false", "storage_format" = "DEFAULT")
INSERT INTO test_t (`dt`,`id`,`name`) VALUES ('20201013',1,'x'), ('20201004',2,'xx'), ('20201029',3,'c'), ('20201029',3,'c'), ('20201029',3,'c'), ('20201009',1,'x')
SELECT * FROM `issue_4833`.`test_t` WHERE `dt` >= 20200801 AND `dt` < 20201101 AND `id` = 1 AND `name` = 'x' AND substr(`dt`, 7, 8) IN ('09')
SELECT * FROM `issue_4833`.`test_t` WHERE `dt` >= 20200801 AND `dt` < 20201101 AND `id` = 1 AND `name` = 'x'

drop database issue_4833
