mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 07:01:59 +00:00
fix
This commit is contained in:
parent
b991cbf9d6
commit
2782b2a6b0
@ -237,7 +237,9 @@ void ASTFunction::formatImplWithoutAlias(const FormatSettings & settings, Format
|
||||
* but the old comment said it is impossible, without mentioning
|
||||
* the reason. We should also negate the nonnegative literals,
|
||||
* for symmetry. We print the negated value without parentheses,
|
||||
* because they are not needed around a single literal.
|
||||
* because they are not needed around a single literal. Also we
|
||||
* use formatting from FieldVisitorToString, so that the type is
|
||||
* preserved (e.g. -0. is printed with trailing period).
|
||||
*/
|
||||
if (literal && name == "negate")
|
||||
{
|
||||
@ -257,14 +259,15 @@ void ASTFunction::formatImplWithoutAlias(const FormatSettings & settings, Format
|
||||
// fuzzer. Decimals are always signed, so no need
|
||||
// to deduce the result type like we do for ints.
|
||||
const auto int_value = value.getValue().value;
|
||||
settings.ostr << ValueType{
|
||||
settings.ostr << FieldVisitorToString{}(ValueType{
|
||||
-int_value,
|
||||
value.getScale()};
|
||||
value.getScale()});
|
||||
}
|
||||
else if constexpr (std::is_arithmetic_v<ValueType>)
|
||||
{
|
||||
using ResultType = typename NumberTraits::ResultOfNegate<ValueType>::Type;
|
||||
settings.ostr << -static_cast<ResultType>(value);
|
||||
settings.ostr << FieldVisitorToString{}(
|
||||
-static_cast<ResultType>(value));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,10 @@ SELECT
|
||||
-1 IN (-1)
|
||||
explain syntax select negate(1.), negate(-1.), - -1., -(-1.), (-1.) in (-1.);
|
||||
SELECT
|
||||
-1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
-1.,
|
||||
1.,
|
||||
1.,
|
||||
1.,
|
||||
-1. IN (-1.)
|
||||
explain syntax select negate(-9223372036854775808), -(-9223372036854775808), - -9223372036854775808;
|
||||
SELECT
|
||||
@ -27,8 +27,8 @@ SELECT
|
||||
0 IN (0)
|
||||
explain syntax select negate(0.), negate(-0.), - -0., -(-0.), (-0.) in (-0.);
|
||||
SELECT
|
||||
-0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
-0.,
|
||||
0.,
|
||||
0.,
|
||||
0.,
|
||||
-0. IN (-0.)
|
||||
|
Loading…
Reference in New Issue
Block a user