I'm trying to load S3 data which is in .csv format and the S3 Bucket has many files each with a different number of columns and different column sequence and when trying to use the copy command the data is getting stored in wrong columns.
Example: File1
client_id | event_timestamp | event_name
aaa1 | 2020-08-21 | app_launch
bbb2 | 2020-10-11 | first_launch
File2
a_sales| event_timestamp | client_id | event_name
2039 | 2020-08-27 | ccc1 | app_used
3123 | 2020-03-15 | aaa2 | app_uninstalled
Desired OUTPUT:
a_sales | client_id | event_name | event_timestamp
2039 | ccc1 | app_used | 2020-08-27
3123 | aaa2 | app_uninstalled | 2020-03-15
| aaa1 | app_launch | 2020-08-21
| bbb2 | first_launch | 2020-10-11
I have tried the below SQL script which basically runs successfully but doesn't give the desired output can someone help me out with this issue.
COPY public.sample_table
FROM 's3://mybucket/file*'
iam_role 'arn:aws:iam::99999999999:role/RedShiftRole'
FILLRECORD DELIMITER ',' IGNOREHEADER 1;