【问题标题】:Azure Data Factory: Whitespace in object name for hierarchial schema mappingAzure 数据工厂:用于分层架构映射的对象名称中的空格
【发布时间】:2019-08-31 03:20:28
【问题描述】:

我正在使用复制数据活动将数据从 REST 服务复制到 Azure SQL Server。 REST 服务返回分层 JSON 响应,我正在使用模式映射将其推送到 SQL 表中。这按预期工作,除了一些名称中包含空格的属性。这是一个示例架构映射,其中最后一个属性定义了相关的属性:

"translator": {
    "type": "TabularTranslator",
    "schemaMapping": {
        "id": "id",
        "type": "type",
        "lead_verb": "lead_verb",
        "lead_action_performed": "lead_action_performed",
        "created_at": "created_at",
        "lead_id": "lead_id",
        "selected_action": "selected_action",
        "rate_type": "rate_type",
        "channel_rate_id": "channel_rate_id",
        "tenant_id": "tenant_id",
        "unit_id": "unit_id",
        "created_by_id": "created_by_id",
        "source_id": "source_id",
        "lead_changes_humanized.Quoted Rate[1]": "lead_changes_humanized"
    },
    "collectionReference": "$.lead_events"
}

这会导致以下错误:

{
    "errorCode": "2200",
    "message": "ErrorCode=UserErrorInvalidJsonArrayPathDefinition,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Error occurred when deserializing source JSON data. Please check whether the JsonPath in JsonNodeReference and JsonPathDefintion is valid.,Source=Microsoft.DataTransfer.Common,''Type=Newtonsoft.Json.JsonException,Message=Unexpected character while parsing path:  ,Source=Newtonsoft.Json,'",
    "failureType": "UserError",
    "target": "cpyCompaniesLeadEvents"
}

我试过引用路径如下:

"lead_changes_humanized.\"Quoted Rate\"[1]": "lead_changes_humanized"

并且,用单引号:

"lead_changes_humanized.'Quoted Rate'[1]": "lead_changes_humanized"

这些都会导致相同的错误。我已经使用路径验证器验证了 JSON 路径。

问题:我该如何处理这个空白?

【问题讨论】:

    标签: azure-data-factory azure-data-factory-2


    【解决方案1】:

    尝试但未能跳过复制活动验证器。请考虑以下解决方法。

    1.如果你可以完全控制rest api(名为A)的输出,尝试将lead_changes_humanized.Quoted Rate[1]返回为lead_changes_humanized.Quoted_Rate[1]。如果你不能,创建另一个你自己的rest api(名为B)并调用A rest api 在 B rest api 中,然后将输出处理为lead_changes_humanized.Quoted_Rate[1]

    2.那么你可以用这个技巧跳过验证器。如果你确实关心json密钥的原始格式,请执行下一步。

    3.在sql db端,可以将源数据中的数据复制到临时表中,并在存储过程中恢复原始格式,这样就可以将原始格式存储到准确的目标表中。我在上一个案例中所做的详细步骤:Azure Data Factory mapping 2 columns in one column 参考它。

    【讨论】:

    • 我不控制 API。理论上,我可以将原始 API 与另一个 API(例如 Azure 函数)包装在一起。然而,这似乎违背了使用数据工厂的目的。如果我要编写代码来读取 API,我不妨编写代码将其插入数据库。最后,您的回复是否意味着不支持对象名称中的空格?
    猜你喜欢
    • 2012-04-18
    • 2019-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-14
    • 2021-05-03
    • 2020-08-07
    • 2018-01-05
    相关资源
    最近更新 更多