Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complicated CTE query got cannot find column in schema error #45033

Closed
guo-shaoge opened this issue Jun 28, 2023 · 0 comments · Fixed by #45034
Closed

Complicated CTE query got cannot find column in schema error #45033

guo-shaoge opened this issue Jun 28, 2023 · 0 comments · Fixed by #45034
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@guo-shaoge
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. tiup playground nightly --tiflash 0 --without-monitor
  2. run the following sql:
drop table if exists t1, t2, t3, t4;
CREATE TABLE `t1` (c1 int, c2 int, c3 int, primary key(c1, c2));
CREATE TABLE `t2` (c2 int, c1 int, primary key(c2, c1));
CREATE TABLE `t3` (c4 int, key(c4));
CREATE TABLE `t4` (c2 varchar(20) , test_col varchar(50), gen_col varchar(50) generated always as(concat(test_col,'')) virtual not null, unique key(gen_col));

select count(1)
from   (select ( case
                   when count(1)
                          over(
                            partition by a.c2) >= 50 then 1
                   else 0
                 end ) alias1,
               b.c2    as alias_col1
        from   t1 a
               left join (select c2
                          from   t4 f) k
                      on k.c2 = a.c2
               inner join t2 b
                       on b.c1 = a.c3) alias2
where  exists (select 1
               from   (select distinct alias3.c4 as c2
                       from   t3 alias3) alias4
               where  alias4.c2 = alias2.alias_col1);

2. What did you expect to see? (Required)

+----------+
| count(1) |
+----------+
|        0 |
+----------+

3. What did you see instead (Required)

ERROR 1105 (HY000): Can't find column test.t2.c2 in schema Column: [test.t1.c2,Column#13,test.t3.c4] Unique key: []

4. What is your TiDB version? (Required)

+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                             |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.3.0-alpha
Edition: Community
Git Commit Hash: 8ef5b4a65c8a7c200c1b6713f309426cd162b7f2
Git Branch: heads/refs/tags/v7.3.0-alpha
UTC Build Time: 2023-06-27 14:35:52
GoVersion: go1.20.5
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@guo-shaoge guo-shaoge added the type/bug The issue is confirmed as a bug. label Jun 28, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Jun 28, 2023
@guo-shaoge guo-shaoge removed may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Jun 28, 2023
@guo-shaoge guo-shaoge changed the title Got cannot find column in schema error Complicated CTE query got cannot find column in schema error Jun 30, 2023
@ti-chi-bot ti-chi-bot added the affects-6.1 This bug affects the 6.1.x(LTS) versions. label Nov 13, 2023
@Ivy-YinSu Ivy-YinSu added the sig/execution SIG execution label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants