From ea5cbd8a25c4de04d30afab29eadd8f387b380e5 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 25 Jul 2024 12:04:36 +0800 Subject: [PATCH] partitioned-table: create strictly increasing range columns partition (#18353) --- partitioned-table.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/partitioned-table.md b/partitioned-table.md index 1a70299593a64..8733e29bcdba3 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -169,6 +169,23 @@ Range partitioning is particularly useful when one or more of the following cond Range COLUMNS partitioning is a variant of Range partitioning. You can use one or more columns as partitioning keys. The data types of partition columns can be integer, string (`CHAR` or `VARCHAR`), `DATE`, and `DATETIME`. Any expressions, such as non-COLUMNS partitioning, are not supported. +Like Range partitioning, Range COLUMNS partitioning also requires the partition ranges to be strictly increasing. The partition definition in the following example is not supported: + +```sql +CREATE TABLE t( + a int, + b datetime, + c varchar(8) +) PARTITION BY RANGE COLUMNS(`c`,`b`) +(PARTITION `p20240520A` VALUES LESS THAN ('A','2024-05-20 00:00:00'), + PARTITION `p20240520Z` VALUES LESS THAN ('Z','2024-05-20 00:00:00'), + PARTITION `p20240521A` VALUES LESS THAN ('A','2024-05-21 00:00:00')); +``` + +``` +Error 1493 (HY000): VALUES LESS THAN value must be strictly increasing for each partition +``` + Suppose that you want to partition by name, and drop old and invalid data, then you can create a table as follows: ```sql