Azure data factory 使用带有动态模式映射的ADF复制活动
我正在尝试从数据库配置表驱动columnMapping属性。管道中的第一个活动从config表中提取行。我的复制活动源是Azure blob存储中的Json文件,我的接收器是Azure SQL数据库 在复制活动中,我使用动态内容窗口设置映射。代码如下所示:Azure data factory 使用带有动态模式映射的ADF复制活动,azure-data-factory,Azure Data Factory,我正在尝试从数据库配置表驱动columnMapping属性。管道中的第一个活动从config表中提取行。我的复制活动源是Azure blob存储中的Json文件,我的接收器是Azure SQL数据库 在复制活动中,我使用动态内容窗口设置映射。代码如下所示: "translator": { "value": "@json(activity('Lookup1').output.value[0].ColumnMapping)", "type": "Expression" }
"translator": {
"value": "@json(activity('Lookup1').output.value[0].ColumnMapping)",
"type": "Expression"
}
{
"translator": {
"type": "TabularTranslator",
"mappings": [
{
"source": {
"name": "Address Number",
"type": "Int32"
},
"sink": {
"name": "address_number"
}
},
{
"source": {
"name": "Payment ID",
"type": "Int64"
},
"sink": {
"name": "payment_id"
}
},
{
"source": {
"name": "Document Number",
"type": "Int32"
},
"sink": {
"name": "document_number"
}
},
...
...
]
}
}
{
"translator": {
"type": "TabularTranslator",
"mappings": [
{
"source": {
"type": "String",
"ordinal": "1"
},
"sink": {
"name": "dateOfActivity",
"type": "String"
}
},
{
"source": {
"type": "String",
"ordinal": "2"
},
"sink": {
"name": "CampaignID",
"type": "String"
}
}
]
}
}
我的问题是,activity('Lookup1').output.value[0].ColumnMapping的值应该是什么样的
我尝试了几种不同的json格式,但复制活动似乎总是忽略它
例如,我尝试过:
{
"type": "TabularTranslator",
"columnMappings": {
"view.url": "url"
}
}
以及:
以及:
在本例中,view.url是JSON源中的列的名称,url是Azure SQL数据库中我的目标表中的列的名称。问题在于列名中的点(.)符号
据我所知,你的第一种格式应该是正确的格式。如果已经是json格式,那么您可能不需要在表达式中使用“json”函数。问题和答案之间似乎存在脱节,因此我希望提供一个更直接的答案 设置此设置时,应该有一个具有动态映射的源数据集。接收器不需要,因为我们将在映射中指定它 在复制活动中,按如下方式格式化动态json:
{
"structure": [
{
"name": "Address Number"
},
{
"name": "Payment ID"
},
{
"name": "Document Number"
},
...
...
]
}
然后,您可以按如下方式指定动态映射:
"translator": {
"value": "@json(activity('Lookup1').output.value[0].ColumnMapping)",
"type": "Expression"
}
{
"translator": {
"type": "TabularTranslator",
"mappings": [
{
"source": {
"name": "Address Number",
"type": "Int32"
},
"sink": {
"name": "address_number"
}
},
{
"source": {
"name": "Payment ID",
"type": "Int64"
},
"sink": {
"name": "payment_id"
}
},
{
"source": {
"name": "Document Number",
"type": "Int32"
},
"sink": {
"name": "document_number"
}
},
...
...
]
}
}
{
"translator": {
"type": "TabularTranslator",
"mappings": [
{
"source": {
"type": "String",
"ordinal": "1"
},
"sink": {
"name": "dateOfActivity",
"type": "String"
}
},
{
"source": {
"type": "String",
"ordinal": "2"
},
"sink": {
"name": "CampaignID",
"type": "String"
}
}
]
}
}
假设这些都是在单独的变量中设置的,那么您将希望以字符串形式发送源代码,并以json形式发送映射:
来源:@string(json(变量('str\u dyn\u structure')).structure)
映射:
@json(variables('str_dyn_translator'))。translator
VladDrak-您可以通过如下方式构建动态映射来跳过源动态定义:
"translator": {
"value": "@json(activity('Lookup1').output.value[0].ColumnMapping)",
"type": "Expression"
}
{
"translator": {
"type": "TabularTranslator",
"mappings": [
{
"source": {
"name": "Address Number",
"type": "Int32"
},
"sink": {
"name": "address_number"
}
},
{
"source": {
"name": "Payment ID",
"type": "Int64"
},
"sink": {
"name": "payment_id"
}
},
{
"source": {
"name": "Document Number",
"type": "Int32"
},
"sink": {
"name": "document_number"
}
},
...
...
]
}
}
{
"translator": {
"type": "TabularTranslator",
"mappings": [
{
"source": {
"type": "String",
"ordinal": "1"
},
"sink": {
"name": "dateOfActivity",
"type": "String"
}
},
{
"source": {
"type": "String",
"ordinal": "2"
},
"sink": {
"name": "CampaignID",
"type": "String"
}
}
]
}
}
非常感谢。JSONPath表达式确实是我的问题所在。不幸的是,我现在意识到JSONPath表达式不支持“动态内容”选项,因此我认为我无法从配置数据库中驱动该选项:(对于JSON路径不支持动态内容,我认为这可能是一个UI问题。您可以直接尝试JSON代码。@FangLiu这不是UI问题。该产品存在一个错误,模式映射列名忽略了表达式语言。很难说您是在问问题还是提出不同的答案:-)如果这是一个答案,您可能需要重新表述上述内容,以免将其误认为问题并删除。否则,请打开一个新线程,请参阅。这是一个建议的解决方案,可以省去您对源代码的动态架构定义的麻烦。@请提供复制活动的完整JSON块的示例?我的un我的理解是,结构部分应该是数据集定义的一部分,但我看不到任何动态添加它的方法。@Jon.Mozley您需要将translator块保存在变量中,并将动态内容作为answer
@json(variables('str_dyn_translator')中显示的最后一行放入.translator
。不需要其他东西。在我的情况下,我正在从数据库设置映射变量。