apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.32k stars 3.21k forks source link

[Bug] use insert SQL can insert data where partition field is null #12263

Closed lit2430 closed 2 years ago

lit2430 commented 2 years ago

Search before asking

Version

doris 0.15.3 and doris 1.1

What's Wrong?

Using the unique model, when I use the insert SQL to write data where partition field is null, the data can be written normally. But under normal circumstances, if the partition field is null, the data did not write successfully。

What You Expected?

Is this normal or a bug?

How to Reproduce?

create table SQL :
CREATE TABLE `insert_table_test` (
  `column1` varchar(50) NOT NULL COMMENT "",
  `column2` decimal(19, 0) NOT NULL COMMENT "",
  `column3` decimal(19, 0) NOT NULL COMMENT "",
  `column4` decimal(10, 0) NULL COMMENT "",
  `column5` decimal(19, 0) NOT NULL COMMENT "",
  `column6` datetime NULL COMMENT "",
  `column7` decimal(19, 0) NOT NULL COMMENT "",
  `column8` varchar(150) NULL COMMENT "",
  `column9` varchar(150) NULL COMMENT "",
  `column10` float NOT NULL COMMENT "",
  `column11` decimal(19, 0) NOT NULL COMMENT ""
) ENGINE=OLAP
UNIQUE KEY(`column1`, `column2`, `column3`, `column4`, `column5`, `column6`)
COMMENT "测试表"
PARTITION BY RANGE(`column6`)
(PARTITION P_000000 VALUES [('0000-01-01 00:00:00'), ('2022-08-01 00:00:00')),
PARTITION P_202208 VALUES [('2022-08-01 00:00:00'), ('2022-09-01 00:00:00')),
PARTITION P_202209 VALUES [('2022-09-01 00:00:00'), ('2022-10-01 00:00:00')),
PARTITION P_202210 VALUES [('2022-10-01 00:00:00'), ('2022-11-01 00:00:00')),
PARTITION P_202211 VALUES [('2022-11-01 00:00:00'), ('2022-12-01 00:00:00')))
DISTRIBUTED BY HASH(`column1`, `column2`, `column3`, `column4`) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 3",
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "MONTH",
"dynamic_partition.time_zone" = "Asia/Shanghai",
"dynamic_partition.start" = "-2147483648",
"dynamic_partition.end" = "2",
"dynamic_partition.prefix" = "P_",
"dynamic_partition.replication_allocation" = "tag.location.default: 3",
"dynamic_partition.buckets" = "1",
"dynamic_partition.create_history_partition" = "false",
"dynamic_partition.history_partition_num" = "-1",
"dynamic_partition.hot_partition_num" = "0",
"dynamic_partition.reserved_history_periods" = "NULL",
"dynamic_partition.start_day_of_month" = "1",
"in_memory" = "false",
"storage_format" = "V2"
)
insert SQL :
INSERT INTO `insert_table_test`(`column1`, `column2`, `column3`, `column4`, `column5`, `column6`, `column7`, `column8`, `column9`, `column10`, `column11`) VALUES ('01', 7420300, 4293715, 1, 3342582, NULL, 4, 'S202102280036', NULL, 120, 3653756);
select SQL:
SELECT  * FROM insert_table_test

Anything Else?

NONE

Are you willing to submit PR?

Code of Conduct

JNSimba commented 2 years ago

This is not a bug, nor is it a problem with partition clipping. Because the partition value in the data is null, when we write the where condition dt < '2018-01-01', the null value cannot be compared with '2018-01-01'. The data is filtered out. If you want to check, you need to write:

select * from test_part where dt <'2018-01-01' or dt is null;