azure - 将 JSON 模式插入 U-SQL 表
问题描述
我想在 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 '[' ']' '(' '{' '}' '=' '.' '*' ':' '?' '<' '>'
解决方案
根据我的测试,您可以利用双引号、反斜杠如下声明您的 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"": {}
}
}";
笔记:
在 U-SQL 中,字符串类型的列的最大大小为 128kB(基于以 UTF-8 编码表示的字符串值的字节数)。
您可以遵循Textual Types and Literals的详细信息。
推荐阅读
- c# - 如何在 .NET Core 3.1 的子线程中设置主线程 CultureInfo.CurrentUICulture 的值?
- r - 使用 tidyverse 清理排名选择调查
- python - 使用 Json 内容抓取网站会导致值错误
- javascript - 移动设备与桌面上的幻灯片显示不正确
- django - Django DRF - api webview中的“隐藏用户”(必填字段)
- firebase - 选项卡打开但不在焦点时出现 Firebase 通知问题
- python - raise ValueError("未转换的数据仍然存在:%s" % ValueError:未转换的数据仍然存在:
- amazon-web-services - MEAN 堆栈应用程序的 AWS 结构
- react-router - @expo/vector-icon 未加载 Android 设备
- html - 如何精确移动弹性项目?