cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

MergeSchema Not Working

DJey
New Contributor III

Hi All,

I have a scenario where my Exisiting Delta Table looks like below:

imageNow I have an incremental data with an additional column i.e. owner:

Dataframe Name --> scdDFimageBelow is the code snippet to merge Incremental Dataframe to targetTable, but the new column is not getting added:

imagespark.conf.set("spark.databricks.delta.schema.autoMerge.enabled",True) --> this is also enabled.

But still no luck. Below is the final result which i'm currently getting:

Data looks correct, but the only issue is New Column i.e. Owner is still not merged in targetTable.image 

Someone please help.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

etsyal1e2r3
Honored Contributor

Just add that column to the table with an ALTER TABLE statement. You should capture each table/dataframe columns as a list with df.columns, compare them, and if the table is missing anything do the alter table. Then run your code.

View solution in original post

5 REPLIES 5

etsyal1e2r3
Honored Contributor

Just add that column to the table with an ALTER TABLE statement. You should capture each table/dataframe columns as a list with df.columns, compare them, and if the table is missing anything do the alter table. Then run your code.

Anonymous
Not applicable

Hi @Divyansh Jain​ 

Thank you for posting your question in our community! We are happy to assist you.

To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?

This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance! 

DJey
New Contributor III

This is resolved. Thanks, everyone!

DJey
New Contributor III

@Vidula Khanna​  Enabling the below property resolved my issue:

spark.conf.set("spark.databricks.delta.schema.autoMerge.enabled",True) 

Thanks v much!

g96g
New Contributor III

sorry, can you please explain what was the problem? cause you have already that property enabled 

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.