S126gj opened a new issue, #27922:
URL: https://github.com/apache/shardingsphere/issues/27922
my pom.xml
```
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.0</version>
</parent>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.31</version>
</dependency>
<!--sharding-jdbc-->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<!-- mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.1</version>
<exclusions>
<!-- 解决jsqlparser 依赖版本冲突 -->
<exclusion>
<artifactId>jsqlparser</artifactId>
<groupId>com.github.jsqlparser</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
<version>4.2</version>
</dependency>
```
my yml
```
spring:
datasource:
driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver
url: jdbc:shardingsphere:classpath:sharding/sharding-dev.yaml
# mybatis-plus
mybatis-plus:
type-aliases-package: com.device.entity
mapper-locations: classpath*:com/device/**/*.xml
configuration:
# 输出日志到控制台
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
```
sharding-dev.yaml
```
dataSources:
ds_0:
dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url:
jdbc:mysql://127.0.0.1:3306/maintenance?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&stringtype=unspecified
username: root
password: 123456
initialSize: 5 #连接池初始化连接数
minIdle: 3 #连接池最小连接数
maxActive: 20 #连接池最大连接数
maxWait: 5000
rules:
- !SINGLE
tables:
- ds_0.* # 加载该数据源的全部表
defaultDataSource: ds_0
- !SHARDING
tables: # 数据分片规则配置
box_run: # 逻辑表名称
actualDataNodes : ds_0.box_run_$->{0..7} # 由数据源名 + 表名组成(参考 Inline
语法规则)
tableStrategy: # 分表策略,同分库策略
standard: # 用于单分片键的标准分片场景
shardingColumn: id # 分片列名称
shardingAlgorithmName: box_run_inline # 分片算法名称
keyGenerateStrategy: # 分布式序列策略
column: id # 自增列名称,缺省表示不使用自增主键生成器
keyGeneratorName: snowflake # 分布式序列算法名称
# 分片算法配置
shardingAlgorithms:
box_run_inline: # 分片算法名称
type: INLINE # 分片算法类型
props: # 分片算法属性配置 t_user_$->{u_id % 8} 表示 t_user 表根据 u_id 模 8,而分成 8
张表,表名称为 t_user_0 到 t_user_7
algorithm-expression: box_run_$->{id % 8}
# 分布式序列算法配置
keyGenerators:
snowflake: # 分布式序列算法名称
type: SNOWFLAKE # 分布式序列算法类型
props:
sql-show: true
```
mysql table box_run
```
CREATE TABLE `box_run_0`
(
`id` bigint
NOT NULL COMMENT 'id',
`last_query_time` datetime
DEFAULT NULL COMMENT '查询时间',
`box_code` varchar(50) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
`product_number_begin` decimal(30, 2)
DEFAULT '0.00' COMMENT '开始生产数量',
`product_number` decimal(30, 2)
DEFAULT '0.00' COMMENT '生产数量',
`avg_speed` decimal(10, 2)
DEFAULT '0.00' COMMENT '平均速率',
`begin_time` datetime
DEFAULT NULL COMMENT '开始时间',
`end_time` datetime
DEFAULT NULL COMMENT '结束时间',
`duration` bigint
DEFAULT '0' COMMENT '时长(分钟)',
`machine_state` varchar(5) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
`gmt_create` datetime
DEFAULT NULL COMMENT '创建日期',
`gmt_modified` datetime
DEFAULT NULL COMMENT '修改日期',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';
CREATE TABLE `box_run_1`
(
`id` bigint
NOT NULL COMMENT 'id',
`last_query_time` datetime
DEFAULT NULL COMMENT '查询时间',
`box_code` varchar(50) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
`product_number_begin` decimal(30, 2)
DEFAULT '0.00' COMMENT '开始生产数量',
`product_number` decimal(30, 2)
DEFAULT '0.00' COMMENT '生产数量',
`avg_speed` decimal(10, 2)
DEFAULT '0.00' COMMENT '平均速率',
`begin_time` datetime
DEFAULT NULL COMMENT '开始时间',
`end_time` datetime
DEFAULT NULL COMMENT '结束时间',
`duration` bigint
DEFAULT '0' COMMENT '时长(分钟)',
`machine_state` varchar(5) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
`gmt_create` datetime
DEFAULT NULL COMMENT '创建日期',
`gmt_modified` datetime
DEFAULT NULL COMMENT '修改日期',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';
CREATE TABLE `box_run_2`
(
`id` bigint
NOT NULL COMMENT 'id',
`last_query_time` datetime
DEFAULT NULL COMMENT '查询时间',
`box_code` varchar(50) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
`product_number_begin` decimal(30, 2)
DEFAULT '0.00' COMMENT '开始生产数量',
`product_number` decimal(30, 2)
DEFAULT '0.00' COMMENT '生产数量',
`avg_speed` decimal(10, 2)
DEFAULT '0.00' COMMENT '平均速率',
`begin_time` datetime
DEFAULT NULL COMMENT '开始时间',
`end_time` datetime
DEFAULT NULL COMMENT '结束时间',
`duration` bigint
DEFAULT '0' COMMENT '时长(分钟)',
`machine_state` varchar(5) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
`gmt_create` datetime
DEFAULT NULL COMMENT '创建日期',
`gmt_modified` datetime
DEFAULT NULL COMMENT '修改日期',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';
CREATE TABLE `box_run_3`
(
`id` bigint
NOT NULL COMMENT 'id',
`last_query_time` datetime
DEFAULT NULL COMMENT '查询时间',
`box_code` varchar(50) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
`product_number_begin` decimal(30, 2)
DEFAULT '0.00' COMMENT '开始生产数量',
`product_number` decimal(30, 2)
DEFAULT '0.00' COMMENT '生产数量',
`avg_speed` decimal(10, 2)
DEFAULT '0.00' COMMENT '平均速率',
`begin_time` datetime
DEFAULT NULL COMMENT '开始时间',
`end_time` datetime
DEFAULT NULL COMMENT '结束时间',
`duration` bigint
DEFAULT '0' COMMENT '时长(分钟)',
`machine_state` varchar(5) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
`gmt_create` datetime
DEFAULT NULL COMMENT '创建日期',
`gmt_modified` datetime
DEFAULT NULL COMMENT '修改日期',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';
CREATE TABLE `box_run_4`
(
`id` bigint
NOT NULL COMMENT 'id',
`last_query_time` datetime
DEFAULT NULL COMMENT '查询时间',
`box_code` varchar(50) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
`product_number_begin` decimal(30, 2)
DEFAULT '0.00' COMMENT '开始生产数量',
`product_number` decimal(30, 2)
DEFAULT '0.00' COMMENT '生产数量',
`avg_speed` decimal(10, 2)
DEFAULT '0.00' COMMENT '平均速率',
`begin_time` datetime
DEFAULT NULL COMMENT '开始时间',
`end_time` datetime
DEFAULT NULL COMMENT '结束时间',
`duration` bigint
DEFAULT '0' COMMENT '时长(分钟)',
`machine_state` varchar(5) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
`gmt_create` datetime
DEFAULT NULL COMMENT '创建日期',
`gmt_modified` datetime
DEFAULT NULL COMMENT '修改日期',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';
CREATE TABLE `box_run_5`
(
`id` bigint
NOT NULL COMMENT 'id',
`last_query_time` datetime
DEFAULT NULL COMMENT '查询时间',
`box_code` varchar(50) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
`product_number_begin` decimal(30, 2)
DEFAULT '0.00' COMMENT '开始生产数量',
`product_number` decimal(30, 2)
DEFAULT '0.00' COMMENT '生产数量',
`avg_speed` decimal(10, 2)
DEFAULT '0.00' COMMENT '平均速率',
`begin_time` datetime
DEFAULT NULL COMMENT '开始时间',
`end_time` datetime
DEFAULT NULL COMMENT '结束时间',
`duration` bigint
DEFAULT '0' COMMENT '时长(分钟)',
`machine_state` varchar(5) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
`gmt_create` datetime
DEFAULT NULL COMMENT '创建日期',
`gmt_modified` datetime
DEFAULT NULL COMMENT '修改日期',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';
CREATE TABLE `box_run_6`
(
`id` bigint
NOT NULL COMMENT 'id',
`last_query_time` datetime
DEFAULT NULL COMMENT '查询时间',
`box_code` varchar(50) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
`product_number_begin` decimal(30, 2)
DEFAULT '0.00' COMMENT '开始生产数量',
`product_number` decimal(30, 2)
DEFAULT '0.00' COMMENT '生产数量',
`avg_speed` decimal(10, 2)
DEFAULT '0.00' COMMENT '平均速率',
`begin_time` datetime
DEFAULT NULL COMMENT '开始时间',
`end_time` datetime
DEFAULT NULL COMMENT '结束时间',
`duration` bigint
DEFAULT '0' COMMENT '时长(分钟)',
`machine_state` varchar(5) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
`gmt_create` datetime
DEFAULT NULL COMMENT '创建日期',
`gmt_modified` datetime
DEFAULT NULL COMMENT '修改日期',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';
CREATE TABLE `box_run_7`
(
`id` bigint
NOT NULL COMMENT 'id',
`last_query_time` datetime
DEFAULT NULL COMMENT '查询时间',
`box_code` varchar(50) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci NOT NULL COMMENT '盒子序列号',
`product_number_begin` decimal(30, 2)
DEFAULT '0.00' COMMENT '开始生产数量',
`product_number` decimal(30, 2)
DEFAULT '0.00' COMMENT '生产数量',
`avg_speed` decimal(10, 2)
DEFAULT '0.00' COMMENT '平均速率',
`begin_time` datetime
DEFAULT NULL COMMENT '开始时间',
`end_time` datetime
DEFAULT NULL COMMENT '结束时间',
`duration` bigint
DEFAULT '0' COMMENT '时长(分钟)',
`machine_state` varchar(5) CHARACTER SET utf8mb4 COLLATE
utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备状态(关机,待机,运行)',
`gmt_create` datetime
DEFAULT NULL COMMENT '创建日期',
`gmt_modified` datetime
DEFAULT NULL COMMENT '修改日期',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_box_code` (`box_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
ROW_FORMAT=DYNAMIC COMMENT='设备实时运行表';
```
test code
<img width="1380" alt="image"
src="https://github.com/apache/shardingsphere/assets/70879893/0c663cdf-65ad-4f09-835e-6d7f1c7234ad">
queryHistory xml
```
<select id="queryHistory"
resultType="com.device.system.core.entity.vo.MachineHistoryVO">
SELECT DATE (begin_time) AS date,
IFNULL(end_time, NOW()) AS sortEndTime,
SUM (duration) AS workDuration,
SUM (CASE WHEN machine_state != '关机' THEN duration ELSE 0 END)
AS energizeDuration,
SUM (product_number - product_number_begin) AS productNum,
AVG (avg_speed) AS avgSpeed,
(case when #{bestSpeed,jdbcType=DOUBLE}!= 0 then AVG(avg_speed)
/ #{bestSpeed,jdbcType=DOUBLE} else 0 end) AS ep
FROM (
SELECT *
FROM box_run WHERE box_code = #{boxCode,jdbcType=VARCHAR}
)
GROUP BY DATE (begin_time)
ORDER BY begin_time DESC, sortEndTime DESC;
</select>
```
the error messge
```
org.mybatis.spring.MyBatisSystemException
at
org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
at
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
at jdk.proxy2/jdk.proxy2.$Proxy116.selectList(Unknown Source)
at
org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
at
com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForIPage(MybatisMapperMethod.java:121)
at
com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:85)
at
com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
at
com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
at jdk.proxy2/jdk.proxy2.$Proxy149.queryHistory(Unknown Source)
at com.device.system.ShardTest.query(ShardTest.java:82)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at
org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
at
org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at
org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at
org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
at
org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
at
org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
at
org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
at
org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
at
org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at
org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at
org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at
org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at
org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
at
org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
at
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213)
at
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138)
at
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at
org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at
org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
at
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
at
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
at
org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
at
org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
at
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
at
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at
org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at
org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at
com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
at
com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at
com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.apache.ibatis.executor.ExecutorException: Error preparing
statement. Cause:
org.apache.shardingsphere.sql.parser.exception.SQLParsingException: You have an
error in your SQL syntax: SELECT COUNT(*) FROM (SELECT DATE(begin_time) AS
date, IFNULL(end_time, NOW()) AS sortEndTime, SUM(duration) AS workDuration,
SUM(CASE WHEN machine_state != '关机' THEN duration ELSE 0 END) AS
energizeDuration, SUM(product_number - product_number_begin) AS productNum,
AVG(avg_speed) AS avgSpeed, (CASE WHEN ? != 0 THEN AVG(avg_speed) / ? ELSE 0
END) AS ep FROM (SELECT * FROM box_run WHERE box_code = ?) GROUP BY
DATE(begin_time) ORDER BY begin_time DESC, sortEndTime DESC) TOTAL, no viable
alternative at input
'SELECTCOUNT(*)FROM(SELECTDATE(begin_time)ASdate,IFNULL(end_time,NOW())ASsortEndTime,SUM(duration)ASworkDuration,SUM(CASEWHENmachine_state!='关机'THENdurationELSE0END)ASenergizeDuration,SUM(product_number-product_number_begin)ASproductNum,AVG(avg_speed)ASavgSpeed,(CASEWHEN?!=0THE
NAVG(avg_speed)/?ELSE0END)ASepFROM(SELECT*FROMbox_runWHEREbox_code=?)GROUP' at
line 1, position 403, near [@95,403:407='GROUP',<292>,1:403]
at
org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:97)
at
org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:59)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
at
com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
at jdk.proxy2/jdk.proxy2.$Proxy232.prepare(Unknown Source)
at
org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:87)
at
org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
at
org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at
org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at
com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor.willDoQuery(PaginationInnerInterceptor.java:135)
at
com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:75)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
at jdk.proxy2/jdk.proxy2.$Proxy231.query(Unknown Source)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)
... 78 more
Caused by:
org.apache.shardingsphere.sql.parser.exception.SQLParsingException: You have an
error in your SQL syntax: SELECT COUNT(*) FROM (SELECT DATE(begin_time) AS
date, IFNULL(end_time, NOW()) AS sortEndTime, SUM(duration) AS workDuration,
SUM(CASE WHEN machine_state != '关机' THEN duration ELSE 0 END) AS
energizeDuration, SUM(product_number - product_number_begin) AS productNum,
AVG(avg_speed) AS avgSpeed, (CASE WHEN ? != 0 THEN AVG(avg_speed) / ? ELSE 0
END) AS ep FROM (SELECT * FROM box_run WHERE box_code = ?) GROUP BY
DATE(begin_time) ORDER BY begin_time DESC, sortEndTime DESC) TOTAL, no viable
alternative at input
'SELECTCOUNT(*)FROM(SELECTDATE(begin_time)ASdate,IFNULL(end_time,NOW())ASsortEndTime,SUM(duration)ASworkDuration,SUM(CASEWHENmachine_state!='关机'THENdurationELSE0END)ASenergizeDuration,SUM(product_number-product_number_begin)ASproductNum,AVG(avg_speed)ASavgSpeed,(CASEWHEN?!=0THENAVG(avg_speed)/?ELSE0END)ASepFROM(SELECT*FROMbox_runWHEREbox_code=?)GROUP'
at li
ne 1, position 403, near [@95,403:407='GROUP',<292>,1:403]
at
org.apache.shardingsphere.sql.parser.core.database.parser.SQLParserExecutor.twoPhaseParse(SQLParserExecutor.java:69)
at
org.apache.shardingsphere.sql.parser.core.database.parser.SQLParserExecutor.parse(SQLParserExecutor.java:48)
at
org.apache.shardingsphere.sql.parser.api.SQLParserEngine.parse(SQLParserEngine.java:47)
at
org.apache.shardingsphere.infra.parser.sql.SQLStatementParserExecutor.parse(SQLStatementParserExecutor.java:46)
at
org.apache.shardingsphere.infra.parser.cache.SQLStatementCacheLoader.load(SQLStatementCacheLoader.java:41)
at
org.apache.shardingsphere.infra.parser.cache.SQLStatementCacheLoader.load(SQLStatementCacheLoader.java:30)
at
com.github.benmanes.caffeine.cache.LocalLoadingCache.lambda$newMappingFunction$3(LocalLoadingCache.java:183)
at
com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2685)
at
java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1916)
at
com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2683)
at
com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2666)
at
com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:112)
at
com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:58)
at
org.apache.shardingsphere.infra.parser.sql.SQLStatementParserEngine.parse(SQLStatementParserEngine.java:47)
at
org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine.parse(ShardingSphereSQLParserEngine.java:52)
at
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:199)
at
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:164)
at
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.prepareStatement(ShardingSphereConnection.java:88)
at
com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:327)
at
com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at
org.apache.ibatis.logging.jdbc.ConnectionLogger.invoke(ConnectionLogger.java:55)
at jdk.proxy3/jdk.proxy3.$Proxy237.prepareStatement(Unknown Source)
at
org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:86)
at
org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:88)
... 104 more
```
There are three test methods, the results are all in the comments, the first
query is normal, the second query results mysql has a value, but the query
returns null, and the third xml query reports an error
--
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.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]