无法在配置单元中插入有效的json,导致出现MismatchedTokenException

时间:2015-05-20 09:22:58

标签: hadoop hive

我在执行查询时收到MismatchedTokenException,如下所示:

0: jdbc:hive2://localhost:10000> INSERT INTO TABLE test_data
. . > VALUES ('s92bd2d2u922432c43', 'd93d2e03422f234',
. . > '{"Foo": "ABC","Bar": "20090101100000","Quux": {"QuuxId": 1234,"QuuxName": 
. . > "Sam it doen't matter"}}');

Error: Error while compiling statement: FAILED: ParseException line 3:88 mismatched 
input 't' expecting ) near ''{"Foo": "ABC","Bar": "20090101100000","Quux": {"QuuxId": 
1234,"QuuxName": "Sam it doen'' in statement (state=42000,code=40000)

似乎由于句子中的额外'“Sam it 重要”......它失败了。

但这是一个有效的json。如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

看起来额外的'正在从Hive的角度终止字符串,所以如果它是有效的JSON并不重要,因为它没有机会将它传递给任何要解析的东西。 JSON。您可以使用'从Hive命令解析器中转义\,类似于:

select get_json_object('{"Test":"This isn\'t a test"}','$');