lizhuangs opened a new issue #9027:
URL: https://github.com/apache/shardingsphere/issues/9027
### table
```
CREATE TABLE `site_flow_bandwidth` (
`id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`flow_id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci
NULL DEFAULT NULL,
`detail` json NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `uq_flow`(`flow_id`) USING BTREE
)
```
### test data
```
INSERT INTO `site_flow_bandwidth`(`id`, `flow_id`, `detail`) VALUES
('1b100s1', '1f100s1', '{\"0\": \"1.0\", \"1\": \"1.0\", \"2\": \"1.0\", \"3\":
\"1.0\", \"4\": \"1.0\", \"5\": \"1.0\"');
INSERT INTO `site_flow_bandwidth`(`id`, `flow_id`, `detail`) VALUES
('1b100s10', '1f100s10', '{\"0\": \"1.0\", \"1\": \"1.0\", \"2\": \"1.0\",
\"3\": \"1.0\", \"4\": \"1.0\", \"5\": \"1.0\"');
INSERT INTO `site_flow_bandwidth`(`id`, `flow_id`, `detail`) VALUES
('1b100s100', '1f100s100', '{\"0\": \"1.0\", \"1\": \"1.0\", \"2\": \"1.0\",
\"3\": \"1.0\", \"4\": \"1.0\", \"5\": \"1.0\"');
INSERT INTO `site_flow_bandwidth`(`id`, `flow_id`, `detail`) VALUES
('1b100s1000', '1f100s1000', '{\"0\": \"1.0\", \"1\": \"1.0\", \"2\": \"1.0\",
\"3\": \"1.0\", \"4\": \"1.0\", \"5\": \"1.0\"');
INSERT INTO `site_flow_bandwidth`(`id`, `flow_id`, `detail`) VALUES
('1b100s101', '1f100s101', '{\"0\": \"1.0\", \"1\": \"1.0\", \"2\": \"1.0\",
\"3\": \"1.0\", \"4\": \"1.0\", \"5\": \"1.0\"');
```
### sql
it works well in navicat,but can not work with shardingsphere
```
SELECT
sum( detail -> '$.\"0\"' ), sum( detail -> '$.\"1\"' ), sum( detail ->
'$.\"2\"' )
FROM
site_flow_bandwidth
WHERE
id LIKE '1b100%'
```
### the error msg
```
java.lang.NullPointerException: null
at
org.apache.shardingsphere.sql.parser.mysql.visitor.MySQLVisitor.visitPredicate(MySQLVisitor.java:315)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.MySQLVisitor.visitPredicate(MySQLVisitor.java:121)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$PredicateContext.accept(MySQLStatementParser.java:11690)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
~[antlr4-runtime-4.7.2.jar:4.7.2]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.MySQLVisitor.visitBooleanPrimary(MySQLVisitor.java:273)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.MySQLVisitor.visitBooleanPrimary(MySQLVisitor.java:121)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$BooleanPrimaryContext.accept(MySQLStatementParser.java:11463)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
~[antlr4-runtime-4.7.2.jar:4.7.2]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.MySQLVisitor.visitExpr(MySQLVisitor.java:258)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.MySQLVisitor.visitExpr(MySQLVisitor.java:121)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$ExprContext.accept(MySQLStatementParser.java:11241)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
~[antlr4-runtime-4.7.2.jar:4.7.2]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.createProjection(MySQLDMLVisitor.java:446)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitProjection(MySQLDMLVisitor.java:434)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitProjection(MySQLDMLVisitor.java:127)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$ProjectionContext.accept(MySQLStatementParser.java:5370)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
~[antlr4-runtime-4.7.2.jar:4.7.2]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitProjections(MySQLDMLVisitor.java:410)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitProjections(MySQLDMLVisitor.java:127)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$ProjectionsContext.accept(MySQLStatementParser.java:4865)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
~[antlr4-runtime-4.7.2.jar:4.7.2]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelectClause(MySQLDMLVisitor.java:329)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelectClause(MySQLDMLVisitor.java:127)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$SelectClauseContext.accept(MySQLStatementParser.java:4551)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
~[antlr4-runtime-4.7.2.jar:4.7.2]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitUnionClause(MySQLDMLVisitor.java:322)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitUnionClause(MySQLDMLVisitor.java:127)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$UnionClauseContext.accept(MySQLStatementParser.java:4446)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
~[antlr4-runtime-4.7.2.jar:4.7.2]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelect(MySQLDMLVisitor.java:314)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelect(MySQLDMLVisitor.java:127)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$SelectContext.accept(MySQLStatementParser.java:3098)
~[shardingsphere-sql-parser-mysql-4.1.1.jar:4.1.1]
at
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
~[antlr4-runtime-4.7.2.jar:4.7.2]
at
org.apache.shardingsphere.sql.parser.SQLParserEngine.parse0(SQLParserEngine.java:80)
~[shardingsphere-sql-parser-engine-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.sql.parser.SQLParserEngine.parse(SQLParserEngine.java:61)
~[shardingsphere-sql-parser-engine-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.underlying.route.DataNodeRouter.createRouteContext(DataNodeRouter.java:97)
~[shardingsphere-route-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.underlying.route.DataNodeRouter.executeRoute(DataNodeRouter.java:89)
~[shardingsphere-route-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.underlying.route.DataNodeRouter.route(DataNodeRouter.java:76)
~[shardingsphere-route-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.underlying.pluggble.prepare.PreparedQueryPrepareEngine.route(PreparedQueryPrepareEngine.java:54)
~[shardingsphere-pluggable-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.underlying.pluggble.prepare.BasePrepareEngine.executeRoute(BasePrepareEngine.java:96)
~[shardingsphere-pluggable-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.underlying.pluggble.prepare.BasePrepareEngine.prepare(BasePrepareEngine.java:83)
~[shardingsphere-pluggable-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.prepare(ShardingPreparedStatement.java:183)
~[sharding-jdbc-core-4.1.1.jar:4.1.1]
at
org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:143)
~[sharding-jdbc-core-4.1.1.jar:4.1.1]
at
org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64)
~[mybatis-3.5.6.jar:3.5.6]
at
org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
~[mybatis-3.5.6.jar:3.5.6]
at
org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
~[mybatis-3.5.6.jar:3.5.6]
at
org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
~[mybatis-3.5.6.jar:3.5.6]
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
~[mybatis-3.5.6.jar:3.5.6]
at
org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
~[mybatis-3.5.6.jar:3.5.6]
at
org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:89)
~[mybatis-3.5.6.jar:3.5.6]
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
~[mybatis-3.5.6.jar:3.5.6]
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
~[mybatis-3.5.6.jar:3.5.6]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.8.0_121]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:1.8.0_121]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)
~[mybatis-spring-2.0.6.jar:2.0.6]
at com.sun.proxy.$Proxy58.selectList(Unknown Source) ~[na:na]
at
org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
~[mybatis-spring-2.0.6.jar:2.0.6]
at
org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)
~[mybatis-3.5.6.jar:3.5.6]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)
~[mybatis-3.5.6.jar:3.5.6]
at
org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:152)
~[mybatis-3.5.6.jar:3.5.6]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85)
~[mybatis-3.5.6.jar:3.5.6]
at com.sun.proxy.$Proxy61.selectTotalFlowByDate(Unknown Source) ~[na:na]
at
com.oujiong.service.impl.SiteFlowBandWidthServiceImpl.selectTotalFlowByDate(SiteFlowBandWidthServiceImpl.java:30)
~[classes/:na]
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]