Support MIN/MAX transformation functions
- Dominant language
- Java
- Stars
- 6.1k
- Forks
- 1.5k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 189
Description
Currently MAX()/MIN() are supported in aggregate functions. But in non aggregate situations, we need to use complex Switch case statements to find MIN/MAX.
It would be great if we can support these functions in a recursive way as well.
Example:
**Current approach:**
```
SELECT
col1,
CASE
WHEN (col4 > col5 and col2 < col4) OR (col5 > col4 and col2 < col5) THEN col2
CASE
WHEN col4 > col5 THEN col4
ELSE
col5
END as final_value
FROM table;
```
**Proposed approach:**
```
SELECT
col1,
MIN(col2, MAX(col4, col5)) as final_value
FROM table;
```
Contributor guide
Research direction
Start by reading the existing aggregate MIN()/MAX() support and the query path for non-aggregate transformation functions. Trace how nested expressions are parsed and evaluated, then define completion as allowing scalar MIN(col2, MAX(col4, col5)) expressions in SELECT queries while retaining aggregate behavior. Add coverage for the nested example and related non-aggregate cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100