首页 文章

将JSON模式插入U-SQL表

提问于
浏览
1

我想在DataLake Analysts工具中为我的U-SQL表插入JSON模式 . 这是我的JSON架构

DECLARE @json string=  "{
        "definitions": {},
        "$schema": "http://json-schema.org/draft-06/schema#",
        "$id": "http://getIQOS.com/IQOSAbandonedCartV1.json",
        "title": "CE:I:ORD:ABC",
        "type": "object",
        "properties": {
            "altriaOrchestrated": {
                "$id": "/properties/altriaOrchestrated",
                "type": "integer",
                "title": "Altria Orchestrated",
                "description": "Specifies whether the AT object is being called by Core Services (1) or from an outside source (0)",
                "default": 0,
                "enum": [
                    0, 1
                ],
                "examples": [
                    0, 1
                ],
                "minimum": 0,
                "maximum": 1
            },
        "required": [
            "altriaOrchestrated",
            "initiativeName",
            "date",
            "inventory"
        ]
     }"

我收到以下错误,无法理解它是什么错误 . 由于这个问题,我的开发停止了 .

AGG ALL AND ARRAY BETWEEN BIGINT BIT BINARY BY COLUMNSET CREATED CSHARP CURRENT DATETIME DATETIME2 DECIMAL EXISTS FILE FLOAT FOLLOWING GROUP IN INT IS LENGTH LCID MAP MAX MODIFIED MONEY NULL NVARCHAR OR OVER PARTITION PRECEDING REAL SMALLINT SQL STRUCT TINYINT UNBOUNDED UNIQUEIDENTIFIER VARBINARY VARCHAR WITHIN string-literal numeric-literal character-literal punctuation-mark identifier quoted-identifier reserved-identifier variable system-variable '[' ']' '(' '{' '}' '=' '.' '*' ':' '?' '<' '>'

1 回答

  • 0

    根据我的测试,你可以利用双引号反斜杠来声明你的json字符串参数 .

    DECLARE @json string ="{"+
            "\"definitions\": {},"+
            "\"$schema\": \"http://json-schema.org/draft-06/schema#\","+
            "\"$id\": \"http://getIQOS.com/IQOSAbandonedCartV1.json\","+
            "\"title\": \"CE:I:ORD:ABC\","+
            "\"type\": \"object\","+
            "\"properties\": {"+
                "\"altriaOrchestrated\": {}"+
            "}"+
    "}";
    

    此外,您可以利用Verbatim C#字符串文字,通过在字符串的起始双引号前面加上@字符来简化对此类字符的处理 . 对于你的json字符串,你可以声明如下:

    DECLARE @json string =@"{
            ""definitions"": {},
            ""$schema"": ""http://json-schema.org/draft-06/schema#"",
            ""$id"": ""http://getIQOS.com/IQOSAbandonedCartV1.json"",
            ""title"": ""CE:I:ORD:ABC"",
            ""type"": ""object"",
            ""properties"": {
               ""altriaOrchestrated"": {}
            }
    }";
    

    Note:

    U-SQL中字符串类型的列的最大大小为128kB(基于以UTF-8编码表示的字符串值的字节数) .

    您可以关注的详细信息Textual Types and Literals .

相关问题