mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Backport #71849 to 24.9: Fix: add monotonic estimation for DateTime64 in toDayOfWeek
This commit is contained in:
parent
4d1b4c3c41
commit
88a72105d7
@ -63,6 +63,7 @@ constexpr time_t MAX_DATETIME_DAY_NUM = 49710; // 2106-02-07
|
|||||||
/// This factor transformation will say that the function is monotone everywhere.
|
/// This factor transformation will say that the function is monotone everywhere.
|
||||||
struct ZeroTransform
|
struct ZeroTransform
|
||||||
{
|
{
|
||||||
|
static constexpr auto name = "Zero";
|
||||||
static UInt16 execute(Int64, const DateLUTImpl &) { return 0; }
|
static UInt16 execute(Int64, const DateLUTImpl &) { return 0; }
|
||||||
static UInt16 execute(UInt32, const DateLUTImpl &) { return 0; }
|
static UInt16 execute(UInt32, const DateLUTImpl &) { return 0; }
|
||||||
static UInt16 execute(Int32, const DateLUTImpl &) { return 0; }
|
static UInt16 execute(Int32, const DateLUTImpl &) { return 0; }
|
||||||
|
@ -55,13 +55,26 @@ public:
|
|||||||
? is_monotonic
|
? is_monotonic
|
||||||
: is_not_monotonic;
|
: is_not_monotonic;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (checkAndGetDataType<DataTypeDateTime64>(&type))
|
||||||
{
|
{
|
||||||
return Transform::FactorTransform::execute(UInt32(left.safeGet<UInt64>()), date_lut)
|
|
||||||
== Transform::FactorTransform::execute(UInt32(right.safeGet<UInt64>()), date_lut)
|
const auto & left_date_time = left.safeGet<DateTime64>();
|
||||||
|
TransformDateTime64<typename Transform::FactorTransform> transformer_left(left_date_time.getScale());
|
||||||
|
|
||||||
|
const auto & right_date_time = right.safeGet<DateTime64>();
|
||||||
|
TransformDateTime64<typename Transform::FactorTransform> 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_monotonic
|
||||||
: is_not_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
|
||||||
|
: is_not_monotonic;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
4
|
@ -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;
|
Loading…
Reference in New Issue
Block a user