diff --git a/docs/advanced/partition/auto-partition.md b/docs/advanced/partition/auto-partition.md index cd4ff7878de1b..e9b5e3d1e446a 100644 --- a/docs/advanced/partition/auto-partition.md +++ b/docs/advanced/partition/auto-partition.md @@ -183,7 +183,9 @@ mysql> select * from auto_null_list partition(pX); 1 row in set (0.20 sec) ``` -2. In Doris, NULL values are included in the minimum value partition, whether they are AUTO PARTITION tables or not. Therefore, if a partition is automatically created for a NULL value, you get a partition starting with the minimum value: +2. For AUTO RANGE PARTITION, the storage of NULL values requires the manual creation of specific partitions. + +In Doris' RANGE PARTITION, we do not use a separate NULL PARTITION to contain NULL values, but rather group them in the **minium LESS THAN partition**. For logical clarity, the AUTO RANGE PARTITION does not automatically create such a partition when it encounters a NULL value. If necessary, you can create such a partition yourself to contain NULL values. ```sql mysql> CREATE TABLE `range_table_nullable` ( @@ -202,15 +204,21 @@ mysql> CREATE TABLE `range_table_nullable` ( Query OK, 0 rows affected (0.09 sec) mysql> insert into range_table_nullable values (0, null, null); -Query OK, 1 row affected (0.21 sec) - -mysql> show partitions from range_table_nullable; -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -| 457060 | p00000101000000 | 2 | 2024-03-25 03:01:38 | NORMAL | k2 | [types: [DATETIMEV2]; keys: [0000-01-01 00:00:00]; ..types: [DATETIMEV2]; keys: [0000-01-02 00:00:00]; ) | k1 | 16 | 1 | HDD | 9999-12-31 23:59:59 | | NULL | 0.000 | false | tag.location.default: 1 | true | true | NULL | -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -1 row in set (0.09 sec) +ERROR 1105 (HY000): errCode = 2, detailMessage = [CANCELLED]TStatus: errCode = 2, detailMessage = Can't create partition for NULL Range + +mysql> alter table range_table_nullable add partition pX VALUES LESS THAN ("1970-01-01"); +Query OK, 0 rows affected (0.11 sec) + +mysql> insert into range_table_nullable values (0, null, null); +Query OK, 1 row affected (0.18 sec) + +mysql> select * from range_table_nullable; ++------+------+------+ +| k1 | k2 | k3 | ++------+------+------+ +| 0 | NULL | NULL | ++------+------+------+ +1 row in set (0.18 sec) ``` ## Sample Scenarios diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/advanced/partition/auto-partition.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/advanced/partition/auto-partition.md index 73fb843f07051..15e9f2a57f5ab 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/advanced/partition/auto-partition.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/advanced/partition/auto-partition.md @@ -183,7 +183,9 @@ mysql> select * from auto_null_list partition(pX); 1 row in set (0.20 sec) ``` -2. Doris 中,无论是否为 AUTO PARTITION 表,NULL 值都被包含在最小值分区内。因此,如果对 NULL 值自动创建分区,会得到一个最小值起始的分区: +2. 对于 AUTO RANGE PARTITION,NULL 值的存储需要手动创建特定的分区。 + +在 Doris 的 RANGE PARTITION 中,我们并不使用单独的 NULL PARTITION 来包含 NULL 值,而是将其归属于**最小的 LESS THAN 分区内**。为保持逻辑清晰,AUTO RANGE PARTITION 在遇到 NULL 值时不会自动创建这样的分区。如有需要,可以自行创建这样的分区,以包含 NULL 值。 ```sql mysql> CREATE TABLE `range_table_nullable` ( @@ -202,15 +204,21 @@ mysql> CREATE TABLE `range_table_nullable` ( Query OK, 0 rows affected (0.09 sec) mysql> insert into range_table_nullable values (0, null, null); -Query OK, 1 row affected (0.21 sec) - -mysql> show partitions from range_table_nullable; -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -| 457060 | p00000101000000 | 2 | 2024-03-25 03:01:38 | NORMAL | k2 | [types: [DATETIMEV2]; keys: [0000-01-01 00:00:00]; ..types: [DATETIMEV2]; keys: [0000-01-02 00:00:00]; ) | k1 | 16 | 1 | HDD | 9999-12-31 23:59:59 | | NULL | 0.000 | false | tag.location.default: 1 | true | true | NULL | -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -1 row in set (0.09 sec) +ERROR 1105 (HY000): errCode = 2, detailMessage = [CANCELLED]TStatus: errCode = 2, detailMessage = Can't create partition for NULL Range + +mysql> alter table range_table_nullable add partition pX VALUES LESS THAN ("1970-01-01"); +Query OK, 0 rows affected (0.11 sec) + +mysql> insert into range_table_nullable values (0, null, null); +Query OK, 1 row affected (0.18 sec) + +mysql> select * from range_table_nullable; ++------+------+------+ +| k1 | k2 | k3 | ++------+------+------+ +| 0 | NULL | NULL | ++------+------+------+ +1 row in set (0.18 sec) ``` ## 场景示例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/advanced/partition/auto-partition.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/advanced/partition/auto-partition.md index 875e652f23bd3..dd2832a2b8c1f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/advanced/partition/auto-partition.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/advanced/partition/auto-partition.md @@ -185,7 +185,9 @@ mysql> select * from auto_null_list partition(pX); 1 row in set (0.20 sec) ``` -2. Doris 中,无论是否为 AUTO PARTITION 表,NULL 值都被包含在最小值分区内。因此,如果对 NULL 值自动创建分区,会得到一个最小值起始的分区: +2. 对于 AUTO RANGE PARTITION,NULL 值的存储需要手动创建特定的分区。 + +在 Doris 的 RANGE PARTITION 中,我们并不使用单独的 NULL PARTITION 来包含 NULL 值,而是将其归属于**最小的 LESS THAN 分区内**。为保持逻辑清晰,AUTO RANGE PARTITION 在遇到 NULL 值时不会自动创建这样的分区。如有需要,可以自行创建这样的分区,以包含 NULL 值。 ```sql mysql> CREATE TABLE `range_table_nullable` ( @@ -204,15 +206,21 @@ mysql> CREATE TABLE `range_table_nullable` ( Query OK, 0 rows affected (0.09 sec) mysql> insert into range_table_nullable values (0, null, null); -Query OK, 1 row affected (0.21 sec) - -mysql> show partitions from range_table_nullable; -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -| 457060 | p00000101000000 | 2 | 2024-03-25 03:01:38 | NORMAL | k2 | [types: [DATETIMEV2]; keys: [0000-01-01 00:00:00]; ..types: [DATETIMEV2]; keys: [0000-01-02 00:00:00]; ) | k1 | 16 | 1 | HDD | 9999-12-31 23:59:59 | | NULL | 0.000 | false | tag.location.default: 1 | true | true | NULL | -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -1 row in set (0.09 sec) +ERROR 1105 (HY000): errCode = 2, detailMessage = [CANCELLED]TStatus: errCode = 2, detailMessage = Can't create partition for NULL Range + +mysql> alter table range_table_nullable add partition pX VALUES LESS THAN ("1970-01-01"); +Query OK, 0 rows affected (0.11 sec) + +mysql> insert into range_table_nullable values (0, null, null); +Query OK, 1 row affected (0.18 sec) + +mysql> select * from range_table_nullable; ++------+------+------+ +| k1 | k2 | k3 | ++------+------+------+ +| 0 | NULL | NULL | ++------+------+------+ +1 row in set (0.18 sec) ``` ## 场景示例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md index 87a7442e3a87c..52655ba6050ad 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md @@ -142,7 +142,7 @@ PROPERTIES ( #### Overwrite Table Partition -> 该功能自 2.1.2 版本起可用。 +> 该功能自 2.1.1 版本起可用。 使用 INSERT OVERWRITE 重写分区时,实际我们是将如下三步操作封装为一个事务并执行,如果中途失败,已进行的操作将会回滚: 1. 假设指定重写分区 p1,首先创建一个与重写的目标分区结构相同的空临时分区 `pTMP` diff --git a/versioned_docs/version-2.1/advanced/partition/auto-partition.md b/versioned_docs/version-2.1/advanced/partition/auto-partition.md index 087cc41901074..839914dd89d84 100644 --- a/versioned_docs/version-2.1/advanced/partition/auto-partition.md +++ b/versioned_docs/version-2.1/advanced/partition/auto-partition.md @@ -185,7 +185,9 @@ mysql> select * from auto_null_list partition(pX); 1 row in set (0.20 sec) ``` -2. In Doris, NULL values are included in the minimum value partition, whether they are AUTO PARTITION tables or not. Therefore, if a partition is automatically created for a NULL value, you get a partition starting with the minimum value: +2. For AUTO RANGE PARTITION, the storage of NULL values requires the manual creation of specific partitions. + +In Doris' RANGE PARTITION, we do not use a separate NULL PARTITION to contain NULL values, but rather group them in the **minium LESS THAN partition**. For logical clarity, the AUTO RANGE PARTITION does not automatically create such a partition when it encounters a NULL value. If necessary, you can create such a partition yourself to contain NULL values. ```sql mysql> CREATE TABLE `range_table_nullable` ( @@ -204,15 +206,21 @@ mysql> CREATE TABLE `range_table_nullable` ( Query OK, 0 rows affected (0.09 sec) mysql> insert into range_table_nullable values (0, null, null); -Query OK, 1 row affected (0.21 sec) - -mysql> show partitions from range_table_nullable; -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -| 457060 | p00000101000000 | 2 | 2024-03-25 03:01:38 | NORMAL | k2 | [types: [DATETIMEV2]; keys: [0000-01-01 00:00:00]; ..types: [DATETIMEV2]; keys: [0000-01-02 00:00:00]; ) | k1 | 16 | 1 | HDD | 9999-12-31 23:59:59 | | NULL | 0.000 | false | tag.location.default: 1 | true | true | NULL | -+-------------+-----------------+----------------+---------------------+--------+--------------+----------------------------------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ -1 row in set (0.09 sec) +ERROR 1105 (HY000): errCode = 2, detailMessage = [CANCELLED]TStatus: errCode = 2, detailMessage = Can't create partition for NULL Range + +mysql> alter table range_table_nullable add partition pX VALUES LESS THAN ("1970-01-01"); +Query OK, 0 rows affected (0.11 sec) + +mysql> insert into range_table_nullable values (0, null, null); +Query OK, 1 row affected (0.18 sec) + +mysql> select * from range_table_nullable; ++------+------+------+ +| k1 | k2 | k3 | ++------+------+------+ +| 0 | NULL | NULL | ++------+------+------+ +1 row in set (0.18 sec) ``` ## Sample Scenarios diff --git a/versioned_docs/version-2.1/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md b/versioned_docs/version-2.1/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md index 57bddc226ad76..d97752ff1484e 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md +++ b/versioned_docs/version-2.1/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md @@ -188,7 +188,7 @@ The following is examples: #### Overwrite Auto Detect Partition -> This feature is available since version 2.1.2. +> This feature is available since version 2.1.1. When the PARTITION clause specified by the INSERT OVERWRITE command is `PARTITION(*)`, this overwrite will automatically detect the partition where the data is located. Example: