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: 

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

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