gpt4 book ai didi

sql - 如何在 ADF 中的附加列中设置数据类型

转载 作者:行者123 更新时间:2023-12-03 06:27:13 34 4
gpt4 key购买 nike

我需要在 ADF 的接收器中设置具有动态内容的附加列的数据类型

默认情况下它从 Json obj 中获取 nvarchar(max) 但我需要 bigInt

下面是一个 Json Obj,它创建带有附加列的表

{
"source": {
"type": "SqlServerSource",
"additionalColumns": [
{
"name": "ApplicationId",
"value": 3604509277250831000
}
],
"sqlReaderQuery": "SELECT * from Table A",
"queryTimeout": "02:00:00",
"isolationLevel": "ReadUncommitted",
"partitionOption": "None"
},
"sink": {
"type": "AzureSqlSink",
"writeBehavior": "insert",
"sqlWriterUseTableLock": false,
"tableOption": "autoCreate",
"disableMetricsCollection": false
},
"enableStaging": false,
"translator": {
"type": "TabularTranslator",
"typeConversion": true,
"typeConversionSettings": {
"allowDataTruncation": true,
"treatBooleanAsNumber": false
}
}
}

ADF 配置

enter image description here

创建表数据库后 - 具有数据类型的列

enter image description here

如果我将 Dynamic 内容转换为 Int

@int(pipeline().parameters.application.applicationId)

然后低于警告

enter image description here

请告诉我如何在 ADF 中设置数据类型

最佳答案

我也尝试了相同的方法并得到了相同的结果。

enter image description here

By default its taking nvarchar(max) from Json obj but I need bigInt

要解决此问题,当您在源数据集中添加附加列并在映射中单击导入架构时,它将导入源的架构,并为您提供附加的列架构中的列,您必须将列的类型更改为 Int64 ,如下图所示。在下图中,您可以看到 name 之后有一个额外的意思,它是一个附加列。

enter image description here

运行管道后,它将创建数据类型为 bigint 的附加列。

{
"name": "pipeline2",
"properties": {
"activities": [
{
"name": "Copy data1",
"type": "Copy",
"dependsOn": [],
"policy": {
"timeout": "0.12:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false,
"secureInput": false
},
"userProperties": [],
"typeProperties": {
"source": {
"type": "JsonSource",
"additionalColumns": [
{
"name": "name",
"value": {
"value": "@pipeline().parameters.demo.age",
"type": "Expression"
}
}
],
"storeSettings": {
"type": "AzureBlobFSReadSettings",
"recursive": true,
"enablePartitionDiscovery": false
},
"formatSettings": {
"type": "JsonReadSettings"
}
},
"sink": {
"type": "AzureSqlSink",
"writeBehavior": "insert",
"sqlWriterUseTableLock": false,
"tableOption": "autoCreate",
"disableMetricsCollection": false
},
"enableStaging": false,
"translator": {
"type": "TabularTranslator",
"mappings": [
{
"source": {
"path": "$['taskId']"
},
"sink": {
"name": "taskId",
"type": "String"
}
},
{
"source": {
"path": "$['taskObtainedScore']"
},
"sink": {
"name": "taskObtainedScore",
"type": "String"
}
},
{
"source": {
"path": "$['multiInstance']"
},
"sink": {
"name": "multiInstance",
"type": "String"
}
},
{
"source": {
"path": "$['name']"
},
"sink": {
"name": "name",
"type": "Int64"
}
}
],
"collectionReference": ""
}
},
"inputs": [
{
"referenceName": "Json1",
"type": "DatasetReference"
}
],
"outputs": [
{
"referenceName": "AzureSqlTable1",
"type": "DatasetReference"
}
]
}
],
"parameters": {
"demo": {
"type": "object",
"defaultValue": {
"name": "John",
"age": 30,
"isStudent": true
}
}
},
"annotations": []
}
}

输出:

enter image description here

关于sql - 如何在 ADF 中的附加列中设置数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75476009/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com