Adding/Updating/Deleting/Clearing/Viewing TTL Policies
Function
Add, update, delete, and clear TTL policies.
Syntax
- Add a TTL policy.
call ttl_policy_save(table => "[table]", path => "[path]", spec => "[spec]", level => "[level]", value => "[value]", units => "[units]")
spec uses regular expressions to select partitions that require TTL. You can run the show partitions command to view the partition format of the Hudi table and write a correct regular expression to match partitions.
value and units must be used together. value is an integer, and units is the unit of the integer value, indicating the duration for storing data.
- Update TTL policy.
call ttl_policy_save(table => "[table]", path => "[path]", spec => "[spec]", level => "[level]", value => "[value]", units => "[units]")
If spec has been specified (same as that of an existing policy), the historical TTL policy is updated.
- Delete a TTL policy.
call ttl_policy_delete(table => "[table]", path => "[path]", spec => "[spec]")
- Clear a TTL policy.
call ttl_policy_empty(table => "[table]", path => "[path]")
- View a TTL policy.
call ttl_policy_show(table => "[table]", path => "[path]")
Parameters
Parameters of the ttl_policy_save command are listed in the following table.
Parameter |
Description |
Mandatory |
---|---|---|
table |
Table name. Database name.Table name is also supported. The value is a string. |
No. Specify either table or path. |
path |
Absolute path of the table. The value is a string. |
No. Specify either table or path. |
spec |
Regular expression. The value is a string. |
Yes |
level |
TTL level. The value is a string. |
Yes. The value can be PARTITION or RECORD. Currently, only PARTITION is supported. |
value |
Retention duration. The value is a string. |
Yes |
units |
Unit of the retention duration. The value is a string. |
Yes. The value can be YEARS, MONTHS, WEEKS, and DAYS. |
The parameters of the ttl_policy_delete command are listed in the following table.
Parameter |
Description |
Mandatory |
---|---|---|
table |
Table name. Database name.Table name is also supported. The value is a string. |
No. Specify either table or path. |
path |
Absolute path of the table. The value is a string. |
No. Specify either table or path. |
spec |
Regular expression. The value is a string. |
Yes |
The parameters of the ttl_policy_empty command are listed in the following table.
Parameter |
Description |
Mandatory |
---|---|---|
table |
Table name. Database name.Table name is also supported. The value is a string. |
No. Specify either table or path. |
path |
Absolute path of the table. The value is a string. |
No. Specify either table or path. |
The parameters of the ttl_policy_show command are listed in the following table.
Parameter |
Description |
Mandatory |
---|---|---|
table |
Table name. Database name.Table name is also supported. The value is a string. |
No. Specify either table or path. |
path |
Absolute path of the table. The value is a string. |
No. Specify either table or path. |
Examples
Scenario: The Hudi table has three levels of partitions: year, month, and day, and the partition field is dt.
- Add a TTL policy to retain the partition of May 2023 for one day.
call ttl_policy_save(table => 'hudi_table', spec => 'dt=2023/05/*', units => 'DAYS', value => '1', level => 'PARTITION')
- Update the TTL policy to retain the partition of May 2023 for one day.
call ttl_policy_save(table => 'hudi_table', spec => 'dt=2023/05/*', units => 'YEARS', value => '1', level => 'PARTITION')
- Delete the TTL policy.
call ttl_policy_delete(table => "hudi_table", spec => "dt=2023/05/*")
- Clear the TTL policy.
call ttl_policy_empty(table => "hudi_table")
- View the TTL policy.
call ttl_policy_show(table => "hudi_table")
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot