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

Support max_by in Aggregation function #12252

Closed
Tracked by #12254
Weijun-H opened this issue Aug 30, 2024 · 5 comments
Closed
Tracked by #12254

Support max_by in Aggregation function #12252

Weijun-H opened this issue Aug 30, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@Weijun-H
Copy link
Member

Weijun-H commented Aug 30, 2024

Is your feature request related to a problem or challenge?

max_by(arg, val)

Description Finds the row with the maximum val. Calculates the arg expression at that row. This function is affected by ordering.
Example max_by(A, B)
Alias(es) argMax(arg, val), arg_max(arg, val)

Describe the solution you'd like

D SELECT max_by(x, y) FROM VALUES ('a', 10), ('b', 50), ('c', 20) AS tab(x, y);
┌──────────────┐
│ max_by(x, y) │
│   varchar    │
├──────────────┤
│ b            │
└──────────────┘

Describe alternatives you've considered

No response

Additional context

https://duckdb.org/docs/sql/functions/aggregates#max_byarg-val
https://docs.databricks.com/en/sql/language-manual/functions/max_by.html

@Lordworms
Copy link
Contributor

take

@korowa
Copy link
Contributor

korowa commented Sep 1, 2024

These probably could be an aliases (with some additional transformations) for first/last aggregation functions -- otherwise there it'll end with two implementations of basically the same function (not something bad, but still redundant).

Relevant discussion -- #12075

@alamb
Copy link
Contributor

alamb commented Sep 9, 2024

Given #12357 we may want to move this function to some other repo rather than the core

@alamb
Copy link
Contributor

alamb commented Sep 16, 2024

Suggestion: #12254 (comment)

@alamb
Copy link
Contributor

alamb commented Sep 25, 2024

We are going to implement these in a different repository so closing this ticket to avoid confusion: #12254 (comment)

@alamb alamb closed this as completed Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants