> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# Expression partitioning (recommended)

> How to use expression partitioning in the database to automatically create partitions based on data values.

Since v3.0, the database has supported expression partitioning (previously known as automatic partitioning), which is more flexible and user-friendly. This partitioning method is suitable for most scenarios such as querying and managing data based on continuous time ranges or ENUM values.

You only need to specify a simple partition expression at table creation. During data loading, the database will automatically create partitions based on the data and the rule defined in the partition expression. You no longer need to manually create numerous partitions at table creation, nor configure dynamic partition properties.

From v3.4 onwards, expression partitioning is further optimized to unify all partitioning strategies and supported more complex solutions. It is recommended in most cases, and will replace the other partitioning strategies in future releases.

From v3.5 onwards, the database supports merging expression partitions based on time function for optimized storage efficiency and query performance. For detailed information, see [Merge expression partitions](#merge-expression-partitions).

## Partitioning based on a simple time function expression

If you frequently query and manage data based on continuous time ranges, you only need to specify a date type (`DATE` or `DATETIME`) column as the partition column and specify year, month, day, or hour as the partition granularity in the time function expression. The database will automatically create partitions and set the partitions' start and end dates or datetime based on the loaded data and partition expression.

However, in some special scenarios, such as partitioning historical data into partitions by month and recent data into partitions by day, you must use [range partitioning](/documents/4.2/table_design/data_distribution/Data_distribution.md#range-partitioning) to create partitions.

**Note**

`PARTITION BY date_trunc(column)` and `PARTITION BY time_slice(column)` are considered range partitioning, despite their format of expression partitioning. Therefore, you can use the `ALTER TABLE ... ADD PARTITION` statement for range partitions to add new partitions to tables using such partitioning strategies.

### Syntax

```sql theme={null}
PARTITION BY expression
...
[ PROPERTIES( { 'partition_live_number' = 'xxx' | 'partition_retention_condition' = 'expr' } ) ]

expression ::=
    { date_trunc ( <time_unit> , <partition_column> ) |
      time_slice ( <partition_column> , INTERVAL <N> <time_unit> [ , boundary ] ) }
```

### Parameters

#### `expression`

**Required**: YES\
**Description**: A simple time function expression that use the [`date_trunc`](/documents/4.2/sql-reference/sql-functions/date-time-functions/date_trunc) or [`time_slice`](/documents/4.2/sql-reference/sql-functions/date-time-functions/time_slice) functions. If you use the function `time_slice`, you do not need to pass the `boundary` parameter. It is because in this scenario, the default and valid value for this parameter is `floor`, and the value cannot be `ceil`.

#### `time_unit`

**Required**: YES\
**Description**: The partition granularity, which can be `hour`, `day`, `week`, `month`, or `year`. If partition granularity is `hour`, the partition column must be of the `DATETIME` data type and cannot be of the `DATE` data type.

#### `partition_column`

**Required**: YES\
**Description**: The name of the partition column.

* The partition column can only be of the `DATE` or `DATETIME` data type. The partition column allows `NULL` values.
* The partition column can be of the `DATE` or `DATETIME` data type if the `date_trunc` function is used. The partition column must be of the `DATETIME` data type if the `time_slice` function is used.
* If the partition column is of the `DATE` data type, the supported range is `[0000-01-01 ~ 9999-12-31]`. If the partition column is of the `DATETIME` data type, the supported range is `[0000-01-01 01:01:01 ~ 9999-12-31 23:59:59]`
* Currently, you can specify only one partition column; multiple partition columns are not supported.

#### `partition_live_number`

**Required**: NO\
**Description**: The number of the most recent partitions to be retained. Partitions that start on or before the current time are sorted in chronological order, and only the most recent `partition_live_number` of them are retained; the others are deleted. For a DATE partition column, the cutoff is the current date. For a DATETIME partition column, the cutoff is the current timestamp, so a partition that starts later today (for example, an hourly partition) is not counted. Partitions that start after the cutoff are neither counted nor deleted. Expired partitions are dropped forcibly and cannot be restored with RECOVER. The database schedules tasks to manage the number of partitions, and the scheduling interval can be configured through the FE dynamic parameter `dynamic_partition_check_interval_seconds`, which defaults to 600 seconds (10 minutes). Suppose that the current date is April 4, 2023, `partition_live_number` is set to `2`, and the partitions include `p20230401`, `p20230402`, `p20230403`, `p20230404`. The partitions `p20230403` and `p20230404` are retained, and other partitions are deleted. If dirty data is loaded, such as data from the future dates April 5 and April 6, partitions include `p20230401`, `p20230402`, `p20230403`, `p20230404`, and `p20230405`, and `p20230406`. Then partitions `p20230403`, `p20230404`, `p20230405`, and `p20230406` are retained, and the other partitions are deleted.

#### `partition_retention_condition`

From v3.5.0 onwards, native tables support Common Partition Expression TTL.

`partition_retention_condition`: The expression that declares the partitions to be retained dynamically. Partitions that do not meet the condition in the expression will be dropped regularly. Example: `'partition_retention_condition' = 'dt >= CURRENT_DATE() - INTERVAL 3 MONTH'`.

* The expression can only contain partition columns and constants. Non-partition columns are not supported.
* Common Partition Expression applies to List partitions and Range partitions differently:
  * For tables with List partitions, the database supports deleting partitions filtered by the Common Partition Expression.
  * For tables with Range partitions, the database can only filter and delete partitions using the partition pruning capability of FE. Partitions correspond to predicates that are not supported by partition pruning cannot be filtered and deleted.

### Usage notes

* During data loading, the database automatically creates some partitions based on the loaded data, but if the load job fails for some reason, the partitions that are automatically created by the database cannot be automatically deleted.
* The database sets the default maximum number of automatically created partitions for one load to 4096, which can be configured by the FE parameter `auto_partition_max_creation_number_per_load`. This parameter can prevent you from accidentally creating too many partitions.
* The naming rule for partitions is consistent with the naming rule for dynamic partitioning.

### Examples

Example 1: Suppose you frequently query data by day. You can use the partition expression `date_trunc()` and set the partition column as `event_day` and the partition granularity as `day` at table creation. Data is automatically partitioned based on dates during loading. Data of the same day is stored in one partition and partition pruning can be used to significantly improve query efficiency.

```SQL theme={null}
CREATE TABLE site_access1 (
    event_day DATETIME NOT NULL,
    site_id INT DEFAULT '10',
    city_code VARCHAR(100),
    user_name VARCHAR(32) DEFAULT '',
    pv BIGINT DEFAULT '0'
)
DUPLICATE KEY(event_day, site_id, city_code, user_name)
PARTITION BY date_trunc('day', event_day)
DISTRIBUTED BY HASH(event_day, site_id);
```

For example, when the following two data rows are loaded, the database will automatically create two partitions, `p20230226` and `p20230227`, with ranges \[2023-02-26 00:00:00, 2023-02-27 00:00:00) and \[2023-02-27 00:00:00, 2023-02-28 00:00:00) respectively. If subsequent loaded data falls within these ranges, they are automatically routed to the corresponding partitions.

```SQL theme={null}
-- insert two data rows
INSERT INTO site_access1  
VALUES ("2023-02-26 20:12:04",002,"New York","Sam Smith",1),
("2023-02-27 21:06:54",001,"Los Angeles","Taylor Swift",1);

-- view partitions
mysql > SHOW PARTITIONS FROM site_access1;
+-------------+---------------+----------------+---------------------+--------------------+--------+--------------+------------------------------------------------------------------------------------------------------+--------------------+---------+----------------+---------------+---------------------+--------------------------+----------+-------------+------------+----------+-------------+--------------------+----------------+----------------+
| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime  | VisibleVersionHash | State  | PartitionKey | Range                                                                                                | DistributionKey    | Buckets | ReplicationNum | StorageMedium | CooldownTime        | LastConsistencyCheckTime | DataSize | StorageSize | IsInMemory | RowCount | DataVersion | VersionEpoch       | VersionTxnType | TabletBalanced |
+-------------+---------------+----------------+---------------------+--------------------+--------+--------------+------------------------------------------------------------------------------------------------------+--------------------+---------+----------------+---------------+---------------------+--------------------------+----------+-------------+------------+----------+-------------+--------------------+----------------+----------------+
| 17138       | p20230226     | 2              | 2023-07-19 17:53:59 | 0                  | NORMAL | event_day    | [types: [DATETIME]; keys: [2023-02-26 00:00:00]; ..types: [DATETIME]; keys: [2023-02-27 00:00:00]; ) | event_day, site_id | 6       | 3              | HDD           | 9999-12-31 23:59:59 | NULL                     | 0B       | 0B          | false      | 0        | 2           | 409742105974407168 | TXN_NORMAL     | true           |
| 17113       | p20230227     | 2              | 2023-07-19 17:53:59 | 0                  | NORMAL | event_day    | [types: [DATETIME]; keys: [2023-02-27 00:00:00]; ..types: [DATETIME]; keys: [2023-02-28 00:00:00]; ) | event_day, site_id | 6       | 3              | HDD           | 9999-12-31 23:59:59 | NULL                     | 0B       | 0B          | false      | 0        | 2           | 409742105974407169 | TXN_NORMAL     | true           |
+-------------+---------------+----------------+---------------------+--------------------+--------+--------------+------------------------------------------------------------------------------------------------------+--------------------+---------+----------------+---------------+---------------------+--------------------------+----------+-------------+------------+----------+-------------+--------------------+----------------+----------------+
2 rows in set (0.00 sec)
```

Example 2: If you want to implement partition lifecycle management, which is to retain only a certain number of recent partitions and delete historical partitions, you can use the `partition_live_number` property to specify the number of partitions to retain.

```SQL theme={null}
CREATE TABLE site_access2 (
    event_day DATETIME NOT NULL,
    site_id INT DEFAULT '10',
    city_code VARCHAR(100),
    user_name VARCHAR(32) DEFAULT '',
    pv BIGINT DEFAULT '0'
) 
DUPLICATE KEY(event_day, site_id, city_code, user_name)
PARTITION BY date_trunc('month', event_day)
DISTRIBUTED BY HASH(event_day, site_id)
PROPERTIES(
    "partition_live_number" = "3" -- only retains the most recent three partitions
);
```

Example 3: Suppose you frequently query data by week. You can use the partition expression `time_slice()` and set the partition column as `event_day` and the partition granularity to one week at table creation. Data for one week is stored in one partition and partition pruning can be used to significantly improve query efficiency.

```SQL theme={null}
CREATE TABLE site_access(
    event_day DATETIME NOT NULL,
    site_id INT DEFAULT '10',
    city_code VARCHAR(100),
    user_name VARCHAR(32) DEFAULT '',
    pv BIGINT DEFAULT '0'
)
DUPLICATE KEY(event_day, site_id, city_code, user_name)
PARTITION BY time_slice(event_day, INTERVAL 1 week)
DISTRIBUTED BY HASH(event_day, site_id);
```

## Partitioning based on the column expression (since v3.1)

If you frequently query and manage data of a specific type, you only need to specify the column representing the type as the partition column. The database will automatically create partitions based on the partition column values of the loaded data.

However, in some special scenarios, such as when the table contains a column `city`, and you frequently query and manage data based on countries and cities. You must use [list partitioning](/documents/4.2/table_design/data_distribution/list_partitioning.md) to store data of multiple cities within the same country in one partition.

### Syntax

```sql theme={null}
PARTITION BY expression
...

expression ::=
    partition_columns 
    
partition_columns ::=
    <column>, [ <column> [,...] ]
```

### Parameters

#### `partition_columns`

**Required**: YES\
**Description**: The names of partition columns.

* The partition column values can be string (`BINARY` not supported), `date` or `datetime`, `integer`, and `boolean` values. The partition column allows `NULL` values.
* Each partition can only contain data with the same value in the partition column. To include data with different values in a partition column in a partition, see [List partitioning](/documents/4.2/table_design/data_distribution/list_partitioning.md).

**Note**

From v3.4 onwards, you can omit the parentheses that are used to wrap the partition columns. For example, you can replace `PARTITION BY (dt,city)` with `PARTITION BY dt,city`.

### Usage notes

* During data loading, the database automatically creates some partitions based on the loaded data, but if the load job fails for some reason, the partitions that are automatically created by the database cannot be automatically deleted.
* The database sets the default maximum number of automatically created partitions for one load to 4096, which can be configured by the FE parameter `auto_partition_max_creation_number_per_load`. This parameter can prevent you from accidentally creating too many partitions.
* The naming rule for partitions: if multiple partition columns are specified, the values of different partition columns are connected with an underscore `_` in the partition name, and the format is `p<value in partition column 1>_<value in partition column 2>_...`. For example, if two columns `dt` and `province` are specified as partition columns, both of which are string types, and a data row with values `2022-04-01` and `beijing` is loaded, the corresponding partition automatically created is named `p20220401_beijing`.

### Examples

Example 1: Suppose you frequently query details of the data center billing based on time ranges and specific cities. At table creation, you can use a partition expression to specify the first partition columns as `dt` and `city`. This way, data belonging to the same date and city are routed into the same partition, and partition pruning can be used to significantly improve query efficiency.

```SQL theme={null}
CREATE TABLE t_recharge_detail1 (
    id bigint,
    user_id bigint,
    recharge_money decimal(32,2), 
    city varchar(20) not null,
    dt varchar(20) not null
)
DUPLICATE KEY(id)
PARTITION BY dt,city
DISTRIBUTED BY HASH(`id`);
```

Insert a single data row into the table.

```SQL theme={null}
INSERT INTO t_recharge_detail1 
VALUES (1, 1, 1, 'Houston', '2022-04-01');
```

View the partitions. The result shows that the database automatically creates a partition `p20220401_Houston` based on the loaded data. During subsequent loading, data with the values `2022-04-01` and `Houston` in the partition columns `dt` and `city` are stored in this partition.

**Tip**

Each partition can only contain data with the specified one value for the partition column. To specify multiple values for a partition column in a partition, see [List partitions](/documents/4.2/table_design/data_distribution/list_partitioning.md).

```SQL theme={null}
MySQL > SHOW PARTITIONS from t_recharge_detail1\G
*************************** 1. row ***************************
             PartitionId: 16890
           PartitionName: p20220401_Houston
          VisibleVersion: 2
      VisibleVersionTime: 2023-07-19 17:24:53
      VisibleVersionHash: 0
                   State: NORMAL
            PartitionKey: dt, city
                    List: [["2022-04-01","Houston"]]
         DistributionKey: id
                 Buckets: 6
          ReplicationNum: 3
           StorageMedium: HDD
            CooldownTime: 9999-12-31 23:59:59
LastConsistencyCheckTime: NULL
                DataSize: 2.5KB
             StorageSize: 2.5KB
              IsInMemory: false
                RowCount: 1
             DataVersion: 2
            VersionEpoch: 409742188174376960
          VersionTxnType: TXN_NORMAL
          TabletBalanced: true
1 row in set (0.00 sec)
```

## Partitioning based on a complex time function expression (since v3.4)

From v3.4.0 onwards, expression partitioning supports any expressions that return `DATE` or `DATETIME` types to accommodate even more complex partitioning scenarios. For the supported time functions, see [Appendix - Supported time functions](#supported-time-functions).

For example, you can define a Unix timestamp column, and use `from_unixtime()` directly against the column in the partition expression to define the partition key, instead of define a generated `DATE` or `DATETIME` column with the function. For more about the usage, see [Examples](#examples-2).

From v3.4.4 onwards, partition pruning are supported for partitions based on most `DATETIME`-related functions.

### Examples

Example 1: Suppose you assign a Unix timestamp to each data row and frequently query data by day. You can use the timestamp column with the function `from_unixtime()` in the expression to define the timestamp as the partition column and the partition granularity to a day at table creation. Data of each day is stored in one partition and partition pruning can be used to improve query efficiency.

```SQL theme={null}
CREATE TABLE orders (
    ts BIGINT NOT NULL,
    id BIGINT NOT NULL,
    city STRING NOT NULL
)
PARTITION BY from_unixtime(ts,'%Y%m%d');
```

Example 2: Suppose you assign an `INT` type timestamp to each data row and store data on a monthly basis. You can use the timestamp column with the functions `cast()` and `str_to_date()` in the expression to transform the timestamp into the `DATE` type, set it as the partition column, and the partition granularity to a month using `date_trunc()` at table creation. Data of each month is stored in one partition and partition pruning can be used to improve query efficiency.

```SQL theme={null}
CREATE TABLE orders_new (
    ts INT NOT NULL,
    id BIGINT NOT NULL,
    city STRING NOT NULL
)
PARTITION BY date_trunc('month', str_to_date(CAST(ts as STRING),'%Y%m%d'));
```

### Usage notes

Partition pruning is applicable to cases of partitioning based on a complex time function expression:

* If the partition clause is `PARTITION BY from_unixtime(ts)`, queries with filters in the format `ts>1727224687` can be pruned to corresponding partitions.
* If the partition clause is `PARTITION BY str2date(CAST(ts AS string),'%Y%m')`, queries with filters in the format `ts = "20240506"` can be pruned.
* The above cases are also applicable to [Partitioning based on mixed expression](#partitioning-based-on-the-mixed-expression-since-v34).

## Partitioning based on the mixed expression (since v3.4)

From v3.4.0 onwards, expression partitioning supports multiple partition columns with one of them being a time function expression.

### Examples

Example 1: Suppose you assign a Unix timestamp to each data row and frequently query data by day and a specific city. You can use the timestamp column (with the `from_unixtime()` function) and the city column as the partition columns at table creation. Data of each day in each city is stored in one partition and partition pruning can be used to improve query efficiency.

```SQL theme={null}
CREATE TABLE orders (
    ts BIGINT NOT NULL,
    id BIGINT NOT NULL,
    city STRING NOT NULL
)
PARTITION BY from_unixtime(ts,'%Y%m%d'), city;
```

## Manage partitions

### Load data into partitions

During data loading, the database will automatically create partitions based on the loaded data and partition rule defined by the partition expression.

When using expression partitioning, you can use [INSERT OVERWRITE](/documents/4.2/loading/InsertInto.md#overwrite-data-via-insert-overwrite-select) to dynamically overwrite data without specifying the partition name. The database will automatically route and overwrite the data in the corresponding partitions.

If you want to overwrite data in a *specific* partition, you can explicitly provide a partition range in `PARTITION()`. Note that for expression partitions, you need to provide the starting date or datetime of that partition (the partition granularity configured at table creation) or the specific column values, rather than just the partition name. If the partition does not exist, it will be automatically created during data loading.

```SQL theme={null}
INSERT OVERWRITE site_access1 PARTITION(event_day='2022-06-08 20:12:04')
SELECT * FROM site_access2 PARTITION(p20220608);
```

If you use column expression at table creation and want to overwrite data in a specific partition, you need to provide the partition column values that the partition contains. If the partition does not exist, it can be automatically created during data loading.

```SQL theme={null}
INSERT OVERWRITE t_recharge_detail1 PARTITION(dt='2022-04-02',city='texas')
SELECT * FROM t_recharge_detail2 PARTITION(p20220402_texas);
```

### View partitions

When you want to view specific information about automatically created partitions, you need to use the `SHOW PARTITIONS FROM <table_name>` statement. The `SHOW CREATE TABLE <table_name>` statement only returns the syntax for expression partitioning that is configured at table creation.

```SQL theme={null}
MySQL > SHOW PARTITIONS FROM t_recharge_detail1;
+-------------+-------------------+----------------+---------------------+--------------------+--------+--------------+----------------------------+-----------------+---------+----------------+---------------+---------------------+--------------------------+----------+-------------+------------+----------+-------------+--------------------+----------------+----------------+
| PartitionId | PartitionName     | VisibleVersion | VisibleVersionTime  | VisibleVersionHash | State  | PartitionKey | List                       | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime        | LastConsistencyCheckTime | DataSize | StorageSize | IsInMemory | RowCount | DataVersion | VersionEpoch       | VersionTxnType | TabletBalanced |
+-------------+-------------------+----------------+---------------------+--------------------+--------+--------------+----------------------------+-----------------+---------+----------------+---------------+---------------------+--------------------------+----------+-------------+------------+----------+-------------+--------------------+----------------+----------------+
| 11099       | p20220401_Houston | 2              | 2026-03-11 13:59:51 | 0                  | NORMAL | dt, city     | [["2022-04-01","Houston"]] | id              | 6       | 3              | HDD           | 9999-12-31 23:59:59 | NULL                     | 0B       | 0B          | false      | 0        | 2           | 409743636180238336 | TXN_NORMAL     | true           |
| 11116       | p20220402_texas   | 2              | 2026-03-11 13:59:52 | 0                  | NORMAL | dt, city     | [["2022-04-02","texas"]]   | id              | 6       | 3              | HDD           | 9999-12-31 23:59:59 | NULL                     | 0B       | 0B          | false      | 0        | 2           | 409743639174971392 | TXN_NORMAL     | true           |
+-------------+-------------------+----------------+---------------------+--------------------+--------+--------------+----------------------------+-----------------+---------+----------------+---------------+---------------------+--------------------------+----------+-------------+------------+----------+-------------+--------------------+----------------+----------------+
2 rows in set (0.01 sec)
```

### Merge expression partitions

In data management, partitioning based on different time granularity is crucial to optimizing queries and storage. To improve storage efficiency and query performance, the database supports merging multiple expression partitions of a finer time granularity into one of a rougher time granularity, for example, merging partitions by day into one partition by month. By merging partitions that meet the specified condition (time range), the database allows you to partition data on different time granularity.

#### Syntax

```SQL theme={null}
ALTER TABLE [<db_name>.]<table_name>
PARTITION BY <time_expr>
[WHERE <time_range_column>] BETWEEN <start_time> AND <end_time>
```

#### Parameters

##### `PARTITION BY <time_expr>`

**Required**: YES\
**Description**: Specifies the new time granularity for the partitioning strategy, for example, `PARTITION BY date_trunc('month', dt)`.

##### `WHERE <time_range_column> BETWEEN <start_time> AND <end_time>`

**Required**: YES\
**Description**: Specifies the time range of the partitions to be merged. Partitions within this range will be merged based on the rules defined in the `PARTITION BY` clause.

#### Example

Merge the partitions in the table `site_access1`, and change the partition time granularity from day to month. The time range of the partitions to be merged is from `2024-01-01` to `2024-03-31`.

```SQL theme={null}
ALTER TABLE site_access1 PARTITION BY date_trunc('month', event_day)
BETWEEN '2024-01-01' AND '2024-03-31';
```

After merging:

* Day-level partitions `2024-01-01` to `2024-01-31` are merged into a month-level partition of `2024-01`.
* Day-level partitions `2024-02-01` to `2024-02-29` are merged into a month-level partition of `2024-02`.
* Day-level partitions `2024-03-01` to `2024-03-31` are merged into a month-level partition of `2024-03`.

#### Usage notes

* Merging is supported only for expression partitions based on a time function.
* Merging partitions with multiple partition columns is not supported.
* Parallel execution of merging and Schema Change/DML operations is not supported.

## Limits

* Since v3.1.0, the database's shared-data mode supports the [time function expression](#partitioning-based-on-a-simple-time-function-expression). And since v3.1.1, the database's shared-data mode further supports the [column expression](#partitioning-based-on-the-column-expression-since-v31).
* Currently, using CTAS to create tables configured expression partitioning is not supported.
* Currently, using Spark Load to load data to tables that use expression partitioning is not supported.
* When the `ALTER TABLE <table_name> DROP PARTITION <partition_name>` statement is used to delete a partition created by using the column expression, data in the partition is directly removed and cannot be recovered.
* From v3.4.0, v3.3.8, v3.2.13, and v3.1.16 onwards, the database supports [backing up and restoring](/documents/4.2/administration/management/Backup_and_restore.md) tables created with the expression partitioning strategy.

## Appendix

### Supported time functions

Expression partitioning supports the following functions:

**Time functions**:

* `timediff`
* `datediff`
* `to_days`
* `years_add`/`sub`
* `quarters_add`/`sub`
* `months_add`/`sub`
* `weeks_add`/`sub`
* `date_add`/`sub`
* `days_add`/`sub`
* `hours_add`/`sub`
* `minutes_add`/`sub`
* `seconds_add`/`sub`
* `milliseconds_add`/`sub`
* `date_trunc`
* `date_format(YmdHiSf/YmdHisf)`
* `str2date(YmdHiSf/YmdHisf)`
* `str_to_date(YmdHiSf/YmdHisf)`
* `to_iso8601`
* `to_date`
* `unix_timestamp`
* `from_unixtime(YmdHiSf/YmdHisf)`
* `time_slice`

**Other functions**:

* add
* subtract
* cast

**Note**

* Combined usage of multiple time functions is supported.
* The system default time zone is used for all the time functions listed above.
* The value format of the time function, `YmdHiSf`, must start with the roughest time granularity, `%Y`. Formats that start with a finer time granularity, for example, `%m-%d`, are not allowed.

**Example**

`PARTITION BY from_unixtime(cast(str as INT) + 3600, '%Y-%m-%d')`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.