Reputation: 2421
How to convert a string
to a int
data type in Azure Data Factory Data Flow
activity to set a parameter?
I have been trying to get a value from a json
file in a gen2 data lake:
{
"firstRow": {
"schema_name": "my_schema",
"table_name": "my_table",
"reserved_space_MB": 138.808,
"unused_space_MB": 1.392,
"data_space_MB": 136.848,
"index_space_MB": 0.568,
"row_count": 916300
},
...
}
But got this error in the last activty:
{
"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": "_split_file_from_table",
"details": ""
}
I have been following the documentation and also these stack overflow questions:
Azure Data Factory split file by file size
Convert Row Count to INT in Azure Data Factory
But I'm getting the same error no matter what I do.
How to reproduce
Lookup
activity in a pipeline:table_size_var
as a string data typeSet Variable
activity to get the data_space_MB
value:@string(activity('read_json').output.firstRow.data_space_MB)
table_size_mb
in a Data Flow
:table_size_var
to the parameter table_size_mb
:@int(variables('table_size_var'))
Upvotes: 0
Views: 6350
Reputation: 16431
I tried and get the same error.
The int()
function only works for covert int string to integer, the parameter must be an int String!
For example string '100'
to integer 100
. It can not convert decimal string '136.848'
to integer 136.848
.
I'm using int()
and split()
function to get integer 138
, then the pipeline works well.
Expression:
@int(split(variables('num'),'.')[1])
'138'
and '848'
, using [1]
to get the first element.int()
to convert '138'
to integer 138
.Upvotes: 2