ClickHouse/tests/queries/0_stateless/01268_shard_avgweighted.sql
Baudouin Giard be2cf70da8 Fix serialize/deserialize of denominator of Average functions
Use writeBinary/readBinary to serialize/deserialize the denominator of Average functions.

Previously it would be transmitted as an unsigned int, which means its value would get corrupted when doing an avgWeighted over a floating point number.

Note: this commit is not backwards compatible!

Signed-off-by: Baudouin Giard <bgiard@bloomberg.net>
2020-05-08 15:10:47 -04:00

10 lines
605 B
SQL

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;