ADF Copy Activity - Emply col issue

ADF_Coder 0 Reputation points
2024-07-20T02:14:27.9266667+00:00

Hi Team,

I have a pipeline where I am copying the data from the file to a database. The file had one extra empty column in between, and my copy activity failed with the below error:

Message: Invalid Excel header with empty value

It failed because the structure got changed and it didn't get mapped for that empty column.

Is there any way to handle this dynamically so that I won't get this error in the future in copy activity?

User's image

Azure SQL Database
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,853 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Amira Bedhiafi 26,266 Reputation points
    2024-07-20T10:24:05.6666667+00:00

    You can use a Derived Column transformation :

    
    iif(columnName == null || trim(columnName) == '', null, columnName)
    
    

    This will convert any empty or null column values to a consistent null value.

    Then you can add a Filter transformation to remove empty columns :

    
    length(trim(columnName)) > 0
    

    If your file schema changes frequently, you can further enhance your solution to handle dynamic schemas using parameters and metadata-driven approaches in ADF :

    1. Parameterize Column Names:
      • Use parameters in your Data Flow to handle column names dynamically.
      • Pass the column names as parameters to the Derived Column and Filter transformations.
    2. Use Metadata Activity:
      • Use the Metadata activity to get the schema of the source file.
      • Pass this schema information as parameters to the Data Flow.
    1 person found this answer helpful.

  2. Chandra Boorla 2,990 Reputation points Microsoft Vendor
    2024-07-24T10:34:01.6166667+00:00

    Hi @ADF_Coder

    Please find the below gif that I have followed to achieve your requirement.

    EmptyColumn1

    Hope this helps! Let me know if you have any further questions.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.