当前位置: 首页 > news >正文

ShardingSphere:查询报错:Actual table `数据源名称.表名` is not in table rule configuration

目录

    • 简介
    • 异常信息
    • 排查
    • 原因
    • 解决


简介

1、使用ShardingSphere框架,版本为5.2.1

<dependency><groupId>org.apache.shardingsphere</groupId><artifactId>shardingsphere-jdbc-core</artifactId><version>5.2.1</version>
</dependency>

2、SQL涉及多表链接查询时会报错

3、表分片字段:subTableDate


异常信息

2025-05-13 11:06:34.072 - [ERROR] - [http-nio-8091-exec-1] - [o.s.boot.web.servlet.support.ErrorPageFilter - line:182]: Forwarding to error page from request [/home/getVisitorQA] due to exception [
### Error querying database.  Cause: java.sql.SQLException: Actual table `xxxrobot0.t_robot_messageReplay_202505` is not in table rule configuration.
### The error may exist in file [/home/xxx/devtest/robot_llm/tomcat10-robotMg_llm-8091/webapps/xxxRobotMg-llm/WEB-INF/classes/mappings/visitor/RobotMessagereplayMapper.xml]
### The error may involve com.xxx.mapper.visitor.RobotMessagereplayMapper.selectVisitorQA-Inline
### The error occurred while setting parameters
### SQL: SELECT if(isOld=1,2,1) vType,if(isOld=1,'老用户咨询量','新用户咨询量') vTypeName,count(1) qty,   SUM(if(a.hours=0,1,0)) qty0,   SUM(if(a.hours=1,1,0)) qty1,   SUM(if(a.hours=2,1,0)) qty2,   SUM(if(a.hours=3,1,0)) qty3,   SUM(if(a.hours=4,1,0)) qty4,   SUM(if(a.hours=5,1,0)) qty5,   SUM(if(a.hours=6,1,0))   qty6,   SUM(if(a.hours=7,1,0)) qty7,   SUM(if(a.hours=8,1,0)) qty8,   SUM(if(a.hours=9,1,0)) qty9,   SUM(if(a.hours=10,1,0)) qty10,   SUM(if(a.hours=11,1,0)) qty11,   SUM(if(a.hours=12,1,0)) qty12,   SUM(if(a.hours=13,1,0)) qty13,   SUM(if(a.hours=14,1,0)) qty14,   SUM(if(a.hours=15,1,0)) qty15,   SUM(if(a.hours=16,1,0)) qty16,   SUM(if(a.hours=17,1,0)) qty17,   SUM(if(a.hours=18,1,0)) qty18,   SUM(if(a.hours=19,1,0)) qty19,   SUM(if(a.hours=20,1,0)) qty20,   SUM(if(a.hours=21,1,0)) qty21,   SUM(if(a.hours=22,1,0)) qty22,   SUM(if(a.hours=23,1,0)) qty23   FROM t_robot_sessionmsg c   LEFT JOIN t_robot_messageReplay a ON a.SessionID=c.SessionID where a.subTableDate   between ? and ?        and a.companyId = ?       GROUP BY c.isOld
### Cause: java.sql.SQLException: Actual table `xxxrobot0.t_robot_messageReplay_202505` is not in table rule configuration.
; Actual table `xxxrobot0.t_robot_messageReplay_202505` is not in table rule configuration.]
org.springframework.dao.DataIntegrityViolationException: 
### Error querying database.  Cause: java.sql.SQLException: Actual table `xxxrobot0.t_robot_messageReplay_202505` is not in table rule configuration.
### The error may exist in file [/home/xxx/devtest/robot_llm/tomcat10-robotMg_llm-8091/webapps/xxxRobotMg-llm/WEB-INF/classes/mappings/visitor/RobotMessagereplayMapper.xml]
### The error may involve com.xxx.mapper.visitor.RobotMessagereplayMapper.selectVisitorQA-Inline
### The error occurred while setting parameters
### SQL: SELECT if(isOld=1,2,1) vType,if(isOld=1,'老用户咨询量','新用户咨询量') vTypeName,count(1) qty,   SUM(if(a.hours=0,1,0)) qty0,   SUM(if(a.hours=1,1,0)) qty1,   SUM(if(a.hours=2,1,0)) qty2,   SUM(if(a.hours=3,1,0)) qty3,   SUM(if(a.hours=4,1,0)) qty4,   SUM(if(a.hours=5,1,0)) qty5,   SUM(if(a.hours=6,1,0))   qty6,   SUM(if(a.hours=7,1,0)) qty7,   SUM(if(a.hours=8,1,0)) qty8,   SUM(if(a.hours=9,1,0)) qty9,   SUM(if(a.hours=10,1,0)) qty10,   SUM(if(a.hours=11,1,0)) qty11,   SUM(if(a.hours=12,1,0)) qty12,   SUM(if(a.hours=13,1,0)) qty13,   SUM(if(a.hours=14,1,0)) qty14,   SUM(if(a.hours=15,1,0)) qty15,   SUM(if(a.hours=16,1,0)) qty16,   SUM(if(a.hours=17,1,0)) qty17,   SUM(if(a.hours=18,1,0)) qty18,   SUM(if(a.hours=19,1,0)) qty19,   SUM(if(a.hours=20,1,0)) qty20,   SUM(if(a.hours=21,1,0)) qty21,   SUM(if(a.hours=22,1,0)) qty22,   SUM(if(a.hours=23,1,0)) qty23   FROM t_robot_sessionmsg c   LEFT JOIN t_robot_messageReplay a ON a.SessionID=c.SessionID where a.subTableDate   between ? and ?        and a.companyId = ?       GROUP BY c.isOld
### Cause: java.sql.SQLException: Actual table `xxxrobot0.t_robot_messageReplay_202505` is not in table rule configuration.
; Actual table `xxxrobot0.t_robot_messageReplay_202505` is not in table rule configuration.at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:118)at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:107)at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:116)at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:116)at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:93)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:347)at jdk.proxy3/jdk.proxy3.$Proxy117.selectList(Unknown Source)at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194)at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:141)at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)at jdk.proxy3/jdk.proxy3.$Proxy316.selectVisitorQA(Unknown Source)at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)at java.base/java.lang.reflect.Method.invoke(Method.java:580)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:355)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:138)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:223)at jdk.proxy3/jdk.proxy3.$Proxy317.selectVisitorQA(Unknown Source)at com.xxx.service.Impl.visitor.RobotMessagereplayServiceImpl.getVisitorQA(RobotMessagereplayServiceImpl.java:164)at com.xxx.controller.rpt.HomeController.getVisitorQA(HomeController.java:184)at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)at java.base/java.lang.reflect.Method.invoke(Method.java:580)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:355)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:768)at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:57)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:173)at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:768)at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:768)at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:720)at com.xxx.controller.rpt.HomeController$$SpringCGLIB$$0.getVisitorQA(<generated>)at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)at java.base/java.lang.reflect.Method.invoke(Method.java:580)at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:255)at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:188)at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:926)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:831)at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1089)at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979)at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:914)at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:590)at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:195)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:110)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)at com.xxx.filter.XssFilter.doFilter(XssFilter.java:53)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108)at org.springframework.security.web.FilterChainProxy.lambda$doFilterInternal$3(FilterChainProxy.java:231)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:365)at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:117)at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:126)at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:120)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:131)at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:85)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:100)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:179)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at com.xxx.jwt.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:145)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:107)at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:93)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:91)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90)at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.security.web.context.SecurityContextHolderFilter.doFilter(SecurityContextHolderFilter.java:82)at org.springframework.security.web.context.SecurityContextHolderFilter.doFilter(SecurityContextHolderFilter.java:69)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:62)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374)at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:233)at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:191)at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:113)at org.springframework.web.servlet.handler.HandlerMappingIntrospector.lambda$createCacheFilter$3(HandlerMappingIntrospector.java:195)at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:113)at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74)at org.springframework.security.config.annotation.web.configuration.WebMvcSecurityConfiguration$CompositeFilterChainProxy.doFilter(WebMvcSecurityConfiguration.java:230)at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:362)at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:278)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:124)at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:99)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:117)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:483)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:670)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:397)at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:905)at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743)at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190)at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.sql.SQLException: Actual table `xxxrobot0.t_robot_messageReplay_202505` is not in table rule configuration.at org.apache.shardingsphere.infra.util.exception.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:54)at org.apache.shardingsphere.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:51)at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:409)at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65)at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:80)at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:65)at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:336)at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:158)at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:110)at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:90)at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:154)at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:142)at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)at java.base/java.lang.reflect.Method.invoke(Method.java:580)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:333)... 136 common frames omitted

