-- Migrated from DuckDB test: test/sql/setops/test_setops.test

SELECT 1 UNION ALL SELECT 2 ORDER BY 1;

SELECT 1, 'a' UNION ALL SELECT 2, 'b' ORDER BY 1;

SELECT 1, 'a' UNION ALL SELECT 2, 'b' UNION ALL SELECT 3, 'c' ORDER BY 1;

SELECT 1, 'a' UNION ALL SELECT 2, 'b' UNION ALL SELECT 3, 'c' UNION ALL SELECT 4, 'd' ORDER BY 1;

-- NULL values
SELECT NULL UNION SELECT NULL;

SELECT NULL EXCEPT SELECT NULL;

SELECT NULL INTERSECT SELECT NULL;

CREATE TABLE test (a INTEGER, b INTEGER, ts TIMESTAMP TIME INDEX);

INSERT INTO test VALUES (11, 1, 1000), (12, 1, 2000), (13, 2, 3000);

-- Table data
SELECT a FROM test WHERE a < 13 UNION ALL SELECT a FROM test WHERE a = 13 ORDER BY a;

SELECT b FROM test WHERE a < 13 UNION ALL SELECT b FROM test WHERE a > 11 ORDER BY b;

-- Type mixing
-- SQLNESS SORT_RESULT 3 1
SELECT 1 UNION ALL SELECT 'asdf';

-- UNION deduplication
SELECT 1 UNION SELECT 1;

SELECT 1 EXCEPT SELECT 2;

SELECT 1 EXCEPT SELECT 1;

SELECT 1 INTERSECT SELECT 1;

SELECT 1 INTERSECT SELECT 2;

DROP TABLE test;
