diff --git a/e2e_test/batch/join/natural_and_cross_join.slt b/e2e_test/batch/join/natural_and_cross_join.slt new file mode 100644 index 0000000000000..59cb6f3b11d47 --- /dev/null +++ b/e2e_test/batch/join/natural_and_cross_join.slt @@ -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; diff --git a/e2e_test/streaming/natural_and_cross_join.slt b/e2e_test/streaming/natural_and_cross_join.slt new file mode 100644 index 0000000000000..4407244623cf3 --- /dev/null +++ b/e2e_test/streaming/natural_and_cross_join.slt @@ -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;