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