21.5.1
```sql

create table test(d Date, k Int64, s String) 
Engine=MergeTree partition by (toYYYYMM(d),k) order by (d, k)

insert into test values ('2020-01-01', 1, '');
insert into test values ('2020-01-02', 1, '');

SELECT * FROM test WHERE d != '2020-01-01'
0 rows in set. Elapsed: 0.003 sec.


SELECT * FROM test WHERE identity(d) !=  '2020-01-01';
┌──────────d─┬─k─┬─s─┐
│ 2020-01-02 │ 1 │   │
└────────────┴───┴───┘

SELECT * FROM test WHERE toDate(d) != '2020-01-01';
┌──────────d─┬─k─┬─s─┐
│ 2020-01-02 │ 1 │   │
└────────────┴───┴───┘
```

DataTypePtr common_type = getLeastSupertype({key_expr_type, const_type});
                    if (!const_type->equals(*common_type))
                    {
                        castValueToType(common_type, const_value, const_type, node);
                        
                        if (!key_expr_type->equals(*common_type))
                            is_constant_transformed = true;
                    }
                    if (!key_expr_type->equals(*common_type))
                    {
                        ColumnsWithTypeAndName arguments{
                            {nullptr, key_expr_type, ""}, {DataTypeString().createColumnConst(1, common_type->getName()), common_type, ""}};
                        FunctionOverloadResolverPtr func_builder_cast
                                = std::make_shared<FunctionOverloadResolverAdaptor>(CastOverloadResolver<CastType::nonAccurate>::createImpl(false));
                        auto func_cast = func_builder_cast->build(arguments);
                        
                        if (!func_cast || (!single_point && !func_cast->hasInformationAboutMonotonicity()))
                            return false;
                        chain.push_back(func_cast);
                    }
                }
            }
            
            if (is_constant_transformed)
            {
                if (func_name == "less")
                    func_name = "lessOrEquals";
                else if (func_name == "greater")
                    func_name = "greaterOrEquals";
            }