2016-12-15 33 views
0

转换对于我所有的CSV源时无效字符,我提取设置为:U型SQL - 顶点失败:试图列数据

USING Extractors.Csv(silent:true,skipFirstNRows:1); 
- silent is set to true to ignore bad rows 
- skipFirstNRows is set to 1 to skip the header row 

但奇怪的是,我仍然得到这个错误:

HEX: "223122" Invalid character when converting input record. 
Position: line 2, column index: 7, column name: "IncludeOnCheck". 
Invalid character when attempting to convert column data. 

数据(样本行&行中的问题)

29,1,10,DC Tax,DC Tax,0.100000,0.00,1,1,1,2014-07-12 21:34:52.4200000 +00:00,NULL,NULL,0,-1,0,0,0,NULL,NULL,NULL,1031,NULL,0,0 
33,4,10,Amenities,Amenities,1.000000,0.00,1,0,1,2014-07-12 21:34:54.1330000 +00:00,NULL,NULL,0,-1,0,0,0,NULL,NULL,NULL,1031,NULL,0,0 

列定义

EXTRACT AncillaryAmountTypeID int, 
     AncillaryAmountCategoryID int, 
     CustomerID int, 
     CheckTitle string, 
     ReportTitle string, 
     Percentage decimal, 
     FixedAmount decimal, 
     IncludeOnCheck bool, 
     AutoCalculate bool, 
     StoreAtCheckLevel bool?, 
     DateTimeModified DateTime?, 
     CheckTitleToken Guid?, 
     ReportTitleToken Guid?, 
     DeletedFlag bool, 
     MaxUsageQty int?, 
     ApplyToBasePriceOnly bool?, 
     Exclusive bool, 
     IsItem bool, 
     MinValue decimal, 
     MaxValue decimal, 
     ItemGroupID int?, 
     LocationID int, 
     ApplicationOrder int?, 
     RequiresReason bool, 
     Exemptable bool? 

问题

  1. 为什么会出现转换错误,当我指定沉默是真的, 应该忽略任何坏行,对吧?
  2. 它试图转换的字符是“1”,并转换为布尔值。 U-SQL或ADLA无法理解或将1和0转换为布尔值吗?

回答

0

是的,我也观察到这种行为,它不会自动将0或1转换为bool。如果你想这样做,那么将它作为int提取出来,然后使用Convert.ToBoolean方法将其转换为bool。

我认为无声开关仅在所提供的模式与实际数据的模式之间存在不匹配时才起作用。

0

Heresilent参数的文档:如果您的目标类型为空,它只会忽略转换错误。否则它仍然错误。

此外,我们正在按照here所述的转换遵循C#语义。