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

load new data in delta table

patdev
New Contributor III

Hello all,

I want to know how to update new data in delta table from new csv file.

here is the code that i have used to create delta table from csv file and loaded data. but i have go new updated file and trying to load new data but not able to any guidance would help.

code:

%sql

SET spark.databricks.delta.schema.autoMerge.enabled = true;

create table if not exists catlog.schema.tablename;

COPY INTO catlog.schema.tablename

FROM (SELECT * FROM 's3://bucket/test.csv')

FILEFORMAT = CSV

FORMAT_OPTIONS ('mergeSchema' = 'true', 'header' = 'true')

but i have new file with additional data. how can i load that please guide?

thanks

need to load new datafile in delta table

2 REPLIES 2

Hubert-Dudek
Esteemed Contributor III

You can specify the directory and select the files you want to import. Copy into is increment by default so it will append the data. Here is a code example:

COPY INTO table1 FROM 'folder location'
FILEFORMAT = CSV
FILES = ('1.csv', '2.csv')

patdev
New Contributor III

Thank you, i tried that and it ended in error, the table created with delta are from csv which must have converted to parquet file and all the columns are varchar or string. so not if i want to entered new file it ends in incmopatibility error for datatypes

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.