Az 数据工厂:使用无效参数调用了函数 'int'

Az Data Factory: The function 'int' was invoked with a parameter that is not valid

如何在 Azure 数据工厂中将 string 数据类型转换为 int 数据类型 Data Flow activity 以设置参数?

我一直在尝试从 gen2 数据湖中的 json 文件获取值:

{
    "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
    },
    ...
}

但在上次活动中出现此错误:

{
    "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": ""
}

我一直在关注 documentation 以及这些堆栈溢出问题:

Convert Row Count to INT in Azure Data Factory
但是无论我做什么,我都会遇到同样的错误。

如何重现

  1. 在管道中使用 Lookup activity:

  1. 开始变量table_size_var作为字符串数据类型

  1. Set Variable activity 得到 data_space_MB 值:
    @string(activity('read_json').output.firstRow.data_space_MB)

  1. Data Flow中设置参数table_size_mb:

  1. 设置变量table_size_var的值到参数table_size_mb:
    @int(variables('table_size_var'))

  1. 运行 管道 - 结果:

查找

设置变量

数据流

我试过并得到同样的错误。

int()函数只对int字符串转整数有效,参数必须是int字符串! 例如字符串 '100' 到整数 100。它不能将十进制字符串 '136.848' 转换为整数 136.848.

我正在使用 int()split() 函数来获取整数 138 ,然后管道运行良好。 表达式:

@int(split(variables('num'),'.')[1])
  1. 变量将拆分为一个数组,'138''848',使用[1]获取第一个元素。
  2. 然后使用int()'138'转换为整数138