【问题标题】:Rounding transformation with Data Flow in Azure Data Factory is not working properlyAzure 数据工厂中使用数据流的舍入转换无法正常工作
【发布时间】:2020-09-21 14:30:46
【问题描述】:

我目前正在创建具有通过 DontNet.SDK 进行舍入转换的派生列的数据流。我使用的 Source 和 Sink 数据集是参数化的。我在运行时通过管道参数为它们赋值。请参考下面两个数据流的json文件。

我有一个场景是将工资从小数点后三位四舍五入到小数点后两位。当我在 ADF 中手动创建它时,它已成功舍入。下面是转换的输出结果文件

但是当我使用 .net SDK 创建它时,它不起作用。我没有按预期获得列名,但值正确出现。下面是 .SDK 输出

下面是我创建的Data Flow的Json格式

{
"name": "Rounding_Auto__Transformation",
"properties": {
    "type": "MappingDataFlow",
    "typeProperties": {
        "sources": [
            {
                "dataset": {
                    "referenceName": "defaultdataflowSourcedataset",
                    "type": "DatasetReference"
                },
                "name": "source"
            }
        ],
        "sinks": [
            {
                "dataset": {
                    "referenceName": "defaultdataflowSinkdataset",
                    "type": "DatasetReference"
                },
                "name": "sink"
            }
        ],
        "transformations": [
            {
                "name": "DerivedColumn0"
            }
        ],
        "script": "source(output(\n\t\tid as string,\n\t\tsal as string,\n\t\tgender as string,\n\t\tname as string,\n\t\tisMarried as string,\n\t\ttags as string,\n\t\taddress as string\n\t),\n\tallowSchemaDrift: true,\n\tvalidateSchema: false,\n\tignoreNoFilesFound: false) ~> source\nsource derive(NewSal = round(toFloat(sal),2,2)) ~> DerivedColumn0\nDerivedColumn0 sink(allowSchemaDrift: true,\n\tvalidateSchema: false,\n\tpartitionFileNames:['customer_post_with_round.csv'],\n\tpartitionBy('hash', 1),\n\tskipDuplicateMapInputs: true,\n\tskipDuplicateMapOutputs: true) ~> sink"
    }
}

}

我还直接在 ADF 中比较了为手册创建的 json(因为它可以工作)——这里是手册的那个

{
"name": "Rounding_Manually",
"properties": {
    "type": "MappingDataFlow",
    "typeProperties": {
        "sources": [
            {
                "dataset": {
                    "referenceName": "SourcDS",
                    "type": "DatasetReference"
                },
                "name": "source1"
            }
        ],
        "sinks": [
            {
                "dataset": {
                    "referenceName": "SinkDS",
                    "type": "DatasetReference"
                },
                "name": "sink1"
            }
        ],
        "transformations": [
            {
                "name": "DerivedColumn1"
            }
        ],
        "script": "source(output(\n\t\tid as string,\n\t\tsal as string,\n\t\tgender as string,\n\t\tname as string,\n\t\tisMarried as string,\n\t\ttags as string,\n\t\taddress as string\n\t),\n\tallowSchemaDrift: true,\n\tvalidateSchema: false,\n\tignoreNoFilesFound: false) ~> source1\nsource1 derive(NewSal = round(toFloat(sal),2,2)) ~> DerivedColumn1\nDerivedColumn1 sink(allowSchemaDrift: true,\n\tvalidateSchema: false,\n\tpartitionFileNames:['customer_post_with_round.csv'],\n\tpartitionBy('hash', 1),\n\tskipDuplicateMapInputs: true,\n\tskipDuplicateMapOutputs: true) ~> sink1"
    }
}

}

请帮忙。

【问题讨论】:

  • 您能否比较两者的Sink 数据集架构。您的 sdk 案例的数据集架构似乎没有定义列标题“新萨尔”。
  • JSON 输出将数据流脚本塞进一行。您可以粘贴到脚本的可读版本中吗? ADF 数据流设计器 UI 顶部有一个脚本按钮。
  • @KrishnenduGhosh-MSFT,由于我使用的是参数化数据集,因此架构将更改为管道到管道,但我会尝试将架构绑定到 SDK 中的数据集。会尽快回复你
  • @MarkKromer,这是我在 ADF 中手动创建的,source(output( id 作为字符串,sal 作为字符串,gender 作为字符串,name 作为字符串,isMarried 作为字符串,标签作为字符串,地址作为字符串), allowSchemaDrift: true, validateSchema: false, ignoreNoFilesFound: false) ~> source1 source1 derived(NewSal = round(toFloat(sal),2,2)) ~> DerivedColumn1 DerivedColumn1 sink(allowSchemaDrift: true, validateSchema: false, partitionFileNames: ['customer_post_with_round.csv'], partitionBy('hash', 1), skipDuplicateMapInputs: true, skipDuplicateMapOutputs: true) ~> sink1
  • 这个是我通过SDK创建的,source(output( id as string, sal as string, gender as string, name as string, isMarried as string, tags as string, address as string, NewSal as string ), allowSchemaDrift: true, validateSchema: false, ignoreNoFilesFound: false) ~> source source derived(NewSal = round(toFloat(sal),2,2)) ~> DerivedColumn0 DerivedColumn0 sink(allowSchemaDrift: true, validateSchema: false, partitionFileNames :['customer_post_with_round.csv'], partitionBy('hash', 1), skipDuplicateMapInputs: true, skipDuplicateMapOutputs: true) ~> sink

标签: azure azure-data-factory dataflow azure-sdk-.net


【解决方案1】:

我在我的环境中导入了您的数据流定义,并且确实在元数据检查和映射列表中看到了列名。你能做同样的事情并将数据流脚本复制/粘贴到 UI 中,并确保你看到那里的一切都很好吗?

【讨论】:

  • 是的,这在我的映射中也是一样的。但该新列未保存在目标文件中
  • 有趣。您可以为此创建 Azure 票证吗?我想让工程部门的人来看看这是否是一个有效的错误。
猜你喜欢
  • 1970-01-01
  • 2018-10-29
  • 1970-01-01
  • 1970-01-01
  • 2019-11-07
  • 1970-01-01
  • 2019-11-17
  • 2023-03-06
  • 2020-11-09
相关资源
最近更新 更多