forked from risingwavelabs/risingwave
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add e2e tests for natural join and cross join (risingwavelabs#8948
- Loading branch information
1 parent
35f7c0c
commit 5d8c0b4
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Test setup | ||
statement ok | ||
CREATE TABLE employees ( | ||
id INTEGER, | ||
employee_name VARCHAR, | ||
department_id INTEGER | ||
); | ||
|
||
statement ok | ||
CREATE TABLE departments ( | ||
department_name VARCHAR, | ||
department_id INTEGER | ||
); | ||
|
||
statement ok | ||
INSERT INTO employees (id, employee_name, department_id) VALUES | ||
(1, 'Alice', 1), | ||
(2, 'Bob', 2), | ||
(3, 'Charlie', 1); | ||
|
||
statement ok | ||
INSERT INTO departments (department_name, department_id) VALUES | ||
('Engineering', 1), | ||
('HR', 2); | ||
|
||
statement ok | ||
flush | ||
|
||
query TT rowsort | ||
SELECT e.employee_name, d.department_name | ||
FROM employees e NATURAL JOIN departments d | ||
ORDER BY employee_name; | ||
---- | ||
Alice Engineering | ||
Bob HR | ||
Charlie Engineering | ||
|
||
# Test cross join | ||
query TT rowsort | ||
SELECT e.employee_name, d.department_name | ||
FROM employees e CROSS JOIN departments d | ||
ORDER BY e.employee_name, d.department_name; | ||
---- | ||
Alice Engineering | ||
Alice HR | ||
Bob Engineering | ||
Bob HR | ||
Charlie Engineering | ||
Charlie HR | ||
|
||
statement ok | ||
DROP TABLE employees; | ||
|
||
statement ok | ||
DROP TABLE departments; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Test setup | ||
statement ok | ||
CREATE TABLE employees ( | ||
id INTEGER, | ||
employee_name VARCHAR, | ||
department_id INTEGER | ||
); | ||
|
||
statement ok | ||
CREATE TABLE departments ( | ||
department_name VARCHAR, | ||
department_id INTEGER | ||
); | ||
|
||
statement ok | ||
INSERT INTO employees (id, employee_name, department_id) VALUES | ||
(1, 'Alice', 1), | ||
(2, 'Bob', 2), | ||
(3, 'Charlie', 1); | ||
|
||
statement ok | ||
INSERT INTO departments (department_name, department_id) VALUES | ||
('Engineering', 1), | ||
('HR', 2); | ||
|
||
# Create materialized view with NATURAL JOIN | ||
statement ok | ||
CREATE MATERIALIZED VIEW employee_department_natural_join AS | ||
SELECT e.employee_name, d.department_name | ||
FROM employees e NATURAL JOIN departments d | ||
ORDER BY employee_name; | ||
|
||
# Nested-loop joins are not supported in the streaming mode. | ||
statement error | ||
CREATE MATERIALIZED VIEW employee_department_cross_join AS | ||
SELECT e.employee_name, d.department_name | ||
FROM employees e CROSS JOIN departments d | ||
ORDER BY e.employee_name, d.department_name; | ||
|
||
statement ok | ||
flush | ||
|
||
# Test NATURAL JOIN | ||
query TT rowsort | ||
SELECT employee_name, department_name FROM employee_department_natural_join; | ||
---- | ||
Alice Engineering | ||
Bob HR | ||
Charlie Engineering | ||
|
||
# Cleanup | ||
statement ok | ||
DROP MATERIALIZED VIEW employee_department_natural_join; | ||
|
||
statement ok | ||
DROP TABLE employees; | ||
|
||
statement ok | ||
DROP TABLE departments; |