Error: ERROR 203 (22005): Type mismatch. VARCHAR and INTEGER for PROGRESS (state=22005,code=203)
org.apache.phoenix.schema.TypeMismatchException: ERROR 203 (22005): Type mismatch. VARCHAR and INTEGER for PROGRESS
at org.apache.phoenix.schema.TypeMismatchException.newException(TypeMismatchException.java:53)
at org.apache.phoenix.compile.ExpressionCompiler.convertToRoundExpressionIfNeeded(ExpressionCompiler.java:584)
at org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:607)
at org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:132)
at org.apache.phoenix.parse.CastParseNode.accept(CastParseNode.java:62)
at org.apache.phoenix.compile.ProjectionCompiler.compile(ProjectionCompiler.java:416)
at org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:561)
at org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:507)
at org.apache.phoenix.compile.QueryCompiler.compileSelect(QueryCompiler.java:202)
at org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:157)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:417)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:391)
at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:277)
at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:267)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:266)
at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1463)
at sqlline.Commands.execute(Commands.java:822)
at sqlline.Commands.sql(Commands.java:732)
at sqlline.SqlLine.dispatch(SqlLine.java:813)
at sqlline.SqlLine.begin(SqlLine.java:686)
at sqlline.SqlLine.start(SqlLine.java:398)
at sqlline.SqlLine.main(SqlLine.java:291)
解决:
Phoenix varchar转integer
0: jdbc:phoenix:***> select PROGRESS,TO_NUMBER(PROGRESS,'###') from CLUSTER_APPS limit 10;
+-----------+----------------------+
| PROGRESS | TO_NUMBER(PROGRESS) |
+-----------+----------------------+
| 100 | 1E+2 |
| 100 | 1E+2 |
| 100 | 1E+2 |
| 100 | 1E+2 |
| 100 | 1E+2 |
| 100 | 1E+2 |
| 100 | 1E+2 |
| 100 | 1E+2 |
| 100 | 1E+2 |
| 100 | 1E+2 |
+-----------+----------------------+
变成科学计数法,查找资料,发现将其改成bigint可以解决
0: jdbc:phoenix:***,> select PROGRESS,cast(TO_NUMBER(PROGRESS) as bigint) from CLUSTER_APPS limit 10;
+-----------+-------------------------------------------+
| PROGRESS | TO_BIGINT(ROUND(TO_NUMBER(PROGRESS), 0)) |
+-----------+-------------------------------------------+
| 100 | 100 |
| 100 | 100 |
| 100 | 100 |
| 100 | 100 |
| 100 | 100 |
| 100 | 100 |
| 100 | 100 |
| 100 | 100 |
| 100 | 100 |
| 100 | 100 |
+-----------+-------------------------------------------+
参考: