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_PARSE , TRY_CAST和TRY_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.
同样,通过首先演示它们的PARSE , CAST和CONVERT对应项的现有限制,可以更好地实现ETL解决方案中SQL TRY函数TRY_PARSE , TRY_CAST和TRY_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 |
莱昂内尔·梅西 |