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 within group clause support for aggregate function builder #1024

Conversation

ivashog
Copy link
Contributor

@ivashog ivashog commented Jun 5, 2024

closes #781

Copy link

vercel bot commented Jun 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kysely ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 10:19am

@ivashog ivashog changed the title Add within group clause support for aggregate functions Add within group clause support for aggregate function builder Jun 5, 2024
@ivashog
Copy link
Contributor Author

ivashog commented Jun 5, 2024

@igalklebanov, I want to consult about the API of the future within group () functionality.
I see the following possible varaints:

  1. Extended - fn.agg('mode').withinGroup(wg => wg.orderBy('field')):
    + : looks like SQL
    - : too verbose; need to create separate WithingGroupBuilder
  2. Simplified - fn.agg('mode').withinGroup('field'), because within group () use only order by expression
  3. Also I can try to implement both variants in one method

@igalklebanov igalklebanov added enhancement New feature or request postgres Related to PostgreSQL api Related to library's API mssql Related to MS SQL Server (MSSQL) oracle Related to Oracle labels Jun 10, 2024
@igalklebanov
Copy link
Member

igalklebanov commented Jun 10, 2024

@igalklebanov, I want to consult about the API of the future within group () functionality. I see the following possible varaints:

  1. Extended - fn.agg('mode').withinGroup(wg => wg.orderBy('field')):
    + : looks like SQL
    - : too verbose; need to create separate WithingGroupBuilder
  2. Simplified - fn.agg('mode').withinGroup('field'), because within group () use only order by expression
  3. Also I can try to implement both variants in one method

Hey 👋

We had a similar situation with filter (where ...). All current SQL specs only support where clause there, so we decided, for simplicity, to just go with filterWhere(...).

So I'd go with withinGroupOrderBy(...) for now. WDYT?

@ivashog
Copy link
Contributor Author

ivashog commented Jun 10, 2024

Hey 👋

We had a similar situation with filter (where ...). All current SQL specs only support where clause there, so we decided, for simplicity, to just go with filterWhere(...).

So I'd go with withinGroupOrderBy(...) for now. WDYT?

OK! We think in the same direction)

c81d766#diff-0e4fd806a08c99c93c0331a3d0e75d4c726e4face483d2e21a9febe03e944593R167

@igalklebanov igalklebanov force-pushed the 781-add-within-group-support-to-aggregate branch from f749602 to 251241c Compare January 9, 2025 09:18
Copy link

pkg-pr-new bot commented Jan 9, 2025

Open in Stackblitzkysely_koa_example

npm i https://pkg.pr.new/kysely-org/kysely@1024

commit: 680df4f

Co-authored-by: Ivashkin Olexiy <[email protected]>
Co-authored-by: Ivashkin Olexiy <[email protected]>
Co-authored-by: Ivashkin Olexiy <[email protected]>
@igalklebanov igalklebanov merged commit 4b73283 into kysely-org:v0.28 Jan 9, 2025
24 checks passed
@igalklebanov
Copy link
Member

Hey 👋

Pushed this through the finish line. It was very good so not a lot of changes - just some minor simplifications. 💪

@igalklebanov igalklebanov self-assigned this Jan 9, 2025
igalklebanov added a commit that referenced this pull request Jan 9, 2025
Co-authored-by: Ivashkin Olexiy <[email protected]>
Co-authored-by: Dev K0te <[email protected]>
Co-authored-by: igalklebanov <[email protected]>
igalklebanov added a commit that referenced this pull request Jan 11, 2025
Co-authored-by: Ivashkin Olexiy <[email protected]>
Co-authored-by: Dev K0te <[email protected]>
Co-authored-by: igalklebanov <[email protected]>
igalklebanov added a commit that referenced this pull request Jan 12, 2025
Co-authored-by: Ivashkin Olexiy <[email protected]>
Co-authored-by: Dev K0te <[email protected]>
Co-authored-by: igalklebanov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to library's API enhancement New feature or request mssql Related to MS SQL Server (MSSQL) oracle Related to Oracle postgres Related to PostgreSQL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add within group (order by ...) clause support for aggregate functions.
2 participants