add support for more MySQL aggregate functions and improve their handling. #1188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've made to improve the handling of aggregate functions in MySQL queries:
Added support for window functions:
Added a new generateWindowSpecification() method that creates window function specifications
Window specifications can include:
PARTITION BY clause
ORDER BY clause
Frame clause (ROWS or RANGE based)
Enhanced aggregate function handling:
Added tracking of whether a window function has been generated
Randomly decides whether to add a window specification to aggregate functions
Improved query generation:
Better handling of GROUP BY clauses when aggregates are present
Proper tracking of columns for grouping
Support for HAVING clauses with aggregate conditions
Example for generated queries now
Query with Both Aggregates and Window Functions
SELECT columnn1, COUNT(DISTINCT column2), GROUP_CONCAT(column3) OVER (PARTITION BY column4), MAX(column5) OVER (ORDER BY column6 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM table1 GROUP BY column7, column8 HAVING SUM(column9) > 1000 ORDER BY column10 ASC LIMIT 20;