cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between "deep clone ..." and as "select * from ..."

camilo_s
Contributor

Hi all,

I was trying to deep clone one of the sample tables provided with a parametrized query:

create table if not exists IDENTIFIER(:target_catalog || :target_schema || :table_name) DEEP CLONE IDENTIFIER('samples.tpch.' || :table_name)

But Databricks SQL throws the error:

[DELTA_CLONE_UNSUPPORTED_SOURCE] Unsupported DEEP clone source ''PlanWithUnresolvedIdentifier concat(samples.tpch., ), org.apache.spark.sql.catalyst.parser.AstBuilder$$Lambda$12333/0x00007f4304d55708@4e795225 ', whose format is Unknown. The supported formats are 'delta', 'iceberg' and 'parquet'.

For testing purposes, I also tried hard-coding the source table's full name (e.g. deep clone samples.tpch.partsupp), to no avail (for the record: the query works when both source and target table full names are hard-coded)

I came up with the following workaround, which does work without problems

create table if not exists IDENTIFIER(:target_catalog || '.' || :target_schema || '.' || :table_name) as select * from IDENTIFIER('samples.tpch.' || :table_name)

This leads me to the question: What is the difference between using deep clone an as select * from for cloning tables?

1 REPLY 1

skarpeck
New Contributor III

Deep clone will also clone all the metadata (e.g. indexes, properties, history, etc.), while SELECT * will create a new, fresh Delta Table, with it's own history and properties.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group