mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 11:02:08 +00:00
Merge branch 'master' into dont-cut-single-value
This commit is contained in:
commit
e84ca3134d
@ -1921,6 +1921,19 @@ struct NameParseDateTimeBestEffort;
|
|||||||
struct NameParseDateTimeBestEffortOrZero;
|
struct NameParseDateTimeBestEffortOrZero;
|
||||||
struct NameParseDateTimeBestEffortOrNull;
|
struct NameParseDateTimeBestEffortOrNull;
|
||||||
|
|
||||||
|
template <typename Name, typename ToDataType>
|
||||||
|
constexpr bool mightBeDateTime()
|
||||||
|
{
|
||||||
|
if constexpr (std::is_same_v<ToDataType, DataTypeDateTime64>)
|
||||||
|
return true;
|
||||||
|
else if constexpr (
|
||||||
|
std::is_same_v<Name, NameToDateTime> || std::is_same_v<Name, NameParseDateTimeBestEffort>
|
||||||
|
|| std::is_same_v<Name, NameParseDateTimeBestEffortOrZero> || std::is_same_v<Name, NameParseDateTimeBestEffortOrNull>)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Name, typename ToDataType>
|
template<typename Name, typename ToDataType>
|
||||||
inline bool isDateTime64(const ColumnsWithTypeAndName & arguments)
|
inline bool isDateTime64(const ColumnsWithTypeAndName & arguments)
|
||||||
{
|
{
|
||||||
@ -2190,7 +2203,6 @@ private:
|
|||||||
result_column = ConvertImpl<LeftDataType, RightDataType, Name, FormatSettings::DateTimeOverflowBehavior::Saturate>::execute(arguments, result_type, input_rows_count, from_string_tag, scale);
|
result_column = ConvertImpl<LeftDataType, RightDataType, Name, FormatSettings::DateTimeOverflowBehavior::Saturate>::execute(arguments, result_type, input_rows_count, from_string_tag, scale);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if constexpr (IsDataTypeDateOrDateTime<RightDataType> && std::is_same_v<LeftDataType, DataTypeDateTime64>)
|
else if constexpr (IsDataTypeDateOrDateTime<RightDataType> && std::is_same_v<LeftDataType, DataTypeDateTime64>)
|
||||||
{
|
{
|
||||||
@ -2208,12 +2220,23 @@ private:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if constexpr ((IsDataTypeNumber<LeftDataType>
|
||||||
|
|| IsDataTypeDateOrDateTime<LeftDataType>)&&IsDataTypeDateOrDateTime<RightDataType>)
|
||||||
|
{
|
||||||
#define GENERATE_OVERFLOW_MODE_CASE(OVERFLOW_MODE) \
|
#define GENERATE_OVERFLOW_MODE_CASE(OVERFLOW_MODE) \
|
||||||
case FormatSettings::DateTimeOverflowBehavior::OVERFLOW_MODE: \
|
case FormatSettings::DateTimeOverflowBehavior::OVERFLOW_MODE: \
|
||||||
result_column = ConvertImpl<LeftDataType, RightDataType, Name, FormatSettings::DateTimeOverflowBehavior::OVERFLOW_MODE>::execute( \
|
result_column = ConvertImpl<LeftDataType, RightDataType, Name, FormatSettings::DateTimeOverflowBehavior::OVERFLOW_MODE>::execute( \
|
||||||
arguments, result_type, input_rows_count, from_string_tag); \
|
arguments, result_type, input_rows_count, from_string_tag); \
|
||||||
break;
|
break;
|
||||||
|
switch (date_time_overflow_behavior)
|
||||||
|
{
|
||||||
|
GENERATE_OVERFLOW_MODE_CASE(Throw)
|
||||||
|
GENERATE_OVERFLOW_MODE_CASE(Ignore)
|
||||||
|
GENERATE_OVERFLOW_MODE_CASE(Saturate)
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef GENERATE_OVERFLOW_MODE_CASE
|
||||||
|
}
|
||||||
else if constexpr (IsDataTypeDecimalOrNumber<LeftDataType> && IsDataTypeDecimalOrNumber<RightDataType>)
|
else if constexpr (IsDataTypeDecimalOrNumber<LeftDataType> && IsDataTypeDecimalOrNumber<RightDataType>)
|
||||||
{
|
{
|
||||||
using LeftT = typename LeftDataType::FieldType;
|
using LeftT = typename LeftDataType::FieldType;
|
||||||
@ -2232,31 +2255,18 @@ private:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (date_time_overflow_behavior)
|
result_column = ConvertImpl<LeftDataType, RightDataType, Name>::execute(
|
||||||
{
|
arguments, result_type, input_rows_count, from_string_tag);
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Throw)
|
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Ignore)
|
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Saturate)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if constexpr ((IsDataTypeNumber<LeftDataType> || IsDataTypeDateOrDateTime<LeftDataType>)
|
|
||||||
&& IsDataTypeDateOrDateTime<RightDataType>)
|
|
||||||
{
|
|
||||||
switch (date_time_overflow_behavior)
|
|
||||||
{
|
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Throw)
|
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Ignore)
|
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Saturate)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#undef GENERATE_OVERFLOW_MODE_CASE
|
|
||||||
else
|
else
|
||||||
result_column = ConvertImpl<LeftDataType, RightDataType, Name>::execute(arguments, result_type, input_rows_count, from_string_tag);
|
result_column = ConvertImpl<LeftDataType, RightDataType, Name>::execute(arguments, result_type, input_rows_count, from_string_tag);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if constexpr (mightBeDateTime<Name, ToDataType>())
|
||||||
|
{
|
||||||
if (isDateTime64<Name, ToDataType>(arguments))
|
if (isDateTime64<Name, ToDataType>(arguments))
|
||||||
{
|
{
|
||||||
/// For toDateTime('xxxx-xx-xx xx:xx:xx.00', 2[, 'timezone']) we need to it convert to DateTime64
|
/// For toDateTime('xxxx-xx-xx xx:xx:xx.00', 2[, 'timezone']) we need to it convert to DateTime64
|
||||||
@ -2265,13 +2275,18 @@ private:
|
|||||||
|
|
||||||
if (to_datetime64 || scale != 0) /// When scale = 0, the data type is DateTime otherwise the data type is DateTime64
|
if (to_datetime64 || scale != 0) /// When scale = 0, the data type is DateTime otherwise the data type is DateTime64
|
||||||
{
|
{
|
||||||
if (!callOnIndexAndDataType<DataTypeDateTime64>(from_type->getTypeId(), call, BehaviourOnErrorFromString::ConvertDefaultBehaviorTag))
|
if (!callOnIndexAndDataType<DataTypeDateTime64>(
|
||||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument of function {}",
|
from_type->getTypeId(), call, BehaviourOnErrorFromString::ConvertDefaultBehaviorTag))
|
||||||
arguments[0].type->getName(), getName());
|
throw Exception(
|
||||||
|
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||||
|
"Illegal type {} of argument of function {}",
|
||||||
|
arguments[0].type->getName(),
|
||||||
|
getName());
|
||||||
|
|
||||||
return result_column;
|
return result_column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if constexpr (std::is_same_v<ToDataType, DataTypeString>)
|
if constexpr (std::is_same_v<ToDataType, DataTypeString>)
|
||||||
{
|
{
|
||||||
@ -2468,7 +2483,9 @@ public:
|
|||||||
result_column = executeInternal<ToDataType>(arguments, result_type, input_rows_count,
|
result_column = executeInternal<ToDataType>(arguments, result_type, input_rows_count,
|
||||||
assert_cast<const ToDataType &>(*removeNullable(result_type)).getScale());
|
assert_cast<const ToDataType &>(*removeNullable(result_type)).getScale());
|
||||||
}
|
}
|
||||||
else if (isDateTime64<Name, ToDataType>(arguments))
|
else if constexpr (mightBeDateTime<Name, ToDataType>())
|
||||||
|
{
|
||||||
|
if (isDateTime64<Name, ToDataType>(arguments))
|
||||||
{
|
{
|
||||||
UInt64 scale = to_datetime64 ? DataTypeDateTime64::default_scale : 0;
|
UInt64 scale = to_datetime64 ? DataTypeDateTime64::default_scale : 0;
|
||||||
if (arguments.size() > 1)
|
if (arguments.size() > 1)
|
||||||
@ -2480,7 +2497,13 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result_column = executeInternal<DataTypeDateTime64>(arguments, result_type, input_rows_count, static_cast<UInt32>(scale));
|
result_column
|
||||||
|
= executeInternal<DataTypeDateTime64>(arguments, result_type, input_rows_count, static_cast<UInt32>(scale));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result_column = executeInternal<ToDataType>(arguments, result_type, input_rows_count, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3173,42 +3196,13 @@ private:
|
|||||||
|
|
||||||
if constexpr (IsDataTypeNumber<LeftDataType>)
|
if constexpr (IsDataTypeNumber<LeftDataType>)
|
||||||
{
|
{
|
||||||
if constexpr (IsDataTypeNumber<RightDataType>)
|
if constexpr (IsDataTypeDateOrDateTime<RightDataType>)
|
||||||
{
|
{
|
||||||
#define GENERATE_OVERFLOW_MODE_CASE(OVERFLOW_MODE, ADDITIONS) \
|
#define GENERATE_OVERFLOW_MODE_CASE(OVERFLOW_MODE, ADDITIONS) \
|
||||||
case FormatSettings::DateTimeOverflowBehavior::OVERFLOW_MODE: \
|
case FormatSettings::DateTimeOverflowBehavior::OVERFLOW_MODE: \
|
||||||
result_column = ConvertImpl<LeftDataType, RightDataType, FunctionCastName, FormatSettings::DateTimeOverflowBehavior::OVERFLOW_MODE>::execute( \
|
result_column \
|
||||||
arguments, result_type, input_rows_count, BehaviourOnErrorFromString::ConvertDefaultBehaviorTag, ADDITIONS()); \
|
= ConvertImpl<LeftDataType, RightDataType, FunctionCastName, FormatSettings::DateTimeOverflowBehavior::OVERFLOW_MODE>:: \
|
||||||
break;
|
execute(arguments, result_type, input_rows_count, BehaviourOnErrorFromString::ConvertDefaultBehaviorTag, ADDITIONS()); \
|
||||||
if (wrapper_cast_type == CastType::accurate)
|
|
||||||
{
|
|
||||||
switch (date_time_overflow_behavior)
|
|
||||||
{
|
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Throw, AccurateConvertStrategyAdditions)
|
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Ignore, AccurateConvertStrategyAdditions)
|
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Saturate, AccurateConvertStrategyAdditions)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (date_time_overflow_behavior)
|
|
||||||
{
|
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Throw, AccurateOrNullConvertStrategyAdditions)
|
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Ignore, AccurateOrNullConvertStrategyAdditions)
|
|
||||||
GENERATE_OVERFLOW_MODE_CASE(Saturate, AccurateOrNullConvertStrategyAdditions)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#undef GENERATE_OVERFLOW_MODE_CASE
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if constexpr (std::is_same_v<RightDataType, DataTypeDate> || std::is_same_v<RightDataType, DataTypeDateTime>)
|
|
||||||
{
|
|
||||||
#define GENERATE_OVERFLOW_MODE_CASE(OVERFLOW_MODE, ADDITIONS) \
|
|
||||||
case FormatSettings::DateTimeOverflowBehavior::OVERFLOW_MODE: \
|
|
||||||
result_column = ConvertImpl<LeftDataType, RightDataType, FunctionCastName, FormatSettings::DateTimeOverflowBehavior::OVERFLOW_MODE>::template execute<ADDITIONS>( \
|
|
||||||
arguments, result_type, input_rows_count, BehaviourOnErrorFromString::ConvertDefaultBehaviorTag); \
|
|
||||||
break;
|
break;
|
||||||
if (wrapper_cast_type == CastType::accurate)
|
if (wrapper_cast_type == CastType::accurate)
|
||||||
{
|
{
|
||||||
@ -3229,6 +3223,30 @@ arguments, result_type, input_rows_count, BehaviourOnErrorFromString::ConvertDef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#undef GENERATE_OVERFLOW_MODE_CASE
|
#undef GENERATE_OVERFLOW_MODE_CASE
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if constexpr (IsDataTypeNumber<RightDataType>)
|
||||||
|
{
|
||||||
|
if (wrapper_cast_type == CastType::accurate)
|
||||||
|
{
|
||||||
|
result_column = ConvertImpl<LeftDataType, RightDataType, FunctionCastName>::execute(
|
||||||
|
arguments,
|
||||||
|
result_type,
|
||||||
|
input_rows_count,
|
||||||
|
BehaviourOnErrorFromString::ConvertDefaultBehaviorTag,
|
||||||
|
AccurateConvertStrategyAdditions());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result_column = ConvertImpl<LeftDataType, RightDataType, FunctionCastName>::execute(
|
||||||
|
arguments,
|
||||||
|
result_type,
|
||||||
|
input_rows_count,
|
||||||
|
BehaviourOnErrorFromString::ConvertDefaultBehaviorTag,
|
||||||
|
AccurateOrNullConvertStrategyAdditions());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,4 @@
|
|||||||
# Check after constants refactoring
|
# Check after constants refactoring
|
||||||
02901_parallel_replicas_rollup
|
02901_parallel_replicas_rollup
|
||||||
# Flaky. Please don't delete them without fixing them:
|
# Flaky. Please don't delete them without fixing them:
|
||||||
01287_max_execution_speed
|
|
||||||
02003_WithMergeableStateAfterAggregationAndLimit_LIMIT_BY_LIMIT_OFFSET
|
02003_WithMergeableStateAfterAggregationAndLimit_LIMIT_BY_LIMIT_OFFSET
|
||||||
02404_memory_bound_merging
|
|
||||||
|
Loading…
Reference in New Issue
Block a user