should be it
This commit is contained in:
194
external/duckdb/test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped.test
vendored
Normal file
194
external/duckdb/test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped.test
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
# name: test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped.test
|
||||
# description: DISTINCT aggregations, without GROUP BY
|
||||
# group: [ungrouped]
|
||||
|
||||
# Since these tests are made to test the ungrouped operator, and not necessarily the functions themselves
|
||||
# This test will mostly focus on the order and mixing of distinct and non-distinct aggregates
|
||||
# And not on variation between types and functions
|
||||
|
||||
#distinct aggregate = 'D'
|
||||
#regular aggregate = '-'
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA verify_external
|
||||
|
||||
statement ok
|
||||
create table tbl as
|
||||
(select i%50 as i, i%100 as j from range(50000) tbl(i))
|
||||
;
|
||||
|
||||
# D
|
||||
query I
|
||||
select
|
||||
count(distinct i)
|
||||
from tbl;
|
||||
----
|
||||
50
|
||||
|
||||
# D--
|
||||
query III
|
||||
select
|
||||
sum(distinct i),
|
||||
sum(i),
|
||||
sum(j)
|
||||
from tbl;
|
||||
----
|
||||
1225 1225000 2475000
|
||||
|
||||
# --D
|
||||
query III
|
||||
select
|
||||
sum(i),
|
||||
sum(j),
|
||||
sum(distinct i)
|
||||
from tbl;
|
||||
----
|
||||
1225000 2475000 1225
|
||||
|
||||
# -D-
|
||||
query III
|
||||
select
|
||||
sum(i),
|
||||
sum(distinct i),
|
||||
sum(j)
|
||||
from tbl;
|
||||
----
|
||||
1225000 1225 2475000
|
||||
|
||||
# D-D
|
||||
query III
|
||||
select
|
||||
sum(distinct i),
|
||||
count(j),
|
||||
sum(distinct j)
|
||||
from tbl;
|
||||
----
|
||||
1225 50000 4950
|
||||
|
||||
#-D-D
|
||||
query IIII
|
||||
select
|
||||
sum(j),
|
||||
sum(distinct i),
|
||||
count(j),
|
||||
sum(distinct j)
|
||||
from tbl;
|
||||
----
|
||||
2475000 1225 50000 4950
|
||||
|
||||
#-D-D
|
||||
query IIII
|
||||
select
|
||||
sum(j),
|
||||
sum(distinct i),
|
||||
count(j),
|
||||
sum(distinct j)
|
||||
from tbl;
|
||||
----
|
||||
2475000 1225 50000 4950
|
||||
|
||||
#D-D-
|
||||
query IIII
|
||||
select
|
||||
sum(distinct i),
|
||||
count(j),
|
||||
sum(distinct j),
|
||||
sum(j)
|
||||
from tbl;
|
||||
----
|
||||
1225 50000 4950 2475000
|
||||
|
||||
# These next tests will repeat the previous test, with the addition of filters
|
||||
# filtered = 'F'
|
||||
# not filtered = '-'
|
||||
|
||||
# D
|
||||
# F
|
||||
query I
|
||||
select
|
||||
count(distinct i) FILTER (WHERE i >= 20)
|
||||
from tbl;
|
||||
----
|
||||
30
|
||||
|
||||
# D--
|
||||
# -FF
|
||||
query III
|
||||
select
|
||||
sum(distinct i),
|
||||
sum(i) FILTER (WHERE j < 20),
|
||||
sum(j) FILTER (WHERE i >= 20)
|
||||
from tbl;
|
||||
----
|
||||
1225 95000 1785000
|
||||
|
||||
# --D
|
||||
# -FF
|
||||
query III
|
||||
select
|
||||
sum(i),
|
||||
sum(j) FILTER (WHERE j == 0),
|
||||
sum(distinct i) FILTER (WHERE i == 0)
|
||||
from tbl;
|
||||
----
|
||||
1225000 0 0
|
||||
|
||||
# -D-
|
||||
# F-F
|
||||
query III
|
||||
select
|
||||
sum(i) FILTER (WHERE j == 5),
|
||||
sum(distinct i),
|
||||
sum(j) FILTER (WHERE i == 5)
|
||||
from tbl;
|
||||
----
|
||||
2500 1225 30000
|
||||
|
||||
# D-D
|
||||
# F-F
|
||||
query III
|
||||
select
|
||||
sum(distinct i) FILTER (WHERE i == 5),
|
||||
count(j),
|
||||
sum(distinct j) FILTER (WHERE i == 5)
|
||||
from tbl;
|
||||
----
|
||||
5 50000 60
|
||||
|
||||
#-D-D
|
||||
#FF--
|
||||
query IIII
|
||||
select
|
||||
sum(j) FILTER (WHERE j == 5),
|
||||
sum(distinct i) FILTER (WHERE j == 5),
|
||||
count(j),
|
||||
sum(distinct j)
|
||||
from tbl;
|
||||
----
|
||||
2500 5 50000 4950
|
||||
|
||||
#-D-D
|
||||
#F--F
|
||||
query IIII
|
||||
select
|
||||
sum(j) FILTER (WHERE i == 5),
|
||||
sum(distinct i),
|
||||
count(j),
|
||||
sum(distinct j) FILTER (WHERE j == 5)
|
||||
from tbl;
|
||||
----
|
||||
30000 1225 50000 5
|
||||
|
||||
#D-D-
|
||||
query IIII
|
||||
select
|
||||
sum(distinct i),
|
||||
count(j),
|
||||
sum(distinct j) FILTER (WHERE j == 5),
|
||||
sum(j) FILTER (WHERE j == 5)
|
||||
from tbl;
|
||||
----
|
||||
1225 50000 5 2500
|
||||
64
external/duckdb/test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped.test_slow
vendored
Normal file
64
external/duckdb/test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped.test_slow
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
# name: test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped.test_slow
|
||||
# description: DISTINCT aggregations, without GROUP BY
|
||||
# group: [ungrouped]
|
||||
|
||||
statement ok
|
||||
SET default_null_order='nulls_first';
|
||||
|
||||
# Since these tests are made to test the ungrouped operator, and not necessarily the functions themselves
|
||||
# This test will mostly focus on the order and mixing of distinct and non-distinct aggregates
|
||||
# And not on variation between types and functions
|
||||
|
||||
#Recursive CTE
|
||||
|
||||
query I
|
||||
with recursive t as (select 1 as x union select sum(distinct x+1) from t where x < 3) select * from t order by x;
|
||||
----
|
||||
NULL
|
||||
1
|
||||
2
|
||||
3
|
||||
|
||||
# Prepared statement
|
||||
|
||||
statement ok
|
||||
CREATE TABLE tbl AS SELECT * FROM range(1000000) tbl(i);
|
||||
|
||||
statement ok
|
||||
PREPARE v1 AS SELECT SUM(DISTINCT i%5+?::INT) FROM tbl;
|
||||
|
||||
query I
|
||||
EXECUTE v1(1);
|
||||
----
|
||||
15
|
||||
|
||||
query I
|
||||
EXECUTE v1(2);
|
||||
----
|
||||
20
|
||||
|
||||
query I
|
||||
EXECUTE v1(3);
|
||||
----
|
||||
25
|
||||
|
||||
# DISTINCT aggregate parameter as expression
|
||||
|
||||
query I
|
||||
SELECT COUNT(distinct i % 5) from tbl;
|
||||
----
|
||||
5
|
||||
|
||||
# Correlated subquery
|
||||
|
||||
query I
|
||||
SELECT COUNT(distinct (SELECT i%5)) from tbl;
|
||||
----
|
||||
5
|
||||
|
||||
## Aggregate with multiple parameters
|
||||
|
||||
query I
|
||||
SELECT ARG_MIN(distinct i%5, i) from tbl;
|
||||
----
|
||||
0
|
||||
45
external/duckdb/test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped_parallel.test_slow
vendored
Normal file
45
external/duckdb/test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped_parallel.test_slow
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# name: test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped_parallel.test_slow
|
||||
# description: DISTINCT aggregations, without GROUP BY
|
||||
# group: [ungrouped]
|
||||
|
||||
# force parallelism of the queries
|
||||
statement ok
|
||||
PRAGMA verify_parallelism
|
||||
|
||||
# Few amount of rows, not partitioned
|
||||
|
||||
statement ok
|
||||
create table tbl as select i%100 as few, i%100000 as many from range(1000000) tbl(i);
|
||||
|
||||
query I
|
||||
select count(distinct few) from tbl;
|
||||
----
|
||||
100
|
||||
|
||||
# Large amount of rows, partitioned
|
||||
|
||||
query I
|
||||
select count(distinct many) from tbl;
|
||||
----
|
||||
100000
|
||||
|
||||
# Mixed few and large amount of rows
|
||||
|
||||
query II
|
||||
select count(distinct few), count(distinct many) from tbl;
|
||||
----
|
||||
100 100000
|
||||
|
||||
# Mixed, different order
|
||||
|
||||
query II
|
||||
select count(distinct many), count(distinct few) from tbl;
|
||||
----
|
||||
100000 100
|
||||
|
||||
# Mixed, with non-distinct inbetween
|
||||
|
||||
query III
|
||||
select count(distinct many), count(few), count(distinct few) from tbl;
|
||||
----
|
||||
100000 1000000 100
|
||||
11
external/duckdb/test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped_shared_input.test
vendored
Normal file
11
external/duckdb/test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped_shared_input.test
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# name: test/sql/aggregate/distinct/ungrouped/test_distinct_ungrouped_shared_input.test
|
||||
# description: DISTINCT aggregations, without GROUP BY
|
||||
# group: [ungrouped]
|
||||
|
||||
statement ok
|
||||
create table tbl as select i%50 as i from range(1000000) tbl(i);
|
||||
|
||||
query IIIII
|
||||
select count(distinct i), min(distinct i), max(distinct i), sum(distinct i), product(distinct i) from tbl;
|
||||
----
|
||||
50 0 49 1225 0.0
|
||||
Reference in New Issue
Block a user