作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在解析存储为表中的行的 json
它解析具有简单字符串但不包含文件路径的 json 行
例如:
{
"CustomerID": "C101",
"BillLocation": "C:\Customer\Files\C101\1.txt",
"CustomerLocation": "NY",
"Company":"XYZ"
}
我尝试了在线 json 验证器,它在账单位置给出了错误,但是当将\附加到所有存在\的地方时,它验证了,像这样 C:\\Customer\\Files\C101\\1.txt
select a.CustomerID,
a.BillLocation,
a.CustomerLocation,
Company from db.jsontable b
LATERAL VIEW json_tuple(b.json,'CustomerId','BillLocation','CustomerLocation','CustomerLocation') a as CustomerId,BillLocation,CustomerLocation,CustomerLocation
最佳答案
select a.*
from jsontable b
lateral view
json_tuple
(
regexp_replace(b.json,'\\\\','\\\\\\\\')
,'CustomerID','BillLocation','CustomerLocation','CustomerLocation','Company'
) a as CustomerId,BillLocation,CustomerLocation,CustomerLocation,Company
+------------+------------------------------+------------------+---------+
| customerid | billlocation | customerlocation | company |
+------------+------------------------------+------------------+---------+
| C101 | C:\Customer\Files\C101\1.txt | NY | XYZ |
+------------+------------------------------+------------------+---------+
关于Json_tuple 表示 hive 中的无效 json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43847196/
我已将配置单元版本从 0.20 更新到 0.13.1。 我正在使用下表和查询从 S3 中提取 json。 表: > CREATE EXTERNAL TABLE in_app_logs (
我正在解析存储为表中的行的 json 它解析具有简单字符串但不包含文件路径的 json 行 例如: { "CustomerID": "C101", "BillLocation": "C
我有一个这样的json文件 {"client":[{"name":"xyz","id":"123"}]} 我已经创建了配置单元外部表 create external table clients (cl
我是一名优秀的程序员,十分优秀!