mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 19:12:03 +00:00
.
This commit is contained in:
parent
ff9c0934ce
commit
3e7041c1f4
@ -169,21 +169,21 @@ public:
|
|||||||
Int64 time = date_lut.toNumYYYYMMDDhhmmss(input_column_data[i] / deg);
|
Int64 time = date_lut.toNumYYYYMMDDhhmmss(input_column_data[i] / deg);
|
||||||
Int64 fraction = input_column_data[i] % deg;
|
Int64 fraction = input_column_data[i] % deg;
|
||||||
|
|
||||||
result_data[i] = getChangedDate(time, new_value_column_data[i], input_type, result_type, date_lut, scale, fraction);
|
result_data[i] = getChangedDate(time, new_value_column_data[i], result_type, date_lut, scale, fraction);
|
||||||
}
|
}
|
||||||
else if constexpr (isDate32<DataType>() && isDateTime64<ResultDataType>())
|
else if constexpr (isDate32<DataType>() && isDateTime64<ResultDataType>())
|
||||||
{
|
{
|
||||||
const auto & date_lut = DateLUT::instance();
|
const auto & date_lut = DateLUT::instance();
|
||||||
Int64 time = static_cast<Int64>(date_lut.toNumYYYYMMDD(ExtendedDayNum(input_column_data[i]))) * 1'000'000;
|
Int64 time = static_cast<Int64>(date_lut.toNumYYYYMMDD(ExtendedDayNum(input_column_data[i]))) * 1'000'000;
|
||||||
|
|
||||||
result_data[i] = getChangedDate(time, new_value_column_data[i], input_type, result_type, date_lut, 3, 0);
|
result_data[i] = getChangedDate(time, new_value_column_data[i], result_type, date_lut, 3, 0);
|
||||||
}
|
}
|
||||||
else if constexpr (isDateTime<DataType>())
|
else if constexpr (isDateTime<DataType>())
|
||||||
{
|
{
|
||||||
const auto & date_lut = typeid_cast<const DataTypeDateTime &>(*result_type).getTimeZone();
|
const auto & date_lut = typeid_cast<const DataTypeDateTime &>(*result_type).getTimeZone();
|
||||||
Int64 time = date_lut.toNumYYYYMMDDhhmmss(input_column_data[i]);
|
Int64 time = date_lut.toNumYYYYMMDDhhmmss(input_column_data[i]);
|
||||||
|
|
||||||
result_data[i] = static_cast<UInt32>(getChangedDate(time, new_value_column_data[i], input_type, result_type, date_lut));
|
result_data[i] = static_cast<UInt32>(getChangedDate(time, new_value_column_data[i], result_type, date_lut));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -195,11 +195,11 @@ public:
|
|||||||
time = static_cast<Int64>(date_lut.toNumYYYYMMDD(ExtendedDayNum(input_column_data[i]))) * 1'000'000;
|
time = static_cast<Int64>(date_lut.toNumYYYYMMDD(ExtendedDayNum(input_column_data[i]))) * 1'000'000;
|
||||||
|
|
||||||
if (isDate(result_type))
|
if (isDate(result_type))
|
||||||
result_data[i] = static_cast<UInt16>(getChangedDate(time, new_value_column_data[i], input_type, result_type, date_lut));
|
result_data[i] = static_cast<UInt16>(getChangedDate(time, new_value_column_data[i], result_type, date_lut));
|
||||||
else if (isDate32(result_type))
|
else if (isDate32(result_type))
|
||||||
result_data[i] = static_cast<Int32>(getChangedDate(time, new_value_column_data[i], input_type, result_type, date_lut));
|
result_data[i] = static_cast<Int32>(getChangedDate(time, new_value_column_data[i], result_type, date_lut));
|
||||||
else
|
else
|
||||||
result_data[i] = static_cast<UInt32>(getChangedDate(time, new_value_column_data[i], input_type, result_type, date_lut));
|
result_data[i] = static_cast<UInt32>(getChangedDate(time, new_value_column_data[i], result_type, date_lut));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ public:
|
|||||||
return result_column;
|
return result_column;
|
||||||
}
|
}
|
||||||
|
|
||||||
Int64 getChangedDate(Int64 time, Float64 new_value, const DataTypePtr & input_type, const DataTypePtr & result_type, const DateLUTImpl & date_lut, Int64 scale = 0, Int64 fraction = 0) const
|
Int64 getChangedDate(Int64 time, Float64 new_value, const DataTypePtr & result_type, const DateLUTImpl & date_lut, Int64 scale = 0, Int64 fraction = 0) const
|
||||||
{
|
{
|
||||||
auto year = time / 10'000'000'000;
|
auto year = time / 10'000'000'000;
|
||||||
auto month = (time % 10'000'000'000) / 100'000'000;
|
auto month = (time % 10'000'000'000) / 100'000'000;
|
||||||
@ -298,20 +298,12 @@ public:
|
|||||||
if (isDateOrDate32(result_type))
|
if (isDateOrDate32(result_type))
|
||||||
result = date_lut.makeDayNum(year, month, day);
|
result = date_lut.makeDayNum(year, month, day);
|
||||||
else if (isDateTime(result_type))
|
else if (isDateTime(result_type))
|
||||||
{
|
|
||||||
result = date_lut.makeDateTime(year, month, day, hours, minutes, seconds);
|
result = date_lut.makeDateTime(year, month, day, hours, minutes, seconds);
|
||||||
if (isDate(input_type))
|
|
||||||
result += date_lut.timezoneOffset(result);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
result = DecimalUtils::decimalFromComponents<DateTime64>(
|
result = DecimalUtils::decimalFromComponents<DateTime64>(
|
||||||
date_lut.makeDateTime(year, month, day, hours, minutes, seconds),
|
date_lut.makeDateTime(year, month, day, hours, minutes, seconds),
|
||||||
static_cast<Int64>(fraction),
|
static_cast<Int64>(fraction),
|
||||||
static_cast<UInt32>(scale));
|
static_cast<UInt32>(scale));
|
||||||
if (isDate32(input_type))
|
|
||||||
result += date_lut.timezoneOffset(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result > max_date)
|
if (result > max_date)
|
||||||
return max_date;
|
return max_date;
|
||||||
|
Loading…
Reference in New Issue
Block a user