Skip to content

add support for more MySQL aggregate functions and improve their handling. #1188

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

abdala-elgendy
Copy link

@abdala-elgendy abdala-elgendy commented Mar 26, 2025

I've made to improve the handling of aggregate functions in MySQL queries:

  1. 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)

  2. 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

  3. 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;

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

Successfully merging this pull request may close these issues.

1 participant