排查

1、单表查询SQL分片正常、查询正常

2、其他多表链接查询的SQL也正常

3、只有以下SQL查询报错,所以问题是出在SQL上

补充:以下SQL在其他ShardingSphere版本的框架上是可以正常执行的,所以问题也与ShardingSphere的框架版本有关

SELECT if(isOld=1,2,1) vType,if(isOld=1,'老用户咨询量','新用户咨询量') vTypeName,count(1) qty,SUM(if(a.hours=0,1,0)) qty0,SUM(if(a.hours=1,1,0)) qty1,SUM(if(a.hours=2,1,0)) qty2,SUM(if(a.hours=3,1,0)) qty3,SUM(if(a.hours=4,1,0)) qty4,SUM(if(a.hours=5,1,0)) qty5,SUM(if(a.hours=6,1,0)) qty6,SUM(if(a.hours=7,1,0)) qty7,SUM(if(a.hours=8,1,0)) qty8,SUM(if(a.hours=9,1,0)) qty9,SUM(if(a.hours=10,1,0)) qty10,SUM(if(a.hours=11,1,0)) qty11,SUM(if(a.hours=12,1,0)) qty12,SUM(if(a.hours=13,1,0)) qty13,SUM(if(a.hours=14,1,0)) qty14,SUM(if(a.hours=15,1,0)) qty15,SUM(if(a.hours=16,1,0)) qty16,SUM(if(a.hours=17,1,0)) qty17,SUM(if(a.hours=18,1,0)) qty18,SUM(if(a.hours=19,1,0)) qty19,SUM(if(a.hours=20,1,0)) qty20,SUM(if(a.hours=21,1,0)) qty21,SUM(if(a.hours=22,1,0)) qty22,SUM(if(a.hours=23,1,0)) qty23
FROM t_robot_sessionmsg c
LEFT JOIN t_robot_messageReplay a ON a.SessionID=c.SessionID 
where a.subTableDate between 'xxx' and 'xxx'
and a.companyId = 'xxx'
GROUP BY c.isOld

