
**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.

size_t src_offsets_size = src_offsets.size();
        auto res_offsets_column = ColumnArray::ColumnOffsets::create(src_offsets_size);
        IColumn::Offsets & res_offsets = res_offsets_column->getData();
        size_t res_pos = 0;
        size_t src_pos = 0;
        for (size_t i = 0; i < src_offsets_size; ++i)
        {
            auto src_offset = src_offsets[i];
            
            if (src_pos < src_offset)
            {
                
                res_values_column->insertFrom(*mapped, src_pos);
                
                ++src_pos;
                ++res_pos;
                for (; src_pos < src_offset; ++src_pos)
                {
                    if (mapped->compareAt(src_pos - 1, src_pos, *mapped, 1))
                    {
                        res_values_column->insertFrom(*mapped, src_pos);
                        ++res_pos;
                    }
                }
            }
            res_offsets[i] = res_pos;
        }
        res_ptr = ColumnArray::create(std::move(res_values_column), std::move(res_offsets_column));
    }
    static ColumnPtr execute(const ColumnArray & array, ColumnPtr mapped)