2016-12-15 38 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#語義。