Fixed converting DateTime64-Field on client into DataTypeDateTime64-field type.

Since DateTime64 is just a typedef, and there is no explicit Field-type
for it, we have to solely rely on type_hint provided by origin column.
If the hint is missing, there is no way of distinguishing DateTime64
from Decimal64.

Alternative could be having explicit converting code, (and it looks like
it has to be added at some point).
This commit is contained in:
Vasily Nemkov 2019-10-04 16:56:29 +03:00
parent a3548b08a9
commit 1069812d88

View File

@ -163,8 +163,17 @@ Field convertFieldToTypeImpl(const Field & src, const IDataType & type, const ID
WhichDataType which_type(type); WhichDataType which_type(type);
WhichDataType which_from_type; WhichDataType which_from_type;
if (from_type_hint) if (from_type_hint)
{
which_from_type = WhichDataType(*from_type_hint); which_from_type = WhichDataType(*from_type_hint);
// This was added to mitigate converting DateTime64-Field (a typedef to a Decimal64) to DataTypeDate64-compatitable type.
if (which_type.idx == which_from_type.idx)
{
// TODO (vnemkov): looks dangerous and requires more testing, as it could break some assumptions in subtle ways.
return src;
}
}
/// Conversion between Date and DateTime and vice versa. /// Conversion between Date and DateTime and vice versa.
if (which_type.isDate() && which_from_type.isDateTime()) if (which_type.isDate() && which_from_type.isDateTime())
{ {