mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Backport #63097 to 24.3: Fix incorrect judgement of of monotonicity of function abs
This commit is contained in:
parent
f46ef3bf05
commit
483ff9438c
@ -45,7 +45,7 @@ template <> struct FunctionUnaryArithmeticMonotonicity<NameAbs>
|
||||
if ((left_float < 0 && right_float > 0) || (left_float > 0 && right_float < 0))
|
||||
return {};
|
||||
|
||||
return { .is_monotonic = true, .is_positive = left_float > 0, .is_strict = true, };
|
||||
return { .is_monotonic = true, .is_positive = std::min(left_float, right_float) >= 0, .is_strict = true, };
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2860,9 +2860,9 @@ bool KeyCondition::mayBeTrueInRange(
|
||||
String KeyCondition::RPNElement::toString() const
|
||||
{
|
||||
if (argument_num_of_space_filling_curve)
|
||||
return toString(fmt::format("argument {} of column {}", *argument_num_of_space_filling_curve, key_column), false);
|
||||
return toString(fmt::format("argument {} of column {}", *argument_num_of_space_filling_curve, key_column), true);
|
||||
else
|
||||
return toString(fmt::format("column {}", key_column), false);
|
||||
return toString(fmt::format("column {}", key_column), true);
|
||||
}
|
||||
|
||||
String KeyCondition::RPNElement::toString(std::string_view column_name, bool print_constants) const
|
||||
|
@ -0,0 +1 @@
|
||||
2
|
10
tests/queries/0_stateless/03130_abs_in_key_condition_bug.sql
Normal file
10
tests/queries/0_stateless/03130_abs_in_key_condition_bug.sql
Normal file
@ -0,0 +1,10 @@
|
||||
DROP TABLE IF EXISTS t;
|
||||
|
||||
CREATE TABLE t (id UInt64, ts DateTime) ENGINE = MergeTree() ORDER BY (id, ts) SETTINGS index_granularity = 2;
|
||||
|
||||
INSERT INTO t VALUES
|
||||
(1, toDateTime('2023-05-04 21:17:23', 'UTC')), (1, toDateTime('2023-05-04 22:17:23', 'UTC')), (2, toDateTime('2023-05-04 22:17:23', 'UTC')), (2, toDateTime('2023-05-04 23:17:23', 'UTC'));
|
||||
|
||||
SELECT count(abs(toUnixTimestamp(ts, 'UTC') - toUnixTimestamp('2023-05-04 22:17:23', 'UTC')) AS error) FROM t WHERE error < 3600;
|
||||
|
||||
DROP TABLE IF EXISTS t;
|
Loading…
Reference in New Issue
Block a user