使用环境:
jdk1.8,数据库为splittable1和splittable2,在同一个mysql实例中。
test_date在splittable1中,采用按年分表策略,actualDataNodes:splittable1.test_date_${[‘2019’,‘2021’,‘2020’]}
date_type在spittable2中,为普通不分表的表,actualDataNodes: spittable2.date_type
场景一:
执行如下SQL:
select t.createYear
from test_date t
join splittable2.date_type d on t.type=d.type
where createTime between ‘2019-10-01’ and ‘2021-03-01’
输出:
23:30:10.748 数据库语句:select t.createYear from test_date t join splittable2.date_type d on t.type=d.type where createTime between ‘2019-10-01’ and ‘2021-03-01’
23:30:10.773 Parsing …
org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException
场景二:
执行如下SQL:
select t.createYear
from test_date t
join date_type d on t.type=d.type
where createTime between ‘2019-10-01’ and ‘2021-03-01’
输出:
23:49:44.785 数据库语句:select t.createYear from test_date t join date_type d on t.type=d.type where createTime between ‘2019-10-01’ and ‘2021-03-01’
23:49:44.798 Parsing …
23:49:46.218 Reduced t
.type
= d
.type
23:49:46.230 Reduced createTime
BETWEEN ASYMMETRIC ‘2019-10-01’ AND ‘2021-03-01’
……
Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, column 26 to line 1, column 34: Object ‘test_date’ not found
在4.1.1版本有默认数据源是没问题的。升级到5.2.0版本后,如果不跨库join也没有问题,但是跨库(及时是同实例)join查询时怎么尝试都不行,该如何解决,谢谢。