Updated on 2025-01-09 GMT+08:00

SHALLOW CLONE

Function

This command creates a shallow copy of an existing Delta table in a specific version. The cloned information includes the schema, partition information, and data file paths.

Any changes made to the cloned table will only affect the clone itself and not the source table, as long as they do not touch the source data. Note that the cloned table may still point to the data files of the source table, which may cause issues if the source table undergoes a vacuum operation and the files are not found for the clone.

Syntax

CREATE TABLE [target_db.]target_table

SHALLOW CLONE [source_db.]source_table|DELTA.`obs://bucket_name/tbl_path`

location 'obs://bucket_name/tbl_path'

Parameter Description

Table 1 Parameter descriptions of SHALLOW CLONE

Parameter

Description

target_db

Name of the target database, consisting of letters, numbers, and underscores (_)

target_table

Name of the target table, consisting of letters, numbers, and underscores (_)

source_db

Name of the source database, consisting of letters, numbers, and underscores (_)

source_table

Name of the source table, consisting of letters, numbers, and underscores (_)

bucket_name

OBS bucket name

tbl_path

Storage location of the Delta table in the OBS bucket

constraint_name

Constraint name

boolExpression

Constraint expression

Required Permissions

  • SQL permissions
Table 2 Permissions required for executing SHALLOW CLONE

Permission Description

CREATE_TABLE permission on the target database

SELECT permission on the source table

  • Fine-grained permissions: dli:database:createTable and dli:table:select
  • Metadata services provided by LakeFormation. Refer to the LakeFormation documentation for details on permission configuration.

Example

CREATE OR REPLACE TABLE delta_table1 SHALLOW CLONE delta_table0 LOCATION 'obs://bucket0/db0/delta_table1';
CREATE TABLE delta.`obs://bucket0/db0/delta_table1` SHALLOW CLONE delta_table0 VERSION AS OF 10;

System Response

Displays whether the task is successfully executed in the execution history or job list.