mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
fix tests
This commit is contained in:
parent
969c7f36a5
commit
3027f3a04f
@ -117,9 +117,6 @@ public:
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||
"The timezone argument of function {} with interval type {} is allowed only when the 1st argument has the type DateTime or DateTime64",
|
||||
getName(), interval_type->getKind().toString());
|
||||
|
||||
if (arguments[0].type.get() != arguments[2].type.get())
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Datetime argument and origin argument for function {} must have the same type", getName());
|
||||
}
|
||||
else if (isDateOrDate32OrDateTimeOrDateTime64(type_arg3))
|
||||
{
|
||||
@ -137,7 +134,6 @@ public:
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of 3rd argument of function {}. "
|
||||
"This argument is optional and must be a constant String with timezone name or a Date/Date32/DateTime/DateTime64 with a constant origin",
|
||||
type_arg3->getName(), getName());
|
||||
|
||||
};
|
||||
|
||||
auto check_fourth_argument = [&]
|
||||
@ -365,14 +361,20 @@ private:
|
||||
result_data.resize(size);
|
||||
|
||||
Int64 scale_multiplier = DecimalUtils::scaleMultiplier<DateTime64>(scale);
|
||||
Int64 scale_on_precision = decideScaleOnPrecision<unit>(scale);
|
||||
Int64 scale_diff = scale_on_precision > scale_multiplier ? scale_on_precision / scale_multiplier : scale_multiplier / scale_on_precision;
|
||||
Int64 scale_on_interval = decideScaleOnPrecision<unit>(scale);
|
||||
Int64 scale_diff = scale_on_interval > scale_multiplier ? scale_on_interval / scale_multiplier : scale_multiplier / scale_on_interval;
|
||||
|
||||
if (origin_column.column == nullptr)
|
||||
{
|
||||
for (size_t i = 0; i != size; ++i)
|
||||
{
|
||||
result_data[i] = 0;
|
||||
if (scale_on_interval < scale_multiplier)
|
||||
result_data[i] += static_cast<ToFieldType>(ToStartOfInterval<unit>::execute(time_data[i], num_units, time_zone, scale_multiplier)) * scale_diff;
|
||||
else
|
||||
result_data[i] = static_cast<ToFieldType>(ToStartOfInterval<unit>::execute(time_data[i], num_units, time_zone, scale_multiplier));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt64 origin = origin_column.column->get64(0);
|
||||
@ -403,11 +405,10 @@ private:
|
||||
if (isDate(result_type) || isDate32(result_type))
|
||||
res = res / SECONDS_PER_DAY;
|
||||
|
||||
if (scale_on_precision > scale_multiplier)
|
||||
if (scale_on_interval > scale_multiplier)
|
||||
result_data[i] += (origin + res / scale_diff) * scale_diff;
|
||||
else if (scale_on_precision == scale_multiplier && scale_on_precision % 1000 != 0 && scale_multiplier != 10) /// when it's not a default case with DateTime
|
||||
/// and when precision is not sub-scale
|
||||
result_data[i] += origin + (res * scale_on_precision);
|
||||
else if (scale_on_interval == scale_multiplier && scale_on_interval % 1000 != 0 && scale_multiplier != 10)
|
||||
result_data[i] += origin + (res * scale_on_interval);
|
||||
else
|
||||
result_data[i] += origin + res * scale_diff;
|
||||
}
|
||||
|
@ -10,25 +10,25 @@ test intervals
|
||||
- test microseconds
|
||||
1980-12-12 12:12:12.123456
|
||||
1980-12-12 12:12:12.123400
|
||||
1980-12-12 12:12:12.123456
|
||||
1980-12-12 12:12:12.123456
|
||||
1980-12-12 12:12:12.12345600
|
||||
1980-12-12 12:12:12.12345600
|
||||
1930-12-12 12:12:12.123456
|
||||
1930-12-12 12:12:12.123400
|
||||
1930-12-12 12:12:12.123456
|
||||
1930-12-12 12:12:12.12345600
|
||||
2220-12-12 12:12:12.123456
|
||||
2220-12-12 12:12:12.123400
|
||||
2220-12-12 12:12:12.123456
|
||||
2220-12-12 12:12:12.12345600
|
||||
- test milliseconds
|
||||
1980-12-12 12:12:12.123
|
||||
1980-12-12 12:12:12.120
|
||||
1980-12-12 12:12:12.123
|
||||
1980-12-12 12:12:12.123
|
||||
1980-12-12 12:12:12.123000
|
||||
1980-12-12 12:12:12.123000
|
||||
1930-12-12 12:12:12.123
|
||||
1930-12-12 12:12:12.120
|
||||
1930-12-12 12:12:12.123
|
||||
1930-12-12 12:12:12.123000
|
||||
2220-12-12 12:12:12.123
|
||||
2220-12-12 12:12:12.120
|
||||
2220-12-12 12:12:12.123
|
||||
2220-12-12 12:12:12.123000
|
||||
test add[...]seconds()
|
||||
- test nanoseconds
|
||||
1980-12-12 12:12:12.123456790
|
||||
|
Loading…
Reference in New Issue
Block a user