Bug #115696 MySQL reports a error when group by has a lateral subquery.
Submitted: 26 Jul 6:35 Modified: 1 Oct 16:11
Reporter: Diancheng Wang Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:8.0.39, 8.4.2, 9.0.1 OS:Any
Assigned to: CPU Architecture:Any

[26 Jul 6:35] Diancheng Wang
Description:
It reports error message: Duplicate column name 'a'

How to repeat:
following SQL:

create table t1(a int);
select (select ti1.a as c0
                from
                  t1 as ti1,
                  lateral (select to1.a as c00,
                        to1.a as c11
                      from
                        t1 as ti2) as subq_0 limit 1) as c1
      from
        t1 as to1 group by 1;

Note, If remove 'group by 1' from above SQL, the query can be executed successfully.
[26 Jul 7:26] MySQL Verification Team
Hello Diancheng Wang,

Thank you for the report and feedback.

regards,
Umesh
[1 Oct 16:11] Jon Stephens
Documented fix as follows in the MySQL 9.1.0 changelog:

    A GROUP BY query containing a LATERAL subquery raised a spurious
    duplicate column error.

Closed.