Deduplicate uncorrelated scalar subqueries
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Is your feature request related to a problem or challenge?
Per https://github.com/apache/datafusion/pull/21240#discussion_r3065275637 , if the same subquery (identical SQL text) appears multiple times in a query, it will be planned and evaluated multiple times. In principle it should be fine to evaluate it only once, provided the subquery doesn't contain any volatile functions (e.g., `random()`).
### Describe the solution you'd like
_No response_
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
Contributor guide
Research direction
Start with the discussion in apache/datafusion#21240, which identifies the repeated planning and evaluation of identical scalar subqueries. Trace the query-planning path for uncorrelated scalar subqueries and determine how volatile functions such as random() are identified. Done means identical non-volatile subqueries are evaluated once while volatile subqueries retain their current behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- data-engineering, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100