load new data in delta table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 07:52 AM
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
- Labels:
-
Delta
-
FORMAT OPTIONS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 12:27 PM
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')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 01:13 PM
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

