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

Enhancement/issue 901 support group array sorted #909

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Jasmine-ge
Copy link
Contributor

Please write user-readable short description of the changes:

Returns an array with the first N items in ascending order.
Syntax:
groupArraySorted(column, N)

Parameters:

  • N – The number of elements to return.
  • column – The value (Integer, String, Float and other Generic types).

Example
Get the first 10 numbers:

SELECT group_array_sorted(number, 10) FROM numbers(100)
┌─group_array_sorted(number, 10)─┐
│  [0,1,2,3,4,5,6,7,8,9]         │
└────────────────────────────────┘

Get all the String implementations of all numbers in column:

SELECT group_array_sorted(str, 5) FROM (SELECT to_string(number) as str FROM numbers(5));
┌─group_array_sorted(str, 5)─┐
│  ['0','1','2','3','4']     │
└────────────────────────────┘

related #901

support group array last

Introduce groupArrayLast() (useful to store last X values) (#44521)

* Cleanup DataTypeCustomSimpleAggregateFunction::checkSupportedFunctions()

Signed-off-by: Azat Khuzhin <[email protected]>

* Remove unused GroupArrayGeneralListImpl

Signed-off-by: Azat Khuzhin <[email protected]>

* Introduce groupArrayLast() (useful to store last X values)

Also do some refactoring to make code cleaner:
- rename insert() to insertWithSampler() (since it is used only for
  groupArraySample())
- split merge methods into Last/RNG/...

Signed-off-by: Azat Khuzhin <[email protected]>

Signed-off-by: Azat Khuzhin <[email protected]>

Bugfix/issue 7122 group array missing arg (#7135) (#7198)
@Jasmine-ge Jasmine-ge requested a review from yl-lisen February 20, 2025 09:05
@Jasmine-ge Jasmine-ge self-assigned this Feb 20, 2025
Fix a crash and a leak in AggregateFunctionGroupArraySorted

std::vector

Fix memory like in groupArraySorted

Fix multiple bugs in groupArraySorted

Fix problem detected by ubsan

Fix groupArraySorted documentation

Revert Revert Add new aggregation function groupArraySorted()

Updated implementation

Fixed style check

Fixed code review issues

Fixed code review issues

Revert Add new aggregation function groupArraySorted()

created groupSortedArray by ..Moving
@Jasmine-ge Jasmine-ge force-pushed the enhancement/issue-901-support-group-array-sorted branch from c9e37c2 to 97a32c4 Compare February 20, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant