This commit is contained in:
Lucas Chang 2023-05-28 10:40:34 +08:00
parent 864ba06029
commit 93415789d7
2 changed files with 4 additions and 4 deletions

View File

@ -192,11 +192,11 @@ Field convertFieldToTypeImpl(const Field & src, const IDataType & type, const ID
{
return static_cast<const DataTypeDateTime &>(type).getTimeZone().fromDayNum(DayNum(src.get<Int32>()));
}
else if(which_type.isDateTime64() && which_from_type.isDate()) {
else if (which_type.isDateTime64() && which_from_type.isDate()) {
const auto value = static_cast<const DataTypeDateTime64 &>(type).getTimeZone().fromDayNum(DayNum(src.get<UInt64>()));
return DecimalUtils::decimalFromComponentsWithMultiplier<DateTime64>(value, 0, 1);
}
else if(which_type.isDateTime64() && which_from_type.isDate32()) {
else if (which_type.isDateTime64() && which_from_type.isDate32()) {
const auto value = static_cast<const DataTypeDateTime64 &>(type).getTimeZone().fromDayNum(DayNum(src.get<Int32>()));
return DecimalUtils::decimalFromComponentsWithMultiplier<DateTime64>(value, 0, 1);
}

View File

@ -3,7 +3,7 @@ DROP TABLE IF EXISTS datetime64_index_tbl;
CREATE TABLE datetime64_index_tbl(ts DateTime64(3, 'UTC')) ENGINE=MergeTree ORDER BY ts;
INSERT INTO datetime64_index_tbl(ts) VALUES(toDateTime64('2023-05-27 00:00:00', 3, 'UTC'));
SELECT ts from datetime64_index_tbl where ts < toDate('2023-05-28');
SELECT ts from datetime64_index_tbl where ts < toDate32('2023-05-28');
SELECT ts FROM datetime64_index_tbl WHERE ts < toDate('2023-05-28');
SELECT ts FROM datetime64_index_tbl WHERE ts < toDate32('2023-05-28');
DROP TABLE datetime64_index_tbl;