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

INSERT INTO test VALUES (11, 22, 1), (13, 22, 2), (11, 21, 3), (11, 22, 4);

SELECT DISTINCT a, b FROM test ORDER BY a, b;

SELECT DISTINCT test.a, b FROM test ORDER BY a, b;

SELECT DISTINCT a FROM test ORDER BY a;

SELECT DISTINCT b FROM test ORDER BY b;

SELECT DISTINCT a, SUM(B) FROM test GROUP BY a ORDER BY a;

SELECT DISTINCT MAX(b) FROM test GROUP BY a;

SELECT DISTINCT CASE WHEN a > 11 THEN 11 ELSE a END FROM test;

SELECT DISTINCT ON (a) * FROM test ORDER BY a, t DESC;

-- SQLNESS REPLACE (metrics.*) REDACTED
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
-- SQLNESS REPLACE (Hash.*) REDACTED
-- SQLNESS REPLACE (-+) -
-- SQLNESS REPLACE (\s\s+) _
-- SQLNESS REPLACE (peers.*) REDACTED
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
EXPLAIN ANALYZE SELECT DISTINCT a FROM test ORDER BY a;

-- SQLNESS REPLACE (metrics.*) REDACTED
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
-- SQLNESS REPLACE (Hash.*) REDACTED
-- SQLNESS REPLACE (-+) -
-- SQLNESS REPLACE (\s\s+) _
-- SQLNESS REPLACE (peers.*) REDACTED
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
EXPLAIN ANALYZE SELECT DISTINCT a, b FROM test ORDER BY a;

DROP TABLE test;

CREATE TABLE test (a INTEGER, b INTEGER, t TIMESTAMP TIME INDEX)
PARTITION ON COLUMNS(a) (
    a <= 10,
    a > 10,
);

INSERT INTO test VALUES (1, 22, 1), (1, 21, 2), (100, 21, 3), (100, 22, 4);

SELECT DISTINCT a, b FROM test ORDER BY a, b;

-- SQLNESS REPLACE (metrics.*) REDACTED
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
-- SQLNESS REPLACE (Hash.*) REDACTED
-- SQLNESS REPLACE (-+) -
-- SQLNESS REPLACE (\s\s+) _
-- SQLNESS REPLACE (peers.*) REDACTED
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
EXPLAIN ANALYZE SELECT DISTINCT a FROM test ORDER BY a;

-- SQLNESS REPLACE (metrics.*) REDACTED
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
-- SQLNESS REPLACE (Hash.*) REDACTED
-- SQLNESS REPLACE (-+) -
-- SQLNESS REPLACE (\s\s+) _
-- SQLNESS REPLACE (peers.*) REDACTED
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
EXPLAIN ANALYZE SELECT DISTINCT a, b FROM test ORDER BY a;

DROP TABLE test;
