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 group array last #902

Merged

Conversation

Jasmine-ge
Copy link
Contributor

This function returns the last N elements of an array.

Syntax:
group_array_last(x, max_size)

Parameters

  • x – The input array from which elements are selected.
  • max_size – The maximum number of elements to return. If the array contains more than max_size elements, only the last max_size elements will be returned.

Example
Query:
select group_array_last(number+1, 2) numbers from numbers(10)
Result:

┌─numbers─┐
│ [9, 10] │
└─────────┘

Related to #901

@Jasmine-ge Jasmine-ge requested a review from yl-lisen February 19, 2025 10:33
@Jasmine-ge Jasmine-ge self-assigned this Feb 19, 2025
@Jasmine-ge Jasmine-ge force-pushed the enhancement/issue-901-support-group-array-last-and-others branch from 75d5881 to d46d804 Compare February 20, 2025 03:29
@Jasmine-ge Jasmine-ge marked this pull request as ready for review February 20, 2025 03:31
support group array last

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

* Cleanup DataTypeCustomSimpleAggregateFunction::checkSupportedFunctions()

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>

* Remove unused GroupArrayGeneralListImpl

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>

* 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 <a.khuzhin@semrush.com>

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>

Bugfix/issue 7122 group array missing arg (#7135) (#7198)
@Jasmine-ge Jasmine-ge force-pushed the enhancement/issue-901-support-group-array-last-and-others branch from d46d804 to 53b3a3b Compare February 20, 2025 05:57
@Jasmine-ge Jasmine-ge changed the title fix test and comment support group array last Feb 20, 2025
@jovezhong jovezhong merged commit 249ba03 into develop Mar 6, 2025
21 checks passed
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.

3 participants