user1309226
user1309226

Reputation: 759

Azure Data Factory Expression Data Type Conversion Error

This simple expression evaluates correctly at design time when attempting to set a variable value to the following expression:

@string(sub(int(variables('TargetRecordCount')), int(variables('SourceTotalRecordCount')))) 

However when the pipeline is run, the following error occurs:

The function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type

I have verified that the issue is with the variable 'SourceTotalRecordCount'. The other variable is sourced from SQL table. The offending variable is obtained from the Lookup activity which references a CSV file.

The output of the Lookup activity is:

enter image description here

Setting the variable:

@activity('Lookup Source Total Record Count').output.value[0].SourceTotalRecordCount

The input of the SetVariable activity to define the variable TotalRecordDifference**emphasized text is:

enter image description here

I have used output.FirstRow.SourceTotalRecordCount but it still led to the same error.

Upvotes: 0

Views: 1525

Answers (1)

NiharikaMoola
NiharikaMoola

Reputation: 5074

Your expression looks correct. I reproed your expression and was able to get the output without errors.

enter image description here

enter image description here

The issue might be with your incoming data. As per the error message, the variable value is invalid for int conversion.

You can debug by testing individual output values by converting them to int in your set variable. While storing the lookup output value into a variable, try to convert it to int there itself to identify the error.

Example:

@string(int(activity('SourceTotalRecordCount').output.value[0].SourceTotalRecordCount))

enter image description here

@string(int(activity('TargetRecordCount').output.value[0].TargetRecordCount))

enter image description here

Upvotes: 1

Related Questions