4、发现使用分片键的表不是主表c,而是外链表a

-- a表是外链表,c表才是主表
where a.subTableDate between 'xxx' and 'xxx'

5、将主表的分片键作为查询条件,SQL可正常查询

-- 改为:c.subTableDate
where c.subTableDate between 'xxx' and 'xxx'

原因

SQL查询where条件没有涉及主表分片键

补充:以上SQL在其他ShardingSphere版本的框架上是可以正常执行的,所以问题也与ShardingSphere的框架版本有关


解决

将主键分片键加入SQL查询where条件

相关文章:

  • nacos配置文件快速部署另一种方法
  • python 爬虫框架介绍
  • CSS- 3.1 盒子模型-块级元素、行内元素、行内块级元素和display属性
  • idea 保证旧版本配置的同时,如何从低版本升到高版本
  • 嵌入式单片机中STM32F1演示寄存器控制方法
  • 英飞凌tle9954 GPIO
  • LLM学习笔记(五)概率论
  • 非国产算力DeepSeek 部署中的常见问题及解决方案
  • 艾体宝案例丨AI 团队如何高效管理多云部署?Cinnamon AI 的 DevOps 成功经验
  • leetcode 2901. 最长相邻不相等子序列 II 中等
  • OpenCV边界填充(Border Padding)详解:原理、方法与代码实现
  • OpenCV 图像透视变换详解
  • 骨髓移植和干细胞供体移植全过程
  • Claude Prompt-Caching 方案调研
  • 问题 | 国内外软件定义卫星最新进展研究
  • Linux下可执行程序的生成和运行详解(编译链接汇编图解)
  • React中useMemo和useCallback的作用:
  • 基于React的高德地图api教程007:椭圆的绘制、编辑和删除
  • 计算机网络-----6分层结构
  • 青少年ctf平台应急响应-应急响应2
  • 101岁陕西省军区原司令员冀廷璧逝世,曾参加百团大战
  • 官方通报汕头违建豪宅“英之园”将强拆:对有关人员严肃追责问责
  • 张国清将赴俄罗斯举行中俄“长江—伏尔加河”地方合作理事会第五次会议和“东北—远东”政府间合作委员会双方主席会晤
  • 韧性十足的中国外贸企业:“不倒翁”被摁下去,还会再弹起来
  • 国税总局上海市税务局回应刘晓庆被举报涉嫌偷漏税:正依法依规办理
  • 遭“特朗普关税”冲击,韩国今年经济增长预期“腰斩”降至0.8%