Merge pull request #2671 from citusdata/fix_more_orderbys

Fix more order bys
pull/2678/head
Önder Kalacı 2019-04-18 08:31:16 +02:00 committed by GitHub
commit 41f98f9c02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 46 deletions

View File

@ -78,16 +78,17 @@ ORDER BY x;
(3 rows)
END;
-- don't print the worker port
\set VERBOSITY terse
-- files should now be cleaned up
SELECT x, x2
FROM interesting_squares JOIN (SELECT * FROM read_intermediate_result('squares', 'binary') AS res (x text, x2 int)) squares ON (x = interested_in)
WHERE user_id = 'jon'
ORDER BY x;
WARNING: result "squares" does not exist
CONTEXT: while executing command on localhost:57638
WARNING: result "squares" does not exist
CONTEXT: while executing command on localhost:57637
ERROR: could not receive query results
\set VERBOSITY DEFAULT
-- try to read the file as text, will fail because of binary encoding
BEGIN;
SELECT create_intermediate_result('squares', 'SELECT s, s*s FROM generate_series(1,5) s');

View File

@ -32,11 +32,11 @@ SELECT COUNT(*) FROM limit_orders_mx WHERE id = 32745;
(1 row)
-- and see all the inserted rows
SELECT * FROM limit_orders_mx;
SELECT * FROM limit_orders_mx ORDER BY 1;
id | symbol | bidder_id | placed_at | kind | limit_price
-------+--------+-----------+--------------------------+------+-------------
32744 | AAPL | 9580 | Tue Oct 19 10:23:54 2004 | buy | 20.69
32743 | AAPL | 9580 | Tue Oct 19 10:23:54 2004 | buy | 20.69
32744 | AAPL | 9580 | Tue Oct 19 10:23:54 2004 | buy | 20.69
32745 | AAPL | 9580 | Tue Oct 19 10:23:54 2004 | buy | 20.69
(3 rows)

View File

@ -422,7 +422,7 @@ FROM
WHERE
user_id > 2 AND user_id < 6
ORDER BY
user_id, value_1;
user_id, value_1, 3, 4;
user_id | value_1 | array_agg | array_agg
---------+---------+-------------------------------------------------------+-----------------------------------------------------
3 | 0 | {0} |
@ -507,7 +507,7 @@ WINDOW
range_window as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING),
range_window_exclude as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW)
ORDER BY
user_id, value_1;
user_id, value_1, 3, 4;
user_id | value_1 | array_agg | array_agg
---------+---------+---------------------------------------+-------------------------------------
3 | 0 | {0,1,1,1,1,1,1} | {1,1,1,1,1,1}
@ -592,40 +592,40 @@ WINDOW
row_window as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING),
row_window_exclude as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW)
ORDER BY
user_id, value_1;
user_id, value_1, 3, 4;
user_id | value_1 | array_agg | array_agg
---------+---------+-----------+-----------
3 | 0 | {0,1} | {1}
3 | 1 | {1,1,1} | {1,1}
3 | 1 | {1,1,2} | {1,2}
3 | 1 | {0,1,1} | {0,1}
3 | 1 | {1,1,1} | {1,1}
3 | 1 | {1,1,1} | {1,1}
3 | 1 | {1,1,1} | {1,1}
3 | 1 | {1,1,1} | {1,1}
3 | 1 | {1,1,2} | {1,2}
3 | 2 | {1,2,2} | {1,2}
3 | 2 | {2,2,3} | {2,3}
3 | 3 | {2,3,3} | {2,3}
3 | 3 | {3,3,4} | {3,4}
3 | 3 | {3,3,3} | {3,3}
3 | 4 | {4,4,4} | {4,4}
3 | 4 | {4,4,4} | {4,4}
3 | 3 | {3,3,4} | {3,4}
3 | 4 | {3,4,4} | {3,4}
3 | 4 | {4,4,4} | {4,4}
3 | 4 | {4,4,4} | {4,4}
3 | 4 | {4,4,5} | {4,5}
3 | 5 | {4,5} | {4}
4 | 0 | {0,0,1} | {0,1}
4 | 0 | {0,0,0} | {0,0}
4 | 0 | {0,0} | {0}
4 | 0 | {0,0,0} | {0,0}
4 | 0 | {0,0,0} | {0,0}
4 | 0 | {0,0,1} | {0,1}
4 | 1 | {0,1,2} | {0,2}
4 | 2 | {2,2,3} | {2,3}
4 | 2 | {2,2,2} | {2,2}
4 | 2 | {1,2,2} | {1,2}
4 | 3 | {3,3,4} | {3,4}
4 | 3 | {3,3,3} | {3,3}
4 | 3 | {3,3,3} | {3,3}
4 | 3 | {3,3,3} | {3,3}
4 | 3 | {3,3,3} | {3,3}
4 | 2 | {2,2,2} | {2,2}
4 | 2 | {2,2,3} | {2,3}
4 | 3 | {2,3,3} | {2,3}
4 | 3 | {3,3,3} | {3,3}
4 | 3 | {3,3,3} | {3,3}
4 | 3 | {3,3,3} | {3,3}
4 | 3 | {3,3,3} | {3,3}
4 | 3 | {3,3,4} | {3,4}
4 | 4 | {3,4,4} | {3,4}
4 | 4 | {4,4,4} | {4,4}
4 | 4 | {4,4,4} | {4,4}
@ -633,34 +633,34 @@ ORDER BY
4 | 4 | {4,4,4} | {4,4}
4 | 4 | {4,4,4} | {4,4}
4 | 4 | {4,4,5} | {4,5}
4 | 5 | {5,5} | {5}
4 | 5 | {4,5,5} | {4,5}
5 | 0 | {0,0,1} | {0,1}
4 | 5 | {5,5} | {5}
5 | 0 | {0,0} | {0}
5 | 0 | {0,0,1} | {0,1}
5 | 1 | {0,1,1} | {0,1}
5 | 1 | {1,1,1} | {1,1}
5 | 1 | {1,1,2} | {1,2}
5 | 1 | {0,1,1} | {0,1}
5 | 2 | {2,2,2} | {2,2}
5 | 2 | {1,2,2} | {1,2}
5 | 2 | {2,2,2} | {2,2}
5 | 2 | {2,2,2} | {2,2}
5 | 2 | {2,2,2} | {2,2}
5 | 2 | {2,2,2} | {2,2}
5 | 2 | {2,2,3} | {2,3}
5 | 2 | {2,2,2} | {2,2}
5 | 2 | {2,2,2} | {2,2}
5 | 2 | {2,2,2} | {2,2}
5 | 3 | {3,3,4} | {3,4}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {2,3,3} | {2,3}
5 | 4 | {4,4,5} | {4,5}
5 | 4 | {4,4,4} | {4,4}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,3} | {3,3}
5 | 3 | {3,3,4} | {3,4}
5 | 4 | {3,4,4} | {3,4}
5 | 4 | {4,4,4} | {4,4}
5 | 4 | {4,4,5} | {4,5}
5 | 5 | {4,5,5} | {4,5}
5 | 5 | {5,5} | {5}
5 | 5 | {5,5,5} | {5,5}
5 | 5 | {4,5,5} | {4,5}
(66 rows)
-- some tests with GROUP BY, HAVING and LIMIT

View File

@ -422,7 +422,7 @@ FROM
WHERE
user_id > 2 AND user_id < 6
ORDER BY
user_id, value_1;
user_id, value_1, 3, 4;
ERROR: syntax error at or near "EXCLUDE"
LINE 5: ...ANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE CU...
^
@ -440,7 +440,7 @@ WINDOW
range_window as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING),
range_window_exclude as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW)
ORDER BY
user_id, value_1;
user_id, value_1, 3, 4;
ERROR: RANGE PRECEDING is only supported with UNBOUNDED
LINE 11: ..._window as (PARTITION BY user_id ORDER BY value_1 RANGE BETW...
^
@ -458,7 +458,7 @@ WINDOW
row_window as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING),
row_window_exclude as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW)
ORDER BY
user_id, value_1;
user_id, value_1, 3, 4;
ERROR: syntax error at or near "EXCLUDE"
LINE 12: ...value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CU...
^

View File

@ -38,12 +38,17 @@ JOIN (SELECT * FROM read_intermediate_result('squares', 'binary') AS res (x int,
ORDER BY x;
END;
-- don't print the worker port
\set VERBOSITY terse
-- files should now be cleaned up
SELECT x, x2
FROM interesting_squares JOIN (SELECT * FROM read_intermediate_result('squares', 'binary') AS res (x text, x2 int)) squares ON (x = interested_in)
WHERE user_id = 'jon'
ORDER BY x;
\set VERBOSITY DEFAULT
-- try to read the file as text, will fail because of binary encoding
BEGIN;
SELECT create_intermediate_result('squares', 'SELECT s, s*s FROM generate_series(1,5) s');

View File

@ -24,7 +24,7 @@ INSERT INTO limit_orders_mx VALUES (32745, 'AAPL', 9580, '2004-10-19 10:23:54',
SELECT COUNT(*) FROM limit_orders_mx WHERE id = 32745;
-- and see all the inserted rows
SELECT * FROM limit_orders_mx;
SELECT * FROM limit_orders_mx ORDER BY 1;
-- basic single-row INSERT with RETURNING
INSERT INTO limit_orders_mx VALUES (32746, 'AAPL', 9580, '2004-10-19 10:23:54', 'buy', 20.69) RETURNING *;

View File

@ -239,7 +239,7 @@ FROM
WHERE
user_id > 2 AND user_id < 6
ORDER BY
user_id, value_1;
user_id, value_1, 3, 4;
-- test <offset> preceding and <offset> following on RANGE window
SELECT
@ -255,7 +255,7 @@ WINDOW
range_window as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING),
range_window_exclude as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW)
ORDER BY
user_id, value_1;
user_id, value_1, 3, 4;
-- test <offset> preceding and <offset> following on ROW window
SELECT
@ -271,7 +271,7 @@ WINDOW
row_window as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING),
row_window_exclude as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW)
ORDER BY
user_id, value_1;
user_id, value_1, 3, 4;
-- some tests with GROUP BY, HAVING and LIMIT
SELECT