AUTO_PARTITION_NAME
更新时间:2025-10-17
Description
Syntax
VARCHAR AUTO_PARTITION_NAME('RANGE', 'VARCHAR unit', DATETIME datetime)
VARCHAR AUTO_PARTITION_NAME('LIST', VARCHAR,...)
Generate datetime partition names by unit following RANGE's partition name rules
Convert strings to partition names following LIST's partition name rules
The datetime parameter is a legal date expression.
The unit parameter is the time interval you want, the available values are: [second, minute, hour, day, month, year].
If unit does not match one of these options, a syntax error will be returned.
Supported since PALO 2.1.6
Example
SQL
1mysql> select auto_partition_name('range', 'years', '123');
2ERROR 1105 (HY000): errCode = 2, detailMessage = range auto_partition_name must accept year|month|day|hour|minute|second for 2nd argument
3
4mysql> select auto_partition_name('range', 'year', '2022-12-12 19:20:30');
5+---------------------------------------------------------------+
6| auto_partition_name('range', 'year', '2022-12-12 19:20:30') |
7+---------------------------------------------------------------+
8| p20220101000000 |
9+---------------------------------------------------------------+
10
11mysql> select auto_partition_name('range', 'month', '2022-12-12 19:20:30');
12+---------------------------------------------------------------+
13| auto_partition_name('range', 'month', '2022-12-12 19:20:30') |
14+---------------------------------------------------------------+
15| p20221201000000 |
16+---------------------------------------------------------------+
17
18mysql> select auto_partition_name('range', 'day', '2022-12-12 19:20:30');
19+---------------------------------------------------------------+
20| auto_partition_name('range', 'day', '2022-12-12 19:20:30') |
21+---------------------------------------------------------------+
22| p20221212000000 |
23+---------------------------------------------------------------+
24
25mysql> select auto_partition_name('range', 'hour', '2022-12-12 19:20:30');
26+---------------------------------------------------------------+
27| auto_partition_name('range', 'hour', '2022-12-12 19:20:30') |
28+---------------------------------------------------------------+
29| p20221212190000 |
30+---------------------------------------------------------------+
31
32mysql> select auto_partition_name('range', 'minute', '2022-12-12 19:20:30');
33+---------------------------------------------------------------+
34| auto_partition_name('range', 'minute', '2022-12-12 19:20:30') |
35+---------------------------------------------------------------+
36| p20221212192000 |
37+---------------------------------------------------------------+
38
39mysql> select auto_partition_name('range', 'second', '2022-12-12 19:20:30');
40+---------------------------------------------------------------+
41| auto_partition_name('range', 'second', '2022-12-12 19:20:30') |
42+---------------------------------------------------------------+
43| p20221212192030 |
44+---------------------------------------------------------------+
45
46mysql> select auto_partition_name('list', 'helloworld');
47+-------------------------------------------+
48| auto_partition_name('list', 'helloworld') |
49+-------------------------------------------+
50| phelloworld10 |
51+-------------------------------------------+
52
53mysql> select auto_partition_name('list', 'hello', 'world');
54+-----------------------------------------------+
55| auto_partition_name('list', 'hello', 'world') |
56+-----------------------------------------------+
57| phello5world5 |
58+-----------------------------------------------+
59
60mysql> select auto_partition_name('list', "你好");
61+------------------------------------+
62| auto_partition_name('list', "你好") |
63+------------------------------------+
64| p4f60597d2 |
65+------------------------------------+
Keywords
Plain Text
1AUTO_PARTITION_NAME,AUTO,PARTITION,NAME
