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

if (load_factor < 1)
                throw Exception("Too small parameter 'load_factor' for aggregate function " + name + ". Minimum: 1",
                    ErrorCodes::ARGUMENT_OUT_OF_BOUND);
        }
        if (k > TOP_K_MAX_SIZE || load_factor > TOP_K_MAX_SIZE || k * load_factor > TOP_K_MAX_SIZE)
            throw Exception("Too large parameter(s) for aggregate function " + name + ". Maximum: " + toString(TOP_K_MAX_SIZE),
                ErrorCodes::ARGUMENT_OUT_OF_BOUND);
        if (k == 0)
            throw Exception("Parameter 0 is illegal for aggregate function " + name,
                ErrorCodes::ARGUMENT_OUT_OF_BOUND);
        threshold = k;
    }
    AggregateFunctionPtr res(createWithNumericType<AggregateFunctionTopK, is_weighted>(
        *argument_types[0], threshold, load_factor, argument_types, params));
    if (!res)
        res = AggregateFunctionPtr(createWithExtraTypes<is_weighted>(argument_types[0], threshold, load_factor, params));
    if (!res)
        throw Exception("Illegal type " + argument_types[0]->getName() +
            " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
    return res;
}
}
void registerAggregateFunctionTopK(AggregateFunctionFactory & factory)
{
    AggregateFunctionProperties properties = { .returns_default_when_only_null = false, .is_order_dependent = true };
    factory.registerFunction("topK", { createAggregateFunctionTopK<false>, properties });
    factory.registerFunction("topKWeighted", { createAggregateFunctionTopK<true>, properties });
}
}