首页 文章

是什么导致USQL中的JSON反序列化达到字符串限制?

提问于
浏览
0

我有许多(500)JSON文件,我正在使用USQL在ADLA中处理,我做的第一件事就是使用Microsoft.Analytics.Samples.Formats.Json JsonExtractor从每个文件中提取数据 . 大多数(80%?)的文件都很好,包括最大的文件,但有些失败了,我不知道为什么 . 这是失败的代码的最小示例:

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 回答

  • 2

    您遇到的错误是其中一个字符串列超出了允许的最大字符串大小 . 允许的最大字符串大小为128KB . 此时你有两个选择1.要么编写自己的json提取器,它能够将列拆分为两列2.使用byte []数据类型 .

相关问题