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 any_value as a compatibility alias for any #52147

Merged
merged 6 commits into from Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/en/sql-reference/aggregate-functions/reference/any.md
Expand Up @@ -12,3 +12,5 @@ To get a determinate result, you can use the ‘min’ or ‘max’ function ins
In some cases, you can rely on the order of execution. This applies to cases when SELECT comes from a subquery that uses ORDER BY.

When a `SELECT` query has the `GROUP BY` clause or at least one aggregate function, ClickHouse (in contrast to MySQL) requires that all expressions in the `SELECT`, `HAVING`, and `ORDER BY` clauses be calculated from keys or from aggregate functions. In other words, each column selected from the table must be used either in keys or inside aggregate functions. To get behavior like in MySQL, you can put the other columns in the `any` aggregate function.

- Alias: `any_value`
1 change: 1 addition & 0 deletions src/AggregateFunctions/AggregateFunctionAny.cpp
Expand Up @@ -49,6 +49,7 @@ void registerAggregateFunctionsAny(AggregateFunctionFactory & factory)
AggregateFunctionProperties properties = { .returns_default_when_only_null = false, .is_order_dependent = true };

factory.registerFunction("any", { createAggregateFunctionAny, properties });
factory.registerAlias("any_value", "any", AggregateFunctionFactory::CaseInsensitive);
factory.registerFunction("anyLast", { createAggregateFunctionAnyLast, properties });
factory.registerFunction("anyHeavy", { createAggregateFunctionAnyHeavy, properties });

Expand Down
2 changes: 2 additions & 0 deletions tests/queries/0_stateless/02813_any_value.reference
@@ -0,0 +1,2 @@
0
0
3 changes: 3 additions & 0 deletions tests/queries/0_stateless/02813_any_value.sql
@@ -0,0 +1,3 @@
SET max_block_size = 10, max_threads = 1;
select any_value(number) from numbers(10);
select aNy_VaLue(number) from numbers(10);