[ https://issues.apache.org/jira/browse/PHOENIX-1938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14520882#comment-14520882 ]
ASF GitHub Bot commented on PHOENIX-1938: ----------------------------------------- GitHub user AakashPradeep opened a pull request: https://github.com/apache/phoenix/pull/81 PHOENIX-1938 Like operator should throw proper exception when it is used with data type other then Varcahr and Char LIKE operator should be supported only for Varchar and Char and it should throw SQLException with SQLExceptionCode.TYPE_NOT_SUPPORTED_FOR_OPERATOR for any other data type. Postgres specification : http://www.postgresql.org/docs/8.3/static/functions-matching.html Oracle specification: http://docs.oracle.com/cd/B12037_01/server.101/b10759/conditions016.htm @JamesRTaylor @twdsilva Can you please review this. You can merge this pull request into a Git repository by running: $ git pull https://github.com/AakashPradeep/phoenix bugfix Alternatively you can review and apply these changes as the patch at: https://github.com/apache/phoenix/pull/81.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #81 ---- commit fd615a7c267e58b2b4a4a10c595c1aeababbdb72 Author: Aakash <email2aak...@gmail.com> Date: 2015-04-30T04:41:00Z PHOENIX-1938 Like operator should throw proper exception when it is used with data type other then Varcahr and Char commit 5b9d5d5d5bd7754da3e8023b5a005be2590f6abe Author: Aakash <email2aak...@gmail.com> Date: 2015-04-30T04:47:42Z PHOENIX-1938 Like operator should throw proper exception when it is used with data type other then Varcahr and Char commit ad04526922193c99314b91c9fe21abe2d8759035 Author: Aakash <email2aak...@gmail.com> Date: 2015-04-30T05:13:22Z PHOENIX-1938 Like operator should throw proper exception when it is used with data type other then Varcahr and Char- IT test ---- > Like operator should throw proper exception when it is used with data type > other then Varcahr and Char > ------------------------------------------------------------------------------------------------------ > > Key: PHOENIX-1938 > URL: https://issues.apache.org/jira/browse/PHOENIX-1938 > Project: Phoenix > Issue Type: Bug > Affects Versions: 4.4.0 > Reporter: Aakash Pradeep > Assignee: Aakash Pradeep > Priority: Minor > > Currently when "Like" operator is used with Integer it throws > ClassCastException instead of Saying that it is not supported. > select * from <Table_Name> where 1 like 1; > java.lang.ClassCastException: java.lang.Integer cannot be cast to > java.lang.String > at > org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:471) > at > org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:134) > at > org.apache.phoenix.parse.LikeParseNode.accept(LikeParseNode.java:62) > at > org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:130) > at > org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:100) > at > org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:496) > at > org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:449) > at > org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:161) > at > org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:344) > at > org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:327) > at > org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:237) > at > org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:232) > at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53) > at > org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:231) > at > org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1097) > at sqlline.Commands.execute(Commands.java:822) > at sqlline.Commands.sql(Commands.java:732) > at sqlline.SqlLine.dispatch(SqlLine.java:808) > at sqlline.SqlLine.begin(SqlLine.java:681) > at sqlline.SqlLine.start(SqlLine.java:398) > at sqlline.SqlLine.main(SqlLine.java:292) > select * from JSON_PK where '1' like 1; > Error: ERROR 203 (22005): Type mismatch. VARCHAR and INTEGER for '1' LIKE 1 > (state=22005,code=203) > org.apache.phoenix.schema.TypeMismatchException: ERROR 203 (22005): Type > mismatch. VARCHAR and INTEGER for '1' LIKE 1 > at > org.apache.phoenix.schema.TypeMismatchException.newException(TypeMismatchException.java:53) > at > org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:462) > at > org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:134) > at > org.apache.phoenix.parse.LikeParseNode.accept(LikeParseNode.java:62) > at > org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:130) > at > org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:100) > at > org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:496) > at > org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:449) > at > org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:161) > at > org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:344) > at > org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:327) > at > org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:237) > at > org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:232) > at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53) > at > org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:231) > at > org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1097) > at sqlline.Commands.execute(Commands.java:822) > at sqlline.Commands.sql(Commands.java:732) > at sqlline.SqlLine.dispatch(SqlLine.java:808) > at sqlline.SqlLine.begin(SqlLine.java:681) > at sqlline.SqlLine.start(SqlLine.java:398) > at sqlline.SqlLine.main(SqlLine.java:292) > 0: jdbc:phoenix:localhost:2181:/hbase> select * from JSON_PK where 1 like '1'; > Error: ERROR 203 (22005): Type mismatch. INTEGER and VARCHAR for 1 LIKE '1' > (state=22005,code=203) > org.apache.phoenix.schema.TypeMismatchException: ERROR 203 (22005): Type > mismatch. INTEGER and VARCHAR for 1 LIKE '1' > at > org.apache.phoenix.schema.TypeMismatchException.newException(TypeMismatchException.java:53) > at > org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:462) > at > org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:134) > at > org.apache.phoenix.parse.LikeParseNode.accept(LikeParseNode.java:62) > at > org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:130) > at > org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:100) > at > org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:496) > at > org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:449) > at > org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:161) > at > org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:344) > at > org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:327) > at > org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:237) > at > org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:232) > at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53) > at > org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:231) > at > org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1097) > at sqlline.Commands.execute(Commands.java:822) > at sqlline.Commands.sql(Commands.java:732) > at sqlline.SqlLine.dispatch(SqlLine.java:808) > at sqlline.SqlLine.begin(SqlLine.java:681) > at sqlline.SqlLine.start(SqlLine.java:398) > at sqlline.SqlLine.main(SqlLine.java:292) -- This message was sent by Atlassian JIRA (v6.3.4#6332)