sql etl_使用SQL TRY函数进行ETL优化

sql etl

介绍 (Introduction)

An enterprise data warehouse ETL solution typically includes, amongst other steps, a data transformation step that converts source data from one data type into another. It is during this step that type conversion errors may occur and depending on the type of exception handling techniques implemented in the ETL solution (or lack thereof), frustration may occur for both ETL developers and DBAs when trying to identify and resolve type conversion errors. In this article we take a look at a trio of SQL TRY built-in functions that were introduced in SQL Server 2012, namely, TRY_PARSE, TRY_CAST, and TRY_CONVERT and how they could be utilized to reduce type conversion errors in ETL solutions and thereby saving developers needless troubleshooting exercise.

企业数据仓库ETL解决方案除其他步骤外,通常还包括一个数据转换步骤,该步骤将源数据从一种数据类型转换为另一种数据类型。 在此步骤中,可能会发生类型转换错误,并且取决于ETL解决方案中实现的异常处理技术的类型(或缺少此类错误处理技术),当尝试识别和解决类型转换错误时,ETL开发人员和DBA都可能会感到沮丧。 在本文中,我们介绍了SQL Server 2012中引入的三个SQL TRY内置函数,即TRY_PARSETRY_CASTTRY_CONVERT,以及如何利用它们来减少ETL解决方案中的类型转换错误并从而节省它们。开发人员无需进行故障排除练习。

挑战 (Challenge)

Likewise, the benefits of the SQL TRY functions TRY_PARSE, TRY_CAST, and TRY_CONVERT functions in an ETL solution are better realised by firstly demonstrating the existing limitations of their PARSE, CAST and CONVERT counterparts. To demonstrate the existing limitations, we make use of a football (soccer) related analogy wherein we use data from Table 1 to populate a Nominees dimension that will store the top 3 nominees for the 2016 FIFA Ballon d’Or.

同样,通过首先演示它们的PARSECASTCONVERT对应项的现有限制,可以更好地实现ETL解决方案中SQL TRY函数TRY_PARSETRY_CASTTRY_CONVERT函数的好处。 为了证明现有的局限性,我们使用与足球(足球)相关的类比,其中我们使用表1中的数据来填充“ 提名人”维度,该维度将存储2016年FIFA Ballon d'Or的前3名被提名人。

Nominee Club Jersey Number Votes Date of Birth Place of Birth Nationality Height
Antoine Griezmann Atletico Madrid 7 198 21 March 1991 Mâcon France 1.75
Lionel Messi FC Barcelona 10 316 24 June 1987 Rosario Argentina 1.70
Cristiano Ronaldo Real Madrid 7 745 05 February 1985 Funchal Portugal 1.85
被提名人 俱乐部 球衣号码 投票数 出生日期 出生地 国籍 高度
安托万·格里兹曼 马德里竞技 7 198 1991年3月21日 马Kong 法国 1.75
莱昂内尔·梅西
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值