The InSet expression works on collections of internal Catalyst's types. We can see this in the optimization when In is replaced by InSet, and In's collection is evaluated to internal Catalyst's values: https://github.com/apache/spark/blob/branch-2.4/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala#L253-L254
The code existed before the optimization https://github.com/apache/spark/pull/25754 that made another wrong assumption about collection types.
If InSet accepts only internal Catalyst's types, the following code shouldn't fail:
but it fails with the exception: