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
Can't create execution plan for correlated subqueries with JOINs #14671
Comments
If we change this line: https://github.com/crate/crate/blob/master/server/src/main/java/io/crate/planner/operators/LogicalPlanner.java#L399
we get a correct plan involving 2 joins but still execution plan cannot be created as the
In my opinion we should just throw a nicer error for the time being, stating that this kind of correlated join is not supported, and implement this as a feature. |
In a query like: SELECT n.nspname AS schema, t.typname AS typename, t.oid::int4 AS typeid FROM pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem); The filter `EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem)` was placed in-between correlated-join and join: └ CorrelatedJoin[typname, oid, typnamespace, typelem, nspname, oid, (SELECT 1 FROM (el))] (rows=0) └ Filter[EXISTS (SELECT 1 FROM (el))] (rows=0) └ NestedLoopJoin[LEFT | (oid = typnamespace)] (rows=unknown) Given that the filter uses the output of the `CorrelatedJoin`, it must be placed above it, not below. Fixes #14671
In a query like: SELECT n.nspname AS schema, t.typname AS typename, t.oid::int4 AS typeid FROM pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem); The filter `EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem)` was placed in-between correlated-join and join: └ CorrelatedJoin[typname, oid, typnamespace, typelem, nspname, oid, (SELECT 1 FROM (el))] (rows=0) └ Filter[EXISTS (SELECT 1 FROM (el))] (rows=0) └ NestedLoopJoin[LEFT | (oid = typnamespace)] (rows=unknown) Given that the filter uses the output of the `CorrelatedJoin`, it must be placed above it, not below. Fixes #14671
In a query like: SELECT n.nspname AS schema, t.typname AS typename, t.oid::int4 AS typeid FROM pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem); The filter `EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem)` was placed in-between correlated-join and join: └ CorrelatedJoin[typname, oid, typnamespace, typelem, nspname, oid, (SELECT 1 FROM (el))] (rows=0) └ Filter[EXISTS (SELECT 1 FROM (el))] (rows=0) └ NestedLoopJoin[LEFT | (oid = typnamespace)] (rows=unknown) Given that the filter uses the output of the `CorrelatedJoin`, that led to an error: Couldn't create execution plan from logical plan because of: Couldn't find (SELECT 1 FROM (el)) in SourceSymbols The filter must be placed above the correlated join, not below. Fixes #14671
In a query like: SELECT n.nspname AS schema, t.typname AS typename, t.oid::int4 AS typeid FROM pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem); The filter `EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem)` was placed in-between correlated-join and join: └ CorrelatedJoin[typname, oid, typnamespace, typelem, nspname, oid, (SELECT 1 FROM (el))] (rows=0) └ Filter[EXISTS (SELECT 1 FROM (el))] (rows=0) └ NestedLoopJoin[LEFT | (oid = typnamespace)] (rows=unknown) Given that the filter uses the output of the `CorrelatedJoin`, that led to an error: Couldn't create execution plan from logical plan because of: Couldn't find (SELECT 1 FROM (el)) in SourceSymbols The filter must be placed above the correlated join, not below. Fixes #14671
In a query like: SELECT n.nspname AS schema, t.typname AS typename, t.oid::int4 AS typeid FROM pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem); The filter `EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem)` was placed in-between correlated-join and join: └ CorrelatedJoin[typname, oid, typnamespace, typelem, nspname, oid, (SELECT 1 FROM (el))] (rows=0) └ Filter[EXISTS (SELECT 1 FROM (el))] (rows=0) └ NestedLoopJoin[LEFT | (oid = typnamespace)] (rows=unknown) Given that the filter uses the output of the `CorrelatedJoin`, that led to an error: Couldn't create execution plan from logical plan because of: Couldn't find (SELECT 1 FROM (el)) in SourceSymbols The filter must be placed above the correlated join, not below. Fixes #14671 (cherry picked from commit fec2966)
In a query like: SELECT n.nspname AS schema, t.typname AS typename, t.oid::int4 AS typeid FROM pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem); The filter `EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem)` was placed in-between correlated-join and join: └ CorrelatedJoin[typname, oid, typnamespace, typelem, nspname, oid, (SELECT 1 FROM (el))] (rows=0) └ Filter[EXISTS (SELECT 1 FROM (el))] (rows=0) └ NestedLoopJoin[LEFT | (oid = typnamespace)] (rows=unknown) Given that the filter uses the output of the `CorrelatedJoin`, that led to an error: Couldn't create execution plan from logical plan because of: Couldn't find (SELECT 1 FROM (el)) in SourceSymbols The filter must be placed above the correlated join, not below. Fixes #14671 (cherry picked from commit fec2966)
In a query like: SELECT n.nspname AS schema, t.typname AS typename, t.oid::int4 AS typeid FROM pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem); The filter `EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem)` was placed in-between correlated-join and join: └ CorrelatedJoin[typname, oid, typnamespace, typelem, nspname, oid, (SELECT 1 FROM (el))] (rows=0) └ Filter[EXISTS (SELECT 1 FROM (el))] (rows=0) └ NestedLoopJoin[LEFT | (oid = typnamespace)] (rows=unknown) Given that the filter uses the output of the `CorrelatedJoin`, that led to an error: Couldn't create execution plan from logical plan because of: Couldn't find (SELECT 1 FROM (el)) in SourceSymbols The filter must be placed above the correlated join, not below. Fixes #14671 (cherry picked from commit fec2966)
In a query like: SELECT n.nspname AS schema, t.typname AS typename, t.oid::int4 AS typeid FROM pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem); The filter `EXISTS (SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem)` was placed in-between correlated-join and join: └ CorrelatedJoin[typname, oid, typnamespace, typelem, nspname, oid, (SELECT 1 FROM (el))] (rows=0) └ Filter[EXISTS (SELECT 1 FROM (el))] (rows=0) └ NestedLoopJoin[LEFT | (oid = typnamespace)] (rows=unknown) Given that the filter uses the output of the `CorrelatedJoin`, that led to an error: Couldn't create execution plan from logical plan because of: Couldn't find (SELECT 1 FROM (el)) in SourceSymbols The filter must be placed above the correlated join, not below. Fixes #14671 (cherry picked from commit fec2966)
CrateDB version
5.4
CrateDB setup information
No response
Problem description
When trying to connect to Beekeeper Studio the connection fails. This seems to be related to a 🐛 connected to correlated subqueries.
the query Beekeeper is trying to run
fails with
Steps to Reproduce
Actual Result
Expected Result
query works
The text was updated successfully, but these errors were encountered: