Hi! I found what seems to be another case related to subqueries inside derived tables, possibly related to #1264.
Problem
A scalar subquery in the SELECT list works by itself, but fails when that SELECT is wrapped as a derived table in FROM.
The error thrown is: text TypeError: Cannot read properties of undefined (reading '0')
Minimal reproducible example
This works:
SELECT (SELECT COUNT(*) FROM tarefas_roadmap_geral) AS qt FROM tarefas_roadmap_geral
But this fails:
SELECT * FROM ( SELECT (SELECT * FROM tarefas_roadmap_geral) FROM tarefas_roadmap_geral ) p
I was also able to simplify it further and noticed that the problem is not specific to COUNT(*). Even changing the inner scalar subquery shape still leads to the same failure pattern.
Additional notes
I originally found this in a bigger query involving UNION ALL, but after simplifying the SQL, it seems the issue can be reproduced without UNION, GROUP BY, or outer aggregation.
So the minimal failing pattern seems to be:
SELECT * FROM ( SELECT (SELECT ...) FROM ... ) p
Hi! I found what seems to be another case related to subqueries inside derived tables, possibly related to #1264.
Problem
A scalar subquery in the
SELECTlist works by itself, but fails when thatSELECTis wrapped as a derived table inFROM.The error thrown is: text TypeError: Cannot read properties of undefined (reading '0')
Minimal reproducible example
This works:
SELECT (SELECT COUNT(*) FROM tarefas_roadmap_geral) AS qt FROM tarefas_roadmap_geralBut this fails:
SELECT * FROM ( SELECT (SELECT * FROM tarefas_roadmap_geral) FROM tarefas_roadmap_geral ) pI was also able to simplify it further and noticed that the problem is not specific to
COUNT(*). Even changing the inner scalar subquery shape still leads to the same failure pattern.Additional notes
I originally found this in a bigger query involving
UNION ALL, but after simplifying the SQL, it seems the issue can be reproduced withoutUNION,GROUP BY, or outer aggregation.So the minimal failing pattern seems to be:
SELECT * FROM ( SELECT (SELECT ...) FROM ... ) p