You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another problem is maybe that MySQL considers the first projection special if it references across the LATERAL join, rather than the default of rolling up all of the lateral projections as output. I am not sure we do this.
Setup
Createtablestudents (
Id intprimary key,
Name varchar(50),
Major int
);
Createtableclasses (
Id intprimary key,
Name varchar(50),
Department int
);
Createtablegrades (
Grade float,
Student int,
Class int,
Primary key (class, student)
);
Createtablemajors (
Id int,
Name varchar(50),
Department int,
Primary key (name, department)
);
Createtabledepartments (
Id intprimary key,
Name varchar(50)
);
Insert into students values (1, 'Elle', 4), (2, 'Latham', 2);
Insert into classes values
(1, 'Corporate Finance', 1),
(2, 'ESG Studies', 1),
(3, 'Late Bronze Age Collapse', 2),
(4, 'Greek Mythology', 2);
Insert into majors values
(1, 'Roman Studies', 2),
(2, 'Bronze Age Studies', 2),
(3, 'Accounting', 1),
(4, 'Finance', 1);
Insert into departments values
(1, 'Business'),
(2, 'History');
Insert into grades values
(94, 1, 1),
(97, 1, 2),
(85, 2, 3),
(92, 2, 4);
Query that fails to resolve the column name name (students.name):
Select name, class.class_name, grade.max_grade-- (1) get student's name, id, and majorfrom students,
-- (2) get the student's major department
LATERAL (
Selectdepartments.idas did
from majors join departments
Onmajors.department=departments.idwheremajors.id=students.major
) dept,
-- (3) get student's best performing class within their major's department
LATERAL (
Select
grade as max_grade,
classes.idas cid
From grades
Join classes
Ongrades.class=classes.idWheregrades.student=students.idandclasses.department=dept.didOrder by grade desclimit1
) grade,
-- (4) get name for class_id
LATERAL (
Select name as class_name from classes wheregrade.cid=classes.id
) class
column "name" could not be found in any table in scope
Substituting qualified students.name has an indexing error:
Selectstudents.name, class.class_name, grade.max_grade-- (1) get student's name, id, and majorfrom students,
-- (2) get the student's major department
LATERAL (
Selectdepartments.idas did
from majors join departments
Onmajors.department=departments.idwheremajors.id=students.major
) dept,
-- (3) get student's best performing class within their major's department
LATERAL (
Select
grade as max_grade,
classes.idas cid
From grades
Join classes
Ongrades.class=classes.idWheregrades.student=students.idandclasses.department=dept.didOrder by grade desclimit1
) grade,
-- (4) get name for class_id
LATERAL (
Select name as class_name from classes wheregrade.cid=classes.id
) class
unable to find field with index -1in row of 4 columns
The text was updated successfully, but these errors were encountered:
Several bugs trying to run a nested lateral join. One of the issues is that
ExecBuilder.buildSubqueryAlias
should pass through the input row:Another problem is maybe that MySQL considers the first projection special if it references across the LATERAL join, rather than the default of rolling up all of the lateral projections as output. I am not sure we do this.
Setup
Expected result:
Query that fails to resolve the column name
name
(students.name
):Substituting qualified
students.name
has an indexing error:The text was updated successfully, but these errors were encountered: