Reputation: 179
I am getting MismatchedTokenException on executing query as below:
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)
It seems due to extra ' in sentence "Sam it doen't matter".. it's failing.
But this is a valid json. How this can be resolved ?
Upvotes: 1
Views: 297
Reputation: 2486
It looks like that extra '
is terminating the string from Hive's perspective, so it doesn't matter if it's valid JSON because it doesn't get a chance to pass it along to whatever is going to parse the JSON. You can escape the '
from the Hive command parser using a \
similar to:
select get_json_object('{"Test":"This isn\'t a test"}','$');
Upvotes: 1