Currently, there are few issues with the token() function validation.
It is possible to call the function with a wrong number of arguments, which could lead to a Null Pointer Exception.
Here is an example:
The fix is trivial, here is an example: https://github.com/apache/cassandra/compare/trunk...AlexDenisov:token_crash
However, it uncovers the second issue.
The token function can be called either without parameters or with N parameters (where N = # of partition keys). The patch would not allow this to happen.
The same goes for a function call validation as a part of where clause:
I do not see any obvious solution here. Since the token() function is special I could only suggest extending the `Function` class with an additional method (e.g. isTokenFunction()), and validate the number of passed parameters accordingly.