You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@phoenix.apache.org by wuyang <wu...@qq.com> on 2014/10/09 03:59:26 UTC
回复: issue in like expression in which contains Chinese characters
The version is 4.1.0
Thanks for your reply
------------------
Email: wuyang630@qq.com
------------------ 原始邮件 ------------------
发件人: "James Taylor";<ja...@apache.org>;
发送时间: 2014年10月8日(星期三) 晚上11:44
收件人: "user@phoenix.apache.org"<us...@phoenix.apache.org>;
主题: Re: issue in like expression in which contains Chinese characters
That's a bug - please file a JIRA. What version of Phoenix are you using?Thanks,
James
On Wednesday, October 8, 2014, wuyang <wu...@qq.com> wrote:
Hi,
When I use like expression in SELECT query. It works well when I put Chinese characters in LIKE expression on NONE PRIMARY KEY columns . BUT when I put them in LIKE expression on PRIMARY KEY , it occurs an Exception:
select * from "test3" where PK like '中%';
org.apache.phoenix.schema.IllegalDataException: CHAR types may only contain single byte characters (中)
at org.apache.phoenix.schema.PDataType$2.toBytes(PDataType.java:216)
at org.apache.phoenix.compile.WhereOptimizer$KeyExpressionVisitor.visitLeave(WhereOptimizer.java:829)
at org.apache.phoenix.compile.WhereOptimizer$KeyExpressionVisitor.visitLeave(WhereOptimizer.java:349)
at org.apache.phoenix.expression.LikeExpression.accept(LikeExpression.java:269)
at org.apache.phoenix.compile.WhereOptimizer.pushKeyExpressionsToScan(WhereOptimizer.java:117)
at org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:107)
at org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:107)
at org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:324)
....
the type of PRIMARY KEY and ONE PRIMARY KEY columns are all VARCHAR
I looked up the code where the Exception threw. The exception would throw out when
byte[] b = VARCHAR.toBytes(object);
if (b.length != ((String) object).length()) {
throw new IllegalDataException("CHAR types may only contain single byte characters (" + object + ")");
}
actually, Chinese (or other non-Latin) characters will never meet the condition b.length == ((String) object).length() . Default encode method is UTF-8.
So, is there something I missed when I use the LIKE expression or some BUG ?
Thank you all
------------------
Email: wuyang630@qq.com