phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "wuyang" <>
Subject issue in like expression in which contains Chinese characters
Date Wed, 08 Oct 2014 08:10:39 GMT

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(‍
at org.apache.phoenix.compile.WhereOptimizer$KeyExpressionVisitor.visitLeave(‍
at org.apache.phoenix.compile.WhereOptimizer$KeyExpressionVisitor.visitLeave(‍
at org.apache.phoenix.expression.LikeExpression.accept(   ‍
at org.apache.phoenix.compile.WhereOptimizer.pushKeyExpressionsToScan(‍
at org.apache.phoenix.compile.WhereCompiler.compile(  ‍
at org.apache.phoenix.compile.WhereCompiler.compile(              
 at org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(‍


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


View raw message