Fix datetime monotonicity check for LC

This commit is contained in:
Antonio Andelic 2023-03-21 18:19:09 +00:00
parent 67bb647a54
commit ad2f5ba0d6
3 changed files with 20 additions and 1 deletions

View File

@ -2,8 +2,10 @@
#include <DataTypes/DataTypeDate.h>
#include <DataTypes/DataTypeDate32.h>
#include <DataTypes/DataTypeDateTime.h>
#include <Functions/IFunction.h>
#include <DataTypes/DataTypeDateTime64.h>
#include <DataTypes/DataTypeLowCardinality.h>
#include <Functions/IFunction.h>
#include <Functions/extractTimeZoneFromFunctionArguments.h>
#include <Functions/DateTimeTransforms.h>
#include <Functions/TransformDateTime64.h>
@ -60,6 +62,9 @@ public:
const auto * type_ptr = &type;
if (const auto * lc_type = checkAndGetDataType<DataTypeLowCardinality>(type_ptr))
type_ptr = lc_type->getDictionaryType().get();
if (const auto * nullable_type = checkAndGetDataType<DataTypeNullable>(type_ptr))
type_ptr = nullable_type->getNestedType().get();

View File

@ -1 +1,2 @@
22 0 1
1970-01-01 02:00:02

View File

@ -1,4 +1,5 @@
DROP TABLE IF EXISTS 02680_datetime64_monotonic_check;
DROP TABLE IF EXISTS 02680_datetime_monotonic_check_lc;
CREATE TABLE 02680_datetime64_monotonic_check (`t` DateTime64(3), `x` Nullable(Decimal(18, 14)))
ENGINE = MergeTree
@ -13,3 +14,15 @@ WHERE toHour_Israel = 0
GROUP BY toHour_UTC, toHour_Israel;
DROP TABLE 02680_datetime64_monotonic_check;
SET allow_suspicious_low_cardinality_types = 1;
CREATE TABLE 02680_datetime_monotonic_check_lc (`timestamp` LowCardinality(UInt32))
ENGINE = MergeTree
ORDER BY timestamp
SETTINGS index_granularity = 1;
INSERT INTO 02680_datetime_monotonic_check_lc VALUES (2);
SELECT toDateTime(timestamp, 'Asia/Jerusalem') FROM 02680_datetime_monotonic_check_lc WHERE toHour(toDateTime(timestamp, 'Asia/Jerusalem')) = 2;
DROP TABLE 02680_datetime_monotonic_check_lc