Merge pull request #10758 from bgiard/master

Fix serialize/deserialize of denominator of Average functions
This commit is contained in:
alexey-milovidov 2020-05-09 21:22:16 +03:00 committed by GitHub
commit e41e998f4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -71,13 +71,13 @@ public:
void serialize(ConstAggregateDataPtr place, WriteBuffer & buf) const override
{
writeBinary(this->data(place).numerator, buf);
writeVarUInt(this->data(place).denominator, buf);
writeBinary(this->data(place).denominator, buf);
}
void deserialize(AggregateDataPtr place, ReadBuffer & buf, Arena *) const override
{
readBinary(this->data(place).numerator, buf);
readVarUInt(this->data(place).denominator, buf);
readBinary(this->data(place).denominator, buf);
}
void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override

View File

@ -0,0 +1,6 @@
100
10
0
nan
nan
100

View File

@ -0,0 +1,9 @@
CREATE TABLE dummy(foo Int64) ENGINE = Memory();
INSERT INTO dummy VALUES (1);
SELECT avgWeighted(100., .1) FROM remote('127.0.0.{2,3}', currentDatabase(), dummy);
SELECT avgWeighted(10, 100) FROM remote('127.0.0.{2,3}', currentDatabase(), dummy);
SELECT avgWeighted(0, 1) FROM remote('127.0.0.{2,3}', currentDatabase(), dummy);
SELECT avgWeighted(0., 0.) FROM remote('127.0.0.{2,3}', currentDatabase(), dummy);
SELECT avgWeighted(1., 0.) FROM remote('127.0.0.{2,3}', currentDatabase(), dummy);
SELECT avgWeighted(toInt8(100), -1) FROM remote('127.0.0.{2,3}', currentDatabase(), dummy);
DROP TABLE dummy;