【发布时间】:2021-02-19 02:33:23
【问题描述】:
我正在使用以下数据集来测试映射数据流:https://github.com/fivethirtyeight/data/tree/master/avengers。
我的数据流很简单;一个源(AzureDataLakeStorageGen2 上的分隔文件)移动到一个接收器(AzureDataLakeStorageGen2 上的镶木地板文件)。我已经使用导入投影功能来获取我的架构并设置值“验证架构”。我得到一个假设看起来是正确数据类型的投影。值得注意的是,指向此源的数据集将所有列指定为字符串,因此数据集的导入架构与源数据流转换的导入架构之间显然存在脱节。 看到这张图片。 Dataflow Source Projection
如果我尝试使用“验证架构”选项,我会遇到问题。我得到的第一个问题是我在任何不是字符串的数据类型上都收到错误。当使用“数据预览”或在管道中运行数据流时,例如Error: at Source 'AvengersHeader': Column 'Appearances has incompatible types( Found: StringType, Required: ShortType)。我以为这是由于标题行,但是使用 Skip line count 将其排除在外,值为 1 会给我一个新错误,例如Error: at Source 'AvengersHeader': Missing column 'URL.
来源documentation 状态
验证架构:如果选择验证架构,如果传入的源数据与数据集的定义架构不匹配,则数据流将无法运行。
我原以为这会查看数据类型,但现在想知道这是否只是提供的列。
对于水槽 documentation 我说
验证架构:如果选择了验证架构,则如果在源投影中未找到传入源架构的任何列,或者数据类型不匹配,则数据流将失败.使用此设置强制源数据符合您定义的投影的合同。在数据库源场景中表明列名或类型已更改很有用。
我注意到几点:
- 这指定了源中的更改
- 它指定源类型不匹配,但似乎没有这样做。
然后我的问题是,任何人都可以指出详细说明预期行为和用法的特定文档吗?无论是官方 MS 文档还是博客,我都不挑剔。如果有人想投入他们的 2 美分/便士,那也没关系。
进一步看,我已经探索了派生列,然后是条件拆分,但这可能非常耗时:
`iif(
isNull(toInteger(Appearances))==true()
|| isNull(toBoolean(case(or({Current?}=='', isNull({Current?})) == true(), 'NO',{Current?})) )== true()
|| isNull(toShort(Year)) == true()
|| isNull( toShort({Years since joining}))== true()
|| isNull(toBoolean(case(or(Death1=='', isNull(Death1)) == true(), 'NO',Death1)) )== true()
|| isNull(toBoolean(case(or(Return1=='', isNull(Return1)) == true(), 'NO',Return1)) )== true()
|| isNull(toBoolean(case(or(Death2=='', isNull(Death2)) == true(), 'NO',Death2)) )== true()
|| isNull(toBoolean(case(or(Return2=='', isNull(Return2)) == true(), 'NO',Return2)) )== true()
|| isNull(toBoolean(case(or(Death3=='', isNull(Death3)) == true(), 'NO',Death3)) )== true()
|| isNull(toBoolean(case(or(Return3=='', isNull(Return3)) == true(), 'NO',Return3)) )== true()
|| isNull(toBoolean(case(or(Death4=='', isNull(Death4)) == true(), 'NO',Death4)) )== true()
|| isNull(toBoolean(case(or(Return4=='', isNull(Return4)) == true(), 'NO',Return4)) )== true()
|| isNull(toBoolean(case(or(Death5=='', isNull(Death5)) == true(), 'NO',Death5)) )== true()
|| isNull(toBoolean(case(or(Return5=='', isNull(Return5)) == true(), 'NO',Return5)) )== true()
,1,0
)`
条件拆分转换查找符合条件的行并将其写入,在别处写入格式错误的行。
虽然这可行,但我不确定我是否会这样做,而不是使用 _corrupt_record 的数据框感觉它会更容易地解决我的问题,提出为什么我要尝试在映射数据流中进行验证?
【问题讨论】:
标签: azure-data-factory-2 azure-synapse azure-data-flow