The version is 4.1.0

Thanks for your reply


------------------

Email: [email protected]


 




------------------ 原始邮件 ------------------
发件人: "James Taylor";<[email protected]>;
发送时间: 2014年10月8日(星期三) 晚上11:44
收件人: "[email protected]"<[email protected]>; 

主题: 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 <[email protected]> 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: [email protected]

Reply via email to