同时使用了with as语法和union all语法时,报错Can't find column XXXX

同时使用了with as语法和union all语法时,报错Can’t find column XXXX。

去掉union all正常执行,或者将with as语法修改为子查询,也能正常执行

【 Bug 的影响】
系统适配tidb数据库时,原有sql无法正常执行。

【可能的问题复现步骤】
drop table if exists cux_test3;
create table cux_test3(id bigint,rate double);

with temp_d0 as
(select d1.rate, d1.id
from (select d0.id, (d0.rate / 100) as rate from cux_test3 d0) d1
where 1 = 1
and d1.id <= 3)
select rate
from temp_d0 d2
where id = 1
union all
select rate from temp_d0 d0 where id = 2;
【看到的非预期行为】

【期望看到的行为】

希望该sql能正常执行,而不是让我去改sql绕开这两个语法。

【相关组件及具体版本】
tidb v5.1

【其他背景信息或者截图】

应该是这个 bug
如果是 那么 在 v511 已经修复,建议升级再试

4776f696fce5b7e265b9235f9cc4970


升级后仍在报错

5.1.1 还未修复,将在 5.1.2 或者 5.2 版本中修复

1 个赞

请问下咱们目前使用 SQL 的环境是什么。如果是重要生产环境请私信联系我

是帖子中的sql,无法复现报错吗?

此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。