mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
CLICKHOUSE-1791 add modulo for nonIntegral divisor
This commit is contained in:
parent
7b6f0f5372
commit
e331f15ffd
@ -997,6 +997,10 @@ template <> constexpr bool IsIntegral<DataTypeInt16> = true;
|
||||
template <> constexpr bool IsIntegral<DataTypeInt32> = true;
|
||||
template <> constexpr bool IsIntegral<DataTypeInt64> = true;
|
||||
|
||||
template <typename DataType> constexpr bool IsNonIntegral = false;
|
||||
template <> constexpr bool IsNonIntegral<DataTypeFloat32> = true;
|
||||
template <> constexpr bool IsNonIntegral<DataTypeFloat64> = true;
|
||||
|
||||
template <typename DataType> constexpr bool IsDateOrDateTime = false;
|
||||
template <> constexpr bool IsDateOrDateTime<DataTypeDate> = true;
|
||||
template <> constexpr bool IsDateOrDateTime<DataTypeDateTime> = true;
|
||||
@ -1058,7 +1062,8 @@ public:
|
||||
LeftDataType>,
|
||||
/// Date % Int32 -> int32
|
||||
Case<std::is_same_v<Op, ModuloImpl<T0, T1>>, Switch<
|
||||
Case<IsDateOrDateTime<LeftDataType> && IsIntegral<RightDataType>, RightDataType>>>>;
|
||||
Case<IsDateOrDateTime<LeftDataType> && IsIntegral<RightDataType>, RightDataType>,
|
||||
Case<IsDateOrDateTime<LeftDataType> && IsNonIntegral<RightDataType>, DataTypeInt32>>>>;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
SELECT toDate('21-06-2018') % 234 = toInt16(toDate('21-06-2018')) % 234;
|
||||
SELECT toDate('21-06-2018') % 23456 = toInt16(toDate('21-06-2018')) % 23456;
|
||||
SELECT toDate('21-06-2018') % 12376 = toInt16(toDate('21-06-2018')) % 12376;
|
||||
SELECT toDate('21-06-2018 12:12:12') % 234 = toInt32(toDate('21-06-2018 12:12:12')) % 234;
|
||||
SELECT toDate('21-06-2018 12:12:12') % 23456 = toInt32(toDate('21-06-2018 12:12:12')) % 23456;
|
||||
SELECT toDate('21-06-2018 12:12:12') % 12376 = toInt32(toDate('21-06-2018 12:12:12')) % 12376;
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
|
@ -4,3 +4,9 @@ SELECT toDate('21-06-2018') % 12376 = toInt16(toDate('21-06-2018')) % 12376;
|
||||
SELECT toDate('21-06-2018 12:12:12') % 234 = toInt32(toDate('21-06-2018 12:12:12')) % 234;
|
||||
SELECT toDate('21-06-2018 12:12:12') % 23456 = toInt32(toDate('21-06-2018 12:12:12')) % 23456;
|
||||
SELECT toDate('21-06-2018 12:12:12') % 12376 = toInt32(toDate('21-06-2018 12:12:12')) % 12376;
|
||||
SELECT toDate('21-06-2018') % 234 = toInt16(toDate('21-06-2018')) % 234.8;
|
||||
SELECT toDate('21-06-2018') % 23456 = toInt16(toDate('21-06-2018')) % 23456.8;
|
||||
SELECT toDate('21-06-2018') % 12376 = toInt16(toDate('21-06-2018')) % 12376.8;
|
||||
SELECT toDate('21-06-2018 12:12:12') % 234 = toInt32(toDate('21-06-2018 12:12:12')) % 234.8;
|
||||
SELECT toDate('21-06-2018 12:12:12') % 23456 = toInt32(toDate('21-06-2018 12:12:12')) % 23456.8;
|
||||
SELECT toDate('21-06-2018 12:12:12') % 12376 = toInt32(toDate('21-06-2018 12:12:12')) % 12376.8;
|
||||
|
Loading…
Reference in New Issue
Block a user