Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-23740: Sql. Missing rowsort comparison mode in test_filter_clause.test #4772

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,43 @@ SELECT COVAR_POP(NULL, NULL), COVAR_SAMP(NULL, NULL) FROM integers
NULL
NULL

#Query with many different filter clauses (e.g. 5 aggregates, 5 different filters)
statement ok
create table t_2(a int, b int, c int, d int, e int);

statement ok
insert into t_2 select x a, length(x) b, mod(x,100) c, 5 d, 10000 e from table(system_range(0, 999));

query IIIII
select count (a) filter (where a>10 and a < 15), count (b) filter (where b between 1 and 3),
count (c) filter ( where c < 10), count (d) filter (where d =5), count(e) filter (where e < 10)
from t_2;
----
4 1000 100 1000 0

query IIIII
select count (a) filter (where a>10 and a < 15), count (b) filter (where b between 1 and 3),
count (c) filter ( where c < 10), count (d) filter (where d =5), count(e) filter (where e < 10)
from t_2
group by b;
----
0 10 10 10 0
4 90 0 90 0
0 900 90 900 0


#Filter with some more complex aggregates: COVAR_POP (multiple input columns), STRING_AGG (strings) and ARRAY_AGG (lists)
query II
select COVAR_POP(a,b) filter (where a < 100), COVAR_POP(a,b) filter (where b <5) from t_2;
----
4.5 49.95

query II
select COVAR_POP(a,c) filter (where a < 100), COVAR_POP(a,c) filter (where c <50)
from t_2
group by b;
----
8.250000 8.250000
674.916667 133.250000
NULL 208.250000

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# name: test/sql/filter/test_string_agg_array_agg.test
# description: Test STRING_AGG, ARRAY_AGG
# group: [aggregates]
# Ignore: https://issues.apache.org/jira/browse/IGNITE-15589

statement ok
CREATE TABLE films(film_id INTEGER, title VARCHAR)

statement ok
CREATE TABLE actors(actor_id INTEGER, first_name VARCHAR, last_name VARCHAR)

statement ok
CREATE TABLE film_actor(film_id INTEGER, actor_id INTEGER)

statement ok
INSERT INTO films VALUES (1, 'The Martian'), (2, 'Saving Private Ryan'), (3, 'Team America');

statement ok
INSERT INTO actors VALUES (1, 'Matt', 'Damon'), (2, 'Jessica', 'Chastain'), (3, 'Tom', 'Hanks'), (4, 'Edward', 'Burns'),
(5, 'Kim', 'Jong Un'), (6, 'Alec', 'Baldwin');

statement ok
INSERT INTO film_actor VALUES (1, 1), (2, 1), (3, 1), (1, 2), (2, 3), (2, 4), (3, 5), (3, 6);

query II
SELECT
title,
ARRAY_AGG (first_name || ' ' || last_name) filter (where first_name = 'Matt') actors
FROM films
JOIN film_actor USING (film_id)
JOIN actors USING (actor_id)
GROUP BY
title
ORDER BY
title;
----
Saving Private Ryan [Matt Damon]
Team America [Matt Damon]
The Martian [Matt Damon]


query II
SELECT
title,
STRING_AGG (first_name || ' ' || last_name) filter (where first_name = 'Matt') actors
FROM films
JOIN film_actor USING (film_id)
JOIN actors USING (actor_id)
GROUP BY
title
ORDER BY
title;
----
Saving Private Ryan Matt Damon
Team America Matt Damon
The Martian Matt Damon
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ select count (a) filter (where a>10 and a < 15), count (b) filter (where b betwe
----
4 1000 100 1000 0

query IIIII
query IIIII rowsort
select count (a) filter (where a>10 and a < 15), count (b) filter (where b between 1 and 3),
count (c) filter ( where c < 10), count (d) filter (where d =5), count(e) filter (where e < 10)
from t_2
Expand Down
Loading