
**Describe the unexpected behaviour**

Current implementation of arrayCompact does not behave as other higher-order functions: it accepts lambda function as its first argument, but then it compacts array returned by lambda, not original array (see below for example).

**How to reproduce**
* Which ClickHouse server version to use

Any modern

* Queries to run that lead to unexpected result

select arrayCompact(x -> x.2 , groupArray(tuple(number, intDiv(number, 3) % 3))) from numbers(10);

**Expected behavior**

arrayCompact shall follow normal higher-order functons way and use results of lambda function ([0,0,0,1,1,1,2,2,2,0]) to compact original array ([(0,0),(1,0),(2,0),(3,1),(4,1),(5,1),(6,2),(7,2),(8,2),(9,0)]) into [(0,0),(3,1),(6,2),(9,0)]

**Additional context**

Use case: timeseries (time, value) with lots of repeated values that shall be compacted into (first time, value) when value repeats.

#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/DataTypesDecimal.h>
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnDecimal.h>
#include <Common/HashTable/HashTable.h>
#include <Functions/array/FunctionArrayMapped.h>
#include <Functions/FunctionFactory.h>
namespace DB
{
namespace ErrorCodes
{
}
struct ArrayCompactImpl
{
    static bool needBoolean() { return false; }