add monotonic estimation for DateTime64 in toDayOfWeek, add test

This commit is contained in:
Yakov Olkhovskiy 2024-11-13 02:42:31 +00:00
parent 2e3145c757
commit f7c46114f4
3 changed files with 23 additions and 0 deletions

View File

@ -56,6 +56,21 @@ public:
: is_not_monotonic;
}
if (checkAndGetDataType<DataTypeDateTime64>(&type))
{
const auto & left_date_time = left.safeGet<DateTime64>();
TransformDateTime64<Transform> transformer_left(left_date_time.getScale());
const auto & right_date_time = right.safeGet<DateTime64>();
TransformDateTime64<Transform> transformer_right(right_date_time.getScale());
return transformer_left.execute(left_date_time.getValue(), date_lut)
== transformer_right.execute(right_date_time.getValue(), date_lut)
? is_monotonic
: is_not_monotonic;
}
return Transform::FactorTransform::execute(UInt32(left.safeGet<UInt64>()), date_lut)
== Transform::FactorTransform::execute(UInt32(right.safeGet<UInt64>()), date_lut)
? is_monotonic

View File

@ -0,0 +1,7 @@
DROP TABLE IF EXISTS decimal_dt;
CREATE TABLE decimal_dt (timestamp DateTime64(9)) ENGINE=MergeTree() ORDER BY timestamp;
INSERT INTO decimal_dt VALUES (toDate('2024-11-11')),(toDate('2024-11-12')),(toDate('2024-11-13')),(toDate('2024-11-14')),(toDate('2024-11-15')),(toDate('2024-11-16')),(toDate('2024-11-17'));
SELECT count() FROM decimal_dt WHERE toDayOfWeek(timestamp) > 3;
DROP TABLE IF EXISTS decimal_dt;