**Describe what's wrong**

> A clear and concise description of what works not as it is supposed to.

Recent versions of topKWeightedState fail on some input types.

OK:

```sql
SELECT topKWeightedState(2)(1, 1)

Query id: d74c6d5b-f4d7-49a4-a0b4-93ef0916f5b4

┌─topKWeightedState(2)(1, 1)─┐
│ @                          │
└────────────────────────────┘

1 rows in set. Elapsed: 0.003 sec. 
```

NOT OK:

```sql
SELECT topKWeightedState(2)(now(), 1)

Query id: 5842828e-5dfc-47ea-b52d-ebfa498b1c92

Exception on client:
Code: 42. DB::Exception: Aggregate function topKWeighted requires two arguments: while receiving packet from 0.0.0.0:9000. (NUMBER_OF_ARGUMENTS_DOESNT_MATCH)

Connecting to 0.0.0.0:9000 as user default.
Connected to ClickHouse server version 21.11.5 revision 54450.
```

When looking for the types:

```sql
DESCRIBE TABLE 
(
    SELECT
        topKWeightedState(2)(1, 1),
        topKWeightedState(2)(now(), 1)
)
FORMAT Vertical

Query id: 62814122-3c1c-470a-b461-6e3b90dabb81

Row 1:
──────
name:               topKWeightedState(2)(1, 1)
type:               AggregateFunction(topKWeighted(2), UInt8, UInt8)
default_type:       
default_expression: 
comment:            
codec_expression:   
ttl_expression:     

Row 2:
──────
name:               topKWeightedState(2)(now(), 1)
type:               AggregateFunction(topKWeighted(2), DateTime)
default_type:       
default_expression: 
comment:            
codec_expression:   
ttl_expression:     

2 rows in set. Elapsed: 0.003 sec. 
```

The `topKWeightedState(2)(now(), 1)` misses the weight type in the aggregate function.


**Does it reproduce on recent release?**

Yes. It happens in `21.11.5.33`. It also happens in `21.9.6.24`, `21.8.11.4`, `21.7.11.3`, and `21.5.9.4`. It works for version `21.3.8.76` and for versions older than that.

**How to reproduce**

With version `21.11.5.33`, run the query:

```
SELECT topKWeightedState(2)(now(), 1)

Query id: dc844e76-250d-42f4-ac67-1ff3c61f57c0

Exception on client:
Code: 42. DB::Exception: Aggregate function topKWeighted requires two arguments: while receiving packet from 0.0.0.0:9000. (NUMBER_OF_ARGUMENTS_DOESNT_MATCH)
```

**Expected behavior**

I would expect to have the behavior found in older releases or the one that you have for some other types:

```sql
SELECT 
    topKWeightedState(2)(now(), 1),
    topKWeightedState(2)(1, 1)

┌─topKWeightedState(2)(now(), 1)─┬─topKWeightedState(2)(1, 1)─┐
│ �k�a@                           │ @                          │
└────────────────────────────────┴────────────────────────────┘

1 rows in set. Elapsed: 0.016 sec. 
```

{
    using AggregateFunctionTopK<DataTypeDate::FieldType, is_weighted>::AggregateFunctionTopK;
    DataTypePtr getReturnType() const override { return std::make_shared<DataTypeArray>(std::make_shared<DataTypeDate>()); }
};
template <bool is_weighted>
class AggregateFunctionTopKDateTime : public AggregateFunctionTopK<DataTypeDateTime::FieldType, is_weighted>
{
    using AggregateFunctionTopK<DataTypeDateTime::FieldType, is_weighted>::AggregateFunctionTopK;
    DataTypePtr getReturnType() const override { return std::make_shared<DataTypeArray>(std::make_shared<DataTypeDateTime>()); }
};
template <bool is_weighted>
static IAggregateFunction * createWithExtraTypes(const DataTypePtr & argument_type, UInt64 threshold, UInt64 load_factor, const Array & params)
{
    WhichDataType which(argument_type);
    if (which.idx == TypeIndex::Date)
        return new AggregateFunctionTopKDate<is_weighted>(threshold, load_factor, {argument_type}, params);
    if (which.idx == TypeIndex::DateTime)
        return new AggregateFunctionTopKDateTime<is_weighted>(threshold, load_factor, {argument_type}, params);
    
    if (argument_type->isValueUnambiguouslyRepresentedInContiguousMemoryRegion())
        return new AggregateFunctionTopKGeneric<true, is_weighted>(threshold, load_factor, argument_type, params);
    else
        return new AggregateFunctionTopKGeneric<false, is_weighted>(threshold, load_factor, argument_type, params);
}
template <bool is_weighted>
AggregateFunctionPtr createAggregateFunctionTopK(const std::string & name, const DataTypes & argument_types, const Array & params, const Settings *)