```sql
CREATE TABLE dt64test
(`dt64column` DateTime64(3))
ENGINE = MergeTree
PARTITION BY toYYYYMM(dt64column)
ORDER BY dt64column;

INSERT INTO dt64test  VALUES ('2020-01-13 13:37:00');

SELECT 1 FROM dt64test WHERE dt64column = toDateTime('2020-01-13 13:37:00');
DB::Exception: Key expression contains comparison between inconvertible types: DateTime64(3) and DateTime

SELECT 1 FROM dt64test WHERE dt64column = materialize(toDateTime('2020-01-13 13:37:00'));
┌─1─┐
│ 1 │
└───┘
```
#include <DataTypes/DataTypeDateTime.h>
#include <DataTypes/DataTypeDateTime64.h>
#include <DataTypes/DataTypeEnum.h>
#include <DataTypes/DataTypeUUID.h>
#include <DataTypes/DataTypeLowCardinality.h>
#include <DataTypes/DataTypeNullable.h>
#include <Core/AccurateComparison.h>
#include <Common/typeid_cast.h>
#include <Common/NaNUtils.h>
#include <common/DateLUT.h>
#include <DataTypes/DataTypeAggregateFunction.h>
namespace DB
{
namespace ErrorCodes
{
    extern const int ARGUMENT_OUT_OF_BOUND;
    extern const int TYPE_MISMATCH;
}
/** Checking for a `Field from` of `From` type falls to a range of values of type `To`.
  * `From` and `To` - numeric types. They can be floating-point types.
  * `From` is one of UInt64, Int64, Float64,
  *  whereas `To` can also be 8, 16, 32 bit.
  *
  * If falls into a range, then `from` is converted to the `Field` closest to the `To` type.
  * If not, return Field(Null).
  */
namespace
{
template <typename From, typename To>
static Field convertNumericTypeImpl(const Field & from)