Skip to content

Add -OrderBy combinator#11235

Closed
Sonichka1311 wants to merge 2 commits intoClickHouse:masterfrom
Sonichka1311:order-by
Closed

Add -OrderBy combinator#11235
Sonichka1311 wants to merge 2 commits intoClickHouse:masterfrom
Sonichka1311:order-by

Conversation

@Sonichka1311
Copy link
Copy Markdown
Contributor

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add -OrderBy combinator && change transformArguments signature

@blinkov blinkov added doc-alert pr-feature Pull request with new product feature labels May 27, 2020
@akuzm
Copy link
Copy Markdown
Contributor

akuzm commented May 28, 2020


void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena * arena) const override
{
std::call_once(data(place).initialized, [this, place, columns]() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add is not supposed to be called concurrently on shared data, so the call_once shouldn't be necessary. Or is it?

@akuzm akuzm self-assigned this May 28, 2020
@hczhcz
Copy link
Copy Markdown
Contributor

hczhcz commented May 29, 2020

It is probably good to name it as -Sort considering we are using different terms in SQL functions and statements (sort vs order by, if vs where/having, uniq vs distinct, ...)

Comment on lines +1 to +3
SELECT groupArrayOrderBy(2)(x, y, z) FROM (SELECT number AS x, number % 3 AS y, number % 5 AS z FROM system.numbers LIMIT 10);
SELECT groupArrayOrderBy(1)(x, y) FROM (SELECT number AS x, number % 3 AS y FROM system.numbers_mt LIMIT 10);
SELECT groupArrayOrderBy(1)(x, y) FROM (SELECT number AS x, number AS y FROM system.numbers_mt LIMIT 10);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Lets add some other examples if applicable - not only groupArray.
  2. Negative cases are also useful. Both incorrect column names, and unsupported functions.

@filimonov
Copy link
Copy Markdown
Contributor

#3708

using Array = std::vector<IColumn*>;

Array value;
std::once_flag initialized;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed variant of implementation is not the correct way to implement this task.

@alexey-milovidov
Copy link
Copy Markdown
Member

alexey-milovidov commented Sep 19, 2020

We can implement it again in the following way:

  • the function with OrderBy combinator will have state like groupArray and collect values along with order by fields;
  • only at the finalization step the collected array will be fed to the transformed aggregate function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants