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

planner ignores subqueries #748

Closed
kszucs opened this issue Nov 22, 2022 · 2 comments
Closed

planner ignores subqueries #748

kszucs opened this issue Nov 22, 2022 · 2 comments

Comments

@kszucs
Copy link
Contributor

kszucs commented Nov 22, 2022

SELECT *
FROM star1
WHERE `f` > (
  SELECT avg(`f`) AS `mean`
  FROM star1
)

output plan after

expr = sg.parse_one(sqlstring, dialect)
tree = sgo.optimize(expr, catalog.to_sqlglot(), rules=sgo.RULES)
plan = sgp.Plan(tree)
print(plan.root)
- Scan: star1
    Context:
      Source: "star1" AS "star1"
    Projections:
      - "star1"."c" AS "c"
      - "star1"."f" AS "f"
      - "star1"."foo_id" AS "foo_id"
      - "star1"."bar_id" AS "bar_id"
    Condition: "star1"."f" > (SELECT AVG("star1"."f") AS "mean" FROM "star1" AS "star1")

I'd expect the select to be converted as an aggregate dependency of the root scan.

@tobymao
Copy link
Owner

tobymao commented Nov 22, 2022

subqueries are not supported yet

tobymao added a commit that referenced this issue Nov 25, 2022
@tobymao
Copy link
Owner

tobymao commented Nov 25, 2022

scalar subqueries are now converted into cross joins

tobymao added a commit that referenced this issue Nov 25, 2022
* unnest scalar subqueries as cross joins

fixes #748

* pass up to tpc-h 17

* more tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants