From 0d8f4ae1d0966fc42086ce1d5236fd99ea548d90 Mon Sep 17 00:00:00 2001 From: Alex Kasko Date: Mon, 10 Aug 2026 09:07:39 +0100 Subject: [PATCH] Add a test to cover parallel scans safety This PR adds a test that has uncovered a concurrency problem in MySQL scanner: - duckdb/duckdb-mysql#225 - duckdb/duckdb-mysql#254 Note that Postgres scanner is not affected by the same problem due to `INITIALIZE_ON_SCHEDULE` changes added in #252. The test is still necessary to cover possible modifications to this logic in future. --- test/sql/storage/multi_scan_aggregate.test | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/sql/storage/multi_scan_aggregate.test diff --git a/test/sql/storage/multi_scan_aggregate.test b/test/sql/storage/multi_scan_aggregate.test new file mode 100644 index 000000000..9ae996a94 --- /dev/null +++ b/test/sql/storage/multi_scan_aggregate.test @@ -0,0 +1,55 @@ +# name: test/sql/storage/multi_scan_aggregate.test +# description: Test multiple simultaneous scans that are aggregated on DuckDB side +# group: [storage] + +require postgres_scanner + +require-env POSTGRES_TEST_DATABASE_AVAILABLE + +statement ok +ATTACH 'dbname=postgresscanner' AS s (TYPE POSTGRES) + +statement ok +CREATE OR REPLACE TABLE s.aggr_union_test_a AS +SELECT '2020-01-01' insert_date, unnest(range(1<<14)) amount + +statement ok +CREATE OR REPLACE TABLE s.aggr_union_test_b AS +SELECT '2021-01-01' insert_date, unnest(range(1<<14)) amount + +# Note, 'divide()' is necessary to prevent remote-execute pushdown + +query II +SELECT date(t.insert_date) AS d, divide(sum(t.amount), 1) AS s +FROM s.aggr_union_test_a t +GROUP BY 1 +---- +2020-01-01 134209536 + +query II +SELECT date(t.insert_date) AS d, divide(sum(t.amount), 1) AS s +FROM s.aggr_union_test_b t +GROUP BY 1 +---- +2021-01-01 134209536 + +query II +SELECT date(t.insert_date) AS d, divide(sum(t.amount), 1) AS s +FROM s.aggr_union_test_a t +GROUP BY 1 +UNION ALL +SELECT date(t.insert_date) AS d, divide(sum(t.amount), 1) AS s +FROM s.aggr_union_test_b t +GROUP BY 1 +---- +2020-01-01 134209536 +2021-01-01 134209536 + +statement ok +DROP TABLE s.aggr_union_test_a + +statement ok +DROP TABLE s.aggr_union_test_b + +statement ok +DETACH s;