mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 11:02:08 +00:00
fixed filling transform
This commit is contained in:
parent
f60a944483
commit
cf244689a2
2
contrib/replxx
vendored
2
contrib/replxx
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 9460e5e0fc10f78f460af26a6bd928798cac864d
|
Subproject commit c745b3fb012ee5ae762fbc8cd7a40c4dc3fe15df
|
@ -84,12 +84,12 @@ struct AddMicrosecondsImpl
|
|||||||
Int64 multiplier = DecimalUtils::scaleMultiplier<DateTime64>(std::abs(6 - scale));
|
Int64 multiplier = DecimalUtils::scaleMultiplier<DateTime64>(std::abs(6 - scale));
|
||||||
if (scale <= 6)
|
if (scale <= 6)
|
||||||
{
|
{
|
||||||
auto division = std::div( (t.fractional + delta), static_cast<Int64>(10e6));
|
auto division = std::div((t.fractional + delta), static_cast<Int64>(10e6));
|
||||||
return {t.whole * multiplier + division.quot, division.rem};
|
return {t.whole * multiplier + division.quot, division.rem};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto division = std::div( (t.fractional + delta * multiplier), static_cast<Int64>(10e6 * multiplier));
|
auto division = std::div((t.fractional + delta * multiplier), static_cast<Int64>(10e6 * multiplier));
|
||||||
return {t.whole + division.quot, division.rem};
|
return {t.whole + division.quot, division.rem};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,12 +136,12 @@ struct AddMillisecondsImpl
|
|||||||
Int64 multiplier = DecimalUtils::scaleMultiplier<DateTime64>(std::abs(3 - scale));
|
Int64 multiplier = DecimalUtils::scaleMultiplier<DateTime64>(std::abs(3 - scale));
|
||||||
if (scale <= 3)
|
if (scale <= 3)
|
||||||
{
|
{
|
||||||
auto division = std::div( (t.fractional + delta), static_cast<Int64>(1000));
|
auto division = std::div((t.fractional + delta), static_cast<Int64>(1000));
|
||||||
return {t.whole * multiplier + division.quot, division.rem};
|
return {t.whole * multiplier + division.quot, division.rem};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto division = std::div( (t.fractional + delta * multiplier), static_cast<Int64>(1000 * multiplier));
|
auto division = std::div((t.fractional + delta * multiplier), static_cast<Int64>(1000 * multiplier));
|
||||||
return {t.whole + division.quot,division.rem};
|
return {t.whole + division.quot,division.rem};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,11 +157,13 @@ namespace
|
|||||||
|
|
||||||
static UInt32 execute(Int32, UInt64, const DateLUTImpl &, Int64) { return dateIsNotSupported(function_name); }
|
static UInt32 execute(Int32, UInt64, const DateLUTImpl &, Int64) { return dateIsNotSupported(function_name); }
|
||||||
|
|
||||||
static UInt32 execute(UInt32 t, UInt64 hours, const DateLUTImpl & time_zone, Int64) {
|
static UInt32 execute(UInt32 t, UInt64 hours, const DateLUTImpl & time_zone, Int64)
|
||||||
|
{
|
||||||
return time_zone.toStartOfHourInterval(t, hours);
|
return time_zone.toStartOfHourInterval(t, hours);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UInt32 execute(Int64 t, UInt64 hours, const DateLUTImpl & time_zone, Int64 scale_multiplier) {
|
static UInt32 execute(Int64 t, UInt64 hours, const DateLUTImpl & time_zone, Int64 scale_multiplier)
|
||||||
|
{
|
||||||
return time_zone.toStartOfHourInterval(t / scale_multiplier, hours);
|
return time_zone.toStartOfHourInterval(t / scale_multiplier, hours);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -40,7 +40,7 @@ static FillColumnDescription::StepFunction getStepFunction(
|
|||||||
{
|
{
|
||||||
#define DECLARE_CASE(NAME) \
|
#define DECLARE_CASE(NAME) \
|
||||||
case IntervalKind::NAME: \
|
case IntervalKind::NAME: \
|
||||||
return [step, scale, &date_lut](Field & field) { field = Add##NAME##sImpl::execute(get<DecimalField<DateTime64>>(field).getValue(), step, date_lut, scale); };
|
return [step, scale, &date_lut](Field & field) { field = Add##NAME##sImpl::execute(get<T>(field), step, date_lut, scale); };
|
||||||
|
|
||||||
FOR_EACH_INTERVAL_KIND(DECLARE_CASE)
|
FOR_EACH_INTERVAL_KIND(DECLARE_CASE)
|
||||||
#undef DECLARE_CASE
|
#undef DECLARE_CASE
|
||||||
@ -113,7 +113,7 @@ static bool tryConvertFields(FillColumnDescription & descr, const DataTypePtr &
|
|||||||
descr.step_func = [step, &time_zone = date_time64->getTimeZone()](Field & field) \
|
descr.step_func = [step, &time_zone = date_time64->getTimeZone()](Field & field) \
|
||||||
{ \
|
{ \
|
||||||
auto field_decimal = get<DecimalField<DateTime64>>(field); \
|
auto field_decimal = get<DecimalField<DateTime64>>(field); \
|
||||||
auto res = Add##NAME##sImpl::execute(field_decimal.getValue(), step, time_zone, field_decimal.getScaleMultiplier()); \
|
auto res = Add##NAME##sImpl::execute(field_decimal.getValue(), step, time_zone, field_decimal.getScale()); \
|
||||||
field = DecimalField(res, field_decimal.getScale()); \
|
field = DecimalField(res, field_decimal.getScale()); \
|
||||||
}; \
|
}; \
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user