หน้านี้ยังไม่พร้อมใช้งานในภาษาท้องถิ่นของคุณ เรากำลังพยายามอย่างหนักเพื่อเพิ่มเวอร์ชันภาษาอื่น ๆ เพิ่มเติม ขอบคุณสำหรับการสนับสนุนเสมอมา

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Data Lake Insight/ Spark SQL Syntax Reference/ Tables/ Table Lifecycle Management/ Specifying the Lifecycle of a Table When Creating the Table

Specifying the Lifecycle of a Table When Creating the Table

Updated on 2024-07-04 GMT+08:00

Function

DLI provides table lifecycle management to allow you to specify the lifecycle of a table when creating the table. DLI determines whether to reclaim a table based on the table's last modification time and its lifecycle. By setting the lifecycle of a table, you can better manage a large number of tables, automatically delete data tables that are no longer used for a long time, and simplify the process of reclaiming data tables. Additionally, data restoration settings are supported to prevent data loss caused by misoperations.

Table Reclamation Rules

  • When creating a table, use TBLPROPERTIES to specify the lifecycle of the table.
    • Non-partitioned table

      If the table is not a partitioned table, the system determines whether to reclaim the table after the lifecycle time based on the last modification time of the table.

    • Partitioned table

      If the table is a partitioned table, the system determines whether the partition needs to be reclaimed based on the last modification time (LAST_ACCESS_TIME) of the partition. After the last partition of a partitioned table is reclaimed, the table is not deleted.

      Only table-level lifecycle management is supported for partitioned tables.

  • Lifecycle reclamation starts at a specified time every day to scan all partitions.

    Lifecycle reclamation starts at a specified time every day. Reclamation only occurs if the last modification time of the table data (LAST_ACCESS_TIME) detected when scanning complete partitions exceeds the time specified by the lifecycle.

    Assume that the lifecycle of a partitioned table is one day and the last modification time of the partitioned data is 15:00 on May 20, 2023. If the table is scanned before 15:00 on May 20, 2023 (less than one day), the partitions in the table will not be reclaimed. If the last data modification time (LAST_ACCESS_TIME) of a table partition exceeds the time specified by the lifecycle during reclamation scan on May 20, 2023, the partition will be reclaimed.

  • The lifecycle function periodically reclaims tables or partitions, which are reclaimed irregularly every day depending on the level of busyness of the service. It cannot ensure that a table or partition will be reclaimed immediately after its lifecycle expires.
  • After a table is deleted, all properties of the table, including the lifecycle, will be deleted. After a table with the same name is created again, the lifecycle of the table will be determined by the new property.

Notes and Constraints

  • The table lifecycle function is currently in the open beta test (OBT) phase. If necessary, contact customer service to whitelist it.
  • Before using the lifecycle function, log in to the DLI console, choose Global Configuration > Service Authorization, select Tenant Administrator(Project-level), and click Update on the Assign Agency Permissions page.
  • The table lifecycle function currently only supports creating tables and versioning tables using Hive and Datasource syntax.
  • The unit of the lifecycle is in days. The value should be a positive integer.
  • The lifecycle can be set only at the table level. The lifecycle specified for a partitioned table applies to all partitions of the table.
  • After the lifecycle is set, DLI and OBS tables will support data backup. The backup directory for OBS tables needs to be set manually. The backup directory must be in the parallel file system and in the same bucket as the original table directory. It cannot have the same directory or subdirectory name as the original table.

Syntax

  • Creating a DLI table using the Datasource syntax
    CREATE TABLE table_name(name string, id int) 
    USING parquet 
    TBLPROPERTIES( "dli.lifecycle.days"=1 );
  • Creating a DLI table using the Hive syntax
    CREATE TABLE table_name(name string, id int) 
    stored as parquet 
    TBLPROPERTIES( "dli.lifecycle.days"=1 );
  • Creating an OBS table using the Datasource syntax
    CREATE TABLE table_name(name string, id int) 
    USING parquet 
    OPTIONS (path "obs://dli-test/table_name")
    TBLPROPERTIES( "dli.lifecycle.days"=1, "external.table.purge"='true', "dli.lifecycle.trash.dir"='obs://dli-test/Lifecycle-Trash' );
  • Creating an OBS table using the Hive syntax
    1
    2
    3
    4
    CREATE TABLE table_name(name string, id int) 
    STORED AS parquet 
    LOCATION 'obs://dli-test/table_name'
    TBLPROPERTIES( "dli.lifecycle.days"=1, "external.table.purge"='true', "dli.lifecycle.trash.dir"='obs://dli-test/Lifecycle-Trash' );
    

Keywords

  • TBLPROPERTIES: Table properties, which can be used to extend the lifecycle of a table.
  • OPTIONS: path of the new table, which is applicable to OBS tables created using the Datasource syntax.
  • LOCATION: path of the new table, which is applicable to OBS tables created using the Hive syntax.

Parameters

Table 1 Parameters

Parameter

Mandatory

Description

table_name

Yes

Name of the table whose lifecycle needs to be set

dli.lifecycle.days

Yes

Lifecycle duration. The value must be a positive integer, in days.

external.table.purge

No

This parameter is available only for OBS tables.

Whether to clear data in the path when deleting a table or partition. The data is not cleared by default.

When this parameter is set to true:

  • After a file is deleted from a non-partitioned OBS table, the table directory is also deleted.
  • The custom partition data in the partitioned OBS table is also deleted.

dli.lifecycle.trash.dir

No

This parameter is available only for OBS tables.

When external.table.purge is set to true, the backup directory will be deleted. By default, backup data is deleted seven days later.

Example

  • Create the test_datasource_lifecycle table using the Datasource syntax. The lifecycle is set to 100 days.
    1
    2
    3
    CREATE TABLE test_datasource_lifecycle(id int) 
    USING parquet 
    TBLPROPERTIES( "dli.lifecycle.days"=100);
    
  • Create the test_hive_lifecycle table using the Hive syntax. The lifecycle is set to 100 days.
    1
    2
    3
    CREATE TABLE test_hive_lifecycle(id int) 
    stored as parquet 
    TBLPROPERTIES( "dli.lifecycle.days"=100);
    
  • Create the test_datasource_lifecycle_obs table using the Datasource syntax. The lifecycle is set to 100 days. When the lifecycle expires, data is deleted by default and backed up to the obs://dli-test/ directory.
    1
    2
    3
    4
    CREATE TABLE test_datasource_lifecycle_obs(name string, id int) 
    USING parquet 
    OPTIONS (path "obs://dli-test/xxx")
    TBLPROPERTIES( "dli.lifecycle.days"=100, "external.table.purge"='true', "dli.lifecycle.trash.dir"='obs://dli-test/Lifecycle-Trash' );
    
  • Create the test_hive_lifecycle_obs table using the Hive syntax. The lifecycle is set to 100 days. When the lifecycle expires, data is deleted by default and backed up to the obs://dli-test/ directory.
    1
    2
    3
    4
    CREATE TABLE test_hive_lifecycle_obs(name string, id int) 
    STORED AS parquet 
    LOCATION 'obs://dli-test/xxx'
    TBLPROPERTIES( "dli.lifecycle.days"=100, "external.table.purge"='true', "dli.lifecycle.trash.dir"='obs://dli-test/Lifecycle-Trash' );
    

เราใช้คุกกี้เพื่อปรับปรุงไซต์และประสบการณ์การใช้ของคุณ การเรียกดูเว็บไซต์ของเราต่อแสดงว่าคุณยอมรับนโยบายคุกกี้ของเรา เรียนรู้เพิ่มเติม

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback