2017-05-24 21 views
0

我有許多(500+)JSON文件,我正在使用USQL在ADLA中處理,我做的第一件事是從每個提取數據中使用Microsoft.Analytics.Samples.Formats.Json JsonExtractor。大多數(80%?)的文件都很好,包括最大的文件,但有些文件卻失敗了,我不知道爲什麼。下面是失敗的代碼的一個小例子:什麼導致USQL中的JSON反序列化達到字符串限制?

REFERENCE ASSEMBLY [Newtonsoft.Json]; 
REFERENCE ASSEMBLY [Microsoft.Analytics.Samples.Formats]; 

DECLARE @input string="adl://abc.azuredatalakestore.net/data/whatever.json"; 

DECLARE @out string="adl://out.csv"; 

USING Microsoft.Analytics.Samples.Formats.Json; 

@data = 
EXTRACT SourceUrl string, 
     Title string, 
     Guest string, 
     PublishDate DateTime, 
     TranscriptionSections string, 
     Categories string, 
     filename string 
FROM @input 
USING new JsonExtractor(); 

OUTPUT @data 
TO @out 
USING Outputters.Tsv(outputHeader : true); 

下面是從Azure中的錯誤:

**Inner Error:** 
ERROR 
E_RUNTIME_USER_STRINGTOOBIG 

MESSAGE 
String size 132991 exceeds the maximum allowed size of 131072. 

**Outer Error:** 
DESCRIPTION 
Vertex failure triggered quick job abort. Vertex failed: SV1_Extract_Partition[0] with error: Vertex user code error. 
RESOLUTION 
DETAILS 

Vertex SV1_Extract_Partition[0].v1 {8F874C31-C803-4C9A-9C3F-B594A62D7EAC} failed 

Error: 
Vertex user code error 

exitcode=CsExitCode_StillActive Errorsnippet= 
ERROR 
VertexFailedFast 
MESSAGE 
Vertex failed with a fail-fast error 

以下是我正在使用的文件的例子:

{ 
"SourceUrl":"http://www.unittest.org/test.html", 
"Title":"Unit Test File", 
"Guest":"Unit Test Guest", 
"PublishDate":"2017-05-15T00:00:00", 
"TranscriptionSections":[ 
    { 
    "SectionStartTime":"00:00:03", 
    "Sentences":[ 
     { 
     "Text":"Intro." 
     }, 
     { 
     "Text":"Sentence one" 
     }, 
     { 
     "Text":"Sentence two" 
     } 
    ] 
}, 
{ 
    "SectionStartTime":"00:04:46", 
    "Sentences":[ 
     { 
     "Text":"Sentence three" 
     }, 
     { 
     "Text":"Sentence four" 
     } 
    ] 
} 
], 
"Categories":null 
} 

我後首先執行此操作,然後運行另一個USQL語句將TranscriptionSections字符串反序列化爲更多行。也許這就是錯誤,並且有一種方法可以在一個語句中完全壓扁JSON文件

回答

1

您遇到的錯誤是字符串列之一超過了最大允許的字符串大小。允許的最大字符串大小是128KB。此時,您有兩種選擇:1.編寫自己的json提取器,使其能夠將列分成兩列2.使用byte []數據類型。