```sql
CREATE TABLE test(key Int32) ENGINE = MergeTree ORDER BY (key);
insert into test select intDiv(number,100) from numbers(10000000);
SELECT COUNT() FROM test WHERE key <= 100000 AND (NOT (toLowCardinality('') IN (SELECT '')));


<Fatal> BaseDaemon: ########################################
<Fatal> BaseDaemon: ########################################
<Fatal> BaseDaemon: ########################################
<Fatal> BaseDaemon: (version 22.8.11.15 (official build), build id: 8996F0B199922EB3) (from thread 3020
ey <= 100000 AND (NOT (toLowCardinality('') IN (SELECT '' ))) ;) Received signal Segmentation fault (11
<Fatal> BaseDaemon: (version 22.8.11.15 (official build), build id: 8996F0B199922EB3) (from thread 2281
y <= 100000 AND (NOT (toLowCardinality('') IN (SELECT '' ))) ;) Received signal Segmentation fault (11)
<Fatal> BaseDaemon: (version 22.8.11.15 (official build), build id: 8996F0B199922EB3) (from thread 2524
ey <= 100000 AND (NOT (toLowCardinality('') IN (SELECT '' ))) ;) Received signal Segmentation fault (11
<Fatal> BaseDaemon: Address: 0x7f32028fc000 Access: read. Attempted access has violated the permissions
<Fatal> BaseDaemon: Address: 0x7f324e218000 Access: read. Attempted access has violated the permissions
<Fatal> BaseDaemon: Address: 0x7f323d92a000 Access: read. Attempted access has violated the permissions
<Fatal> BaseDaemon: Stack trace: 0x14663831 0x1465cb43 0xcbaa3ce 0x13ceb847 0x13cec13d 0x13ced5e9 0x149
 0xa4be8bd 0x7f32a7232fa3 0x7f32a71634cf
<Fatal> BaseDaemon: Stack trace: 0x14663831 0x1465cb43 0xcbaa3ce 0x13ceb847 0x13cec13d 0x13ced5e9 0x149
 0xa4be8bd 0x7f32a7232fa3 0x7f32a71634cf
<Fatal> BaseDaemon: Stack trace: 0x14663831 0x1465cb43 0xcbaa3ce 0x13ceb847 0x13cec13d 0x13ced5e9 0x149
 0xa4be8bd 0x7f32a7232fa3 0x7f32a71634cf

```
found in 21.8 but I guess all versions are affected.

100% reproducible with 

```
clickhouse-benchmark <<< "SELECT COUNT() FROM test WHERE key <= 100000 AND (NOT (toLowCardinality('') IN (SELECT '')))"
```

22.12.1.985 returns random results, so I guess it's affected as well.
{
/** in(x, set) - function for evaluating the IN
  * notIn(x, set) - and NOT IN.
  */
template <bool negative, bool global, bool null_is_skipped, bool ignore_set>
struct FunctionInName;
template <> struct FunctionInName<false, false, true, false> { static constexpr auto name = "in"; };
template <> struct FunctionInName<false, true, true, false> { static constexpr auto name = "globalIn"; };
template <> struct FunctionInName<true, false, true, false> { static constexpr auto name = "notIn"; };
template <> struct FunctionInName<true, true, true, false> { static constexpr auto name = "globalNotIn"; };
template <> struct FunctionInName<false, false, false, false> { static constexpr auto name = "nullIn"; };
template <> struct FunctionInName<false, true, false, false> { static constexpr auto name = "globalNullIn"; };
template <> struct FunctionInName<true, false, false, false> { static constexpr auto name = "notNullIn"; };
template <> struct FunctionInName<true, true, false, false> { static constexpr auto name = "globalNotNullIn"; };
template <> struct FunctionInName<false, false, true, true> { static constexpr auto name = "inIgnoreSet"; };
template <> struct FunctionInName<false, true, true, true> { static constexpr auto name = "globalInIgnoreSet"; };
template <> struct FunctionInName<true, false, true, true> { static constexpr auto name = "notInIgnoreSet"; };
template <> struct FunctionInName<true, true, true, true> { static constexpr auto name = "globalNotInIgnoreSet"; };
template <> struct FunctionInName<false, false, false, true> { static constexpr auto name = "nullInIgnoreSet"; };
template <> struct FunctionInName<false, true, false, true> { static constexpr auto name = "globalNullInIgnoreSet"; };
template <> struct FunctionInName<true, false, false, true> { static constexpr auto name = "notNullInIgnoreSet"; };
template <> struct FunctionInName<true, true, false, true> { static constexpr auto name = "globalNotNullInIgnoreSet"; };
template <bool negative, bool global, bool null_is_skipped, bool ignore_set>
class FunctionIn : public IFunction
{
public:
    
    
    static constexpr auto name = FunctionInName<negative, global, null_is_skipped, ignore_set>::name;
    static FunctionPtr create(ContextPtr)