问题
I am trying to use a Lookup Activity to return a row count. I am able to do this, but once I do, I would like to run an If Statement against it and if the count returns more than 20MIL in rows, I want to execute an additional pipeline for further table manipulation. The issue, however, is that I can not compare the returned value to a static integer. Below is the current Dynamic Expression I have for this If Statement:
@greater(int(activity('COUNT_RL_WK_GRBY_LOOKUP').output),20000000)
and when fired, the following error is returned: { "errorCode": "InvalidTemplate", "message": "The function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type", "failureType": "UserError", "target": "If Condition1", "details": "" }
Is it possible to convert this returned value to an integer in order to make the comparison? If not, is there a possible work around in order to achieve my desired result?
回答1:
Looks like the issue is with your dynamic expression. Please correct your dynamic expression similar to below and retry.
If
firstRowOnly
is set to true :@greater(int(activity('COUNT_RL_WK_GRBY_LOOKUP').output.firstRow.propertyname),20000000)
If
firstRowOnly
is set to false :@greater(int(activity('COUNT_RL_WK_GRBY_LOOKUP').output.value[zero based index].propertyname),20000000)
The lookup result is returned in the
output
section of the activity run result.- When
firstRowOnly
is set to true (default), the output format is as shown in the following code. The lookup result is under a fixed firstRow key. To use the result in subsequent activity, use the pattern of@{activity('MyLookupActivity').output.firstRow.TableName}
. Sample Output JSON code is as follows:
{ "firstRow": { "Id": "1", "TableName" : "Table1" } }
- When
firstRowOnly
is set to false, the output format is as shown in the following code. A count field indicates how many records are returned. Detailed values are displayed under a fixed value array. In such a case, the Lookup activity is followed by a Foreach activity. You pass the value array to the ForEach activity items field by using the pattern of@activity('MyLookupActivity').output.value
. To access elements in the value array, use the following syntax:@{activity('lookupActivity').output.value[zero based index].propertyname}
. An example is@{activity('lookupActivity').output.value[0].tablename}
. Sample Output JSON Code is as follows:
{ "count": "2", "value": [ { "Id": "1", "TableName" : "Table1" }, { "Id": "2", "TableName" : "Table2" } ] }
Hope this helps.
来源:https://stackoverflow.com/questions/61067826/convert-row-count-to-int-in-azure-data-factory