CREATE ....CLONE
In Lakehouse, the clone table operation creates an independent copy of a table that is completely separate from the original table and does not affect each other. Clone tables do not take up additional storage space when created because they share the data version of the original table. However, if the original table data changes and affects the data in the clone table, the clone table will need to pay for the storage costs of these changes. Clone tables have similar functions to regular tables, including operations such as querying, copying, and deleting. Lakehouse supports cloning regular tables and dynamic tables, and allows creating clones of clones, i.e., cloning a table that is already a clone.
Notes
- The clone operation does not copy the permissions of the original table, and the newly cloned table will have independent permission settings.
- The clone operation does not copy user-set properties, including lifecycle and data time travel retention periods.
- Real-time written and uncommitted data will not be cloned. Therefore, data that has just been written will not be found in the clone table after the clone is completed.
- Cloning external tables is not supported.
Normal Table Clone
- You can use
TIMESTAMP AS OF timestamp_expression
to clone the version of the dynamic table at a specified point in time. As long as the point in time is within the data retention period (data_retention_days
)timestamp_expression
can be any of the following:'2024-10-18T22:15:12.013Z'
, i.e., a string that can be cast to a timestampcast('2024-10-18 13:36:32 ' as timestamp)
'2024-10-18'
, i.e., a date stringcurrent_timestamp() - interval 12 hours
date_sub(current_date(), 1)
- Any other expression that is itself a timestamp or can be cast to a timestamp
Dynamic Table Cloning
- The cloned dynamic table is paused by default. You can use
ALTER DYNAMIC TABLE table_name RESUME;
to start the refresh task. DYNAMIC TABLE dt_name
: The name of the dynamic table to be created.dt_name
is a placeholder that you need to replace with the actual table name.REFRESH
: Specifies the refresh options for the table. When creating a cloned dynamic table, you can specify the refresh options:- If refresh options are specified, the refresh strategy of the cloned table is used.
- If no refresh options are specified, the default refresh strategy is used.
START WITH timestamp_expr
: Optional clause that specifies the start time for the table refresh.timestamp_expr
is a timestamp expression.interval_time
: Specifies the refresh interval time unit. This is of typeINTERVAL
and can be any of the following:- INTERVAL 1 year
- INTERVAL 2 month
- INTERVAL 3 day
- INTERVAL 4 hour
- INTERVAL 5 minute
- INTERVAL 30 second
VCLUSTER vcname
: Specifies the name of the compute cluster.vcname
is the actual name of the compute cluster.CLONE <source_dynamic_table>
: Clones from an existing dynamic table<source_dynamic_table>
.TIMESTAMP AS OF timestamp_expression
: The version of the cloned dynamic table at the specified point in time.timestamp_expression
can be one of several timestamp expressions. As long as the point in time is within the data retention period (data_retention_days
):timestamp_expression
can be any of the following:'2024-10-18T22:15:12.013Z'
, i.e., a string that can be cast to a timestampcast('2024-10-18 13:36:32 ' as timestamp)
'2024-10-18'
, i.e., a date stringcurrent_timestamp() - interval 12 hours
date_sub(current_date(), 1)
- Any other expression that is itself a timestamp or can be cast to a timestamp
Permission Requirements
- You need
CREATE TABLE
permission in the current schema to create a cloned table. - You need
SELECT
permission on the original table.