diff --git a/dbms/tests/queries/0_stateless/00048_stored_aggregates_merge.reference b/dbms/tests/queries/0_stateless/00048_a_stored_aggregates_merge.reference similarity index 100% rename from dbms/tests/queries/0_stateless/00048_stored_aggregates_merge.reference rename to dbms/tests/queries/0_stateless/00048_a_stored_aggregates_merge.reference diff --git a/dbms/tests/queries/0_stateless/00048_stored_aggregates_merge.sql b/dbms/tests/queries/0_stateless/00048_a_stored_aggregates_merge.sql similarity index 100% rename from dbms/tests/queries/0_stateless/00048_stored_aggregates_merge.sql rename to dbms/tests/queries/0_stateless/00048_a_stored_aggregates_merge.sql diff --git a/dbms/tests/queries/0_stateless/00048_b_stored_aggregates_merge.reference b/dbms/tests/queries/0_stateless/00048_b_stored_aggregates_merge.reference new file mode 100644 index 00000000000..e48dcb7503e --- /dev/null +++ b/dbms/tests/queries/0_stateless/00048_b_stored_aggregates_merge.reference @@ -0,0 +1,43 @@ +100 +2014-06-01 10 +2014-06-02 10 +2014-06-03 10 +2014-06-04 10 +2014-06-05 10 +2014-06-06 10 +2014-06-07 10 +2014-06-08 10 +2014-06-09 10 +2014-06-10 10 +155 +2014-06-01 10 +2014-06-02 10 +2014-06-03 10 +2014-06-04 10 +2014-06-05 10 +2014-06-06 15 +2014-06-07 15 +2014-06-08 15 +2014-06-09 15 +2014-06-10 15 +2014-06-11 10 +2014-06-12 10 +2014-06-13 10 +2014-06-14 10 +2014-06-15 10 +155 +2014-06-01 10 +2014-06-02 10 +2014-06-03 10 +2014-06-04 10 +2014-06-05 10 +2014-06-06 15 +2014-06-07 15 +2014-06-08 15 +2014-06-09 15 +2014-06-10 15 +2014-06-11 10 +2014-06-12 10 +2014-06-13 10 +2014-06-14 10 +2014-06-15 10 diff --git a/dbms/tests/queries/0_stateless/00048_b_stored_aggregates_merge.sql b/dbms/tests/queries/0_stateless/00048_b_stored_aggregates_merge.sql new file mode 100644 index 00000000000..7448f4eb6b2 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00048_b_stored_aggregates_merge.sql @@ -0,0 +1,47 @@ +SET min_bytes_to_use_direct_io = 128; + +DROP TABLE IF EXISTS test.stored_aggregates; + +CREATE TABLE test.stored_aggregates +( + d Date, + Uniq AggregateFunction(uniq, UInt64) +) +ENGINE = AggregatingMergeTree(d, d, 8192); + +INSERT INTO test.stored_aggregates +SELECT + toDate(toUInt16(toDate('2014-06-01')) + intDiv(number, 100)) AS d, + uniqState(intDiv(number, 10)) AS Uniq +FROM +( + SELECT * FROM system.numbers LIMIT 1000 +) +GROUP BY d; + +SELECT uniqMerge(Uniq) FROM test.stored_aggregates; + +SELECT d, uniqMerge(Uniq) FROM test.stored_aggregates GROUP BY d ORDER BY d; + +INSERT INTO test.stored_aggregates +SELECT + toDate(toUInt16(toDate('2014-06-01')) + intDiv(number, 100)) AS d, + uniqState(intDiv(number + 50, 10)) AS Uniq +FROM +( + SELECT * FROM system.numbers LIMIT 500, 1000 +) +GROUP BY d; + +SELECT uniqMerge(Uniq) FROM test.stored_aggregates; + +SELECT d, uniqMerge(Uniq) FROM test.stored_aggregates GROUP BY d ORDER BY d; + +OPTIMIZE TABLE test.stored_aggregates; + +SELECT uniqMerge(Uniq) FROM test.stored_aggregates; + +SELECT d, uniqMerge(Uniq) FROM test.stored_aggregates GROUP BY d ORDER BY d; + +DROP TABLE test.stored_aggregates; +