I am using ADF to copy data from Snowflake table (Source) to Azure Blob CSV file (Sink).
The Sink dataset has “First row as header” checked.
It works well if the source table contains data.
However, if the source table is empty, the generated file is empty without a header.
Please see the screenshots for the settings.
I wonder how to make the generated file with header regardless of whether the source table is empty or not.
Thank you.
2
Answers
If still after trying above, if it does not work then that means its product limitation.
You can try the below workaround, to copy the header into the target file.
0
or not.0
, other one is for regular copy to target file.Use the below query in the lookup to get the count of the table.
Then give the below expression in the if activity.
Inside True activities of if, use the below query for the source of the copy activity.
If the column delimiter in your target file is
|
, you need to use|
instead of,
like thislistagg(column_name,'|')
in the above query.This will give the Delimiter(,) seperated column names as one row with a column name
LISTAGG(COLUMN_NAME,',')
like below.But here, we only want the row which has required headers not the column name.
So, in the sink dataset of this copy activity, uncheck the
First row as header
and give the below configurations. This is the reason to use different datasets for both copy activities.You can change the Column delimiter as per your requirement, but you need to change that in the query as well.
In the False activities of if, Give your regular copy activity with another target dataset.
Execute the pipeline and your headers will be copied like below in the Blob.