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: 

SQL - Dynamic overwrite + overwrite schema

oneill
New Contributor II

Hello,

Let say we have an empty table S that represents the schema we want to keep

ABCDE

We have another table T partionned by column A with a schema that depends on the file we have load into. Say :

ABCF
1b1c1f1
2b2c2f2

Now to make T having the same schema as S I do :

SET spark.sql.sources.partitionOverwriteMode=dynamic;
CREATE OR REPLACE TABLE T PARTITIONED BY (A) as SELECT * FROM S WHERE false;

 and the result is, as I wish :

ABCDE
1b1c1nullnull
2b2c2nullnull

Good. But the fact is I didn't see we can do something like that in databricks doc. Even worse it is said  that overwrite schema option (pyspark option I guess because I don't succeed to use this option with SQL) and dynamic partition don't work together. 

So here's the question : is the behavior described above a bug or a feature ?

Ps : runtime si 16.3

3 REPLIES 3

nikhilj0421
Databricks Employee
Databricks Employee

oneill
New Contributor II

Hi, thanks for the reply. I've already looked at the documentation on this point, which actually states that dynamic overwrite doesn't work with schema overwrite, while the instructions described above seem to indicate the opposite.

nikhilj0421
Databricks Employee
Databricks Employee

Let me check on this. 

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now