azure - Azure 数据工厂无法将字符串列值转换为日期时间
问题描述
我正在使用现有的 ADF 管道将数据从 blob 复制到 sql。我的源数据有一个像“20000101”这样的列值。当 ADF 尝试将其从字符串转换为 dateTime 格式时出现错误。我正在使用像“dateTimeFormat”这样的json翻译器:“yyyy-MM-dd HH:mm:ss.fff”。但最终还是会出现错误,因为“转换值 '20000101' 时发生异常无法将字符串转换为日期时间类型。
有什么建议吗?
注意:我只能通过 json 映射来处理这个问题。无法编辑现有管道。这里有什么可能吗?
解决方案
无论 blob 中的数据还是本地 NFS 中的数据,数据工厂副本活动都无法将“20000101”转换为日期时间。即使我们将其设置为 DateTime 列。
"errorCode": "2200",
"message": "ErrorCode=TypeConversionFailure,Exception occurred when converting value '20000101' for column name 'dd' from type 'String' (precision:, scale:) to type 'DateTime' (precision:, scale:). Additional info: String was not recognized as a valid DateTime."
为此,我们必须在数据流中使用DerivedColumn进行一些数据转换:
表达:
toTimestamp(toDate(concat(substring(dd,0, 4), '-',substring(dd,5, 2),'-',substring(dd,7, 2))))
然后它可能会映射到您的水槽表。
推荐阅读
- c - C中结构的通用排序函数
- sql-server - 每天在特定时间发生不必要的自动批量更新正在从所有订阅者上传 SQL Server 合并复制
- python - 想知道如何有效地编码投币器
- python - 如何使用 python-slackclient 读取松弛通道消息
- sql - 如何插入表格?
- powershell - how to find and store filenames in a list with PowerShell?
- java - 如何在 Groovy/JAVA POI 中读取 .xls 文件的行值
- jquery - 过滤元素jQuery的乘法选项
- node.js - 打字稿装饰器类中的“this”关键字不起作用
- javascript - express.js get 方法无法获取 req.body 值