Hi, I googled it, and here is the answer:

https://stackoverflow.com/questions/1250079/how-to-escape-single-quotes-within-single-quoted-strings

I verified it works:

curl -X POST --user ADMIN:KYLIN -H "Content-Type: application/json" -d '{
"sql":"select count(*) from kylin_sales where
LSTG_FORMAT_NAME='"'"'Others'"'"'", "project":"learn_kylin" }'
http://sandbox:7070/kylin/api/query



在 2017年12月14日 上午10:14,weilinzi <[email protected]>写道:

> 您好,打扰了,麻烦问个问题,使用RESTful api查询,如果where条件中key对应的value为字符串类型,查询报错,请问下是什么原因?
> 实例:
> curl -b ./cookiefile.txt -H 'Content-Type: application/json' -d
> '{"sql":"select count(distinct user_id) yuekanCount from
> bidb.ods_resblock_look_about where resblock_id='2411048630942'",
> "offset":0,
> "limit":1,"acceptPartial":false, "project":"learn_kylin"}'
> http://10.16.45.174:7070/kylin/api/query | jq .
>
> 其中sql查询为:
> "select count(distinct user_id) yuekanCount from
> bidb.ods_resblock_look_about where resblock_id = '2411048630942'",
> 其中resblock_id的值为字符串'2411048630942',执行报错如下:
> Error while executing SQL \"select count(distinct user_id) yuekanCount from
> bidb.ods_resblock_look_about where resblock_id=2411048630942 LIMIT 1\":
> while resolving method 'eq[class java.lang.String, long]'
> 明显解析时把单引号”吃掉了“,然后我使用\'转义,又报:
> Could not read document: Unrecognized character escape '2' (code 50)\n at
> [Source: java.io.PushbackInputStream@47bd0a81; line: 1, column: 106]
> (through reference chain:
> org.apache.kylin.rest.request.SQLRequest[\"sql\"]);
> 明显转义的又有问题,有点不知所措,现在只能先读源码了,看下处理逻辑和kylin的sql解析引擎工作机制,
> 但先把问题先反馈到这里,又遇到的也麻烦回复下,非常感谢!
>
>
> --
> Sent from: http://apache-kylin.74782.x6.nabble.com/
>



-- 
Best regards,

Shaofeng Shi 史少锋

Reply via email to