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

Add SQL query planning support for EXISTS subqueries #2219

Closed
Tracked by #474 ...
andygrove opened this issue Apr 12, 2022 · 0 comments · Fixed by #2344
Closed
Tracked by #474 ...

Add SQL query planning support for EXISTS subqueries #2219

andygrove opened this issue Apr 12, 2022 · 0 comments · Fixed by #2344
Labels
enhancement New feature or request

Comments

@andygrove
Copy link
Member

andygrove commented Apr 12, 2022

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
As a user of the DataFusion library for SQL parsing and logical query planning, I would like to be able to produce a valid logical plan from a SQL query containing an EXISTS subquery instead of failing with Unsupported ast node Exists.

Example query: SELECT * FROM a WHERE EXISTS (SELECT * FROM b WHERE a.id = b.id)

Describe the solution you'd like
The SQL should parse without error and produce a valid logical plan.

For reference, here is an example query and logical plan from Apache Spark:

scala> val df = spark.sql("SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t2 WHERE t1.id = t2.id)")
df: org.apache.spark.sql.DataFrame = [id: int, name: string]

scala> df.queryExecution.logical 
res5: org.apache.spark.sql.catalyst.plans.logical.LogicalPlan =
'Project [*]
+- 'Filter exists#16 []
   :  +- 'Project [*]
   :     +- 'Filter ('t1.id = 't2.id)
   :        +- 'UnresolvedRelation [t2], [], false
   +- 'UnresolvedRelation [t1], [], false

Describe alternatives you've considered
None

Additional context
This is a subset of issue #123 which aims to add full support for EXISTS, including a physical plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant