mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #72012 from ClickHouse/backport/24.10/71849
Backport #71849 to 24.10: Fix: add monotonic estimation for DateTime64 in toDayOfWeek
This commit is contained in:
commit
96b8005715
@ -64,6 +64,7 @@ constexpr time_t MAX_DATETIME_DAY_NUM = 49710; // 2106-02-07
|
||||
/// This factor transformation will say that the function is monotone everywhere.
|
||||
struct ZeroTransform
|
||||
{
|
||||
static constexpr auto name = "Zero";
|
||||
static UInt16 execute(Int64, const DateLUTImpl &) { return 0; }
|
||||
static UInt16 execute(UInt32, const DateLUTImpl &) { return 0; }
|
||||
static UInt16 execute(Int32, const DateLUTImpl &) { return 0; }
|
||||
|
@ -56,6 +56,21 @@ public:
|
||||
: is_not_monotonic;
|
||||
}
|
||||
|
||||
if (checkAndGetDataType<DataTypeDateTime64>(&type))
|
||||
{
|
||||
|
||||
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_not_monotonic;
|
||||
}
|
||||
|
||||
return Transform::FactorTransform::execute(UInt32(left.safeGet<UInt64>()), date_lut)
|
||||
== Transform::FactorTransform::execute(UInt32(right.safeGet<UInt64>()), date_lut)
|
||||
? is_monotonic
|
||||
|
@ -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