Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Invalid
-
1.19.0
-
None
-
None
Description
CREATE TABLE test (id INT, val INT); INSERT INTO test VALUES (1,1); INSERT INTO test VALUES (2,2); INSERT INTO test VALUES (3,3); INSERT INTO test VALUES (4,4); SELECT id FROM (SELECT id, val FROM test ORDER BY val DESC);
Looks like CALCITE-2798 removes the sorting in sub-queries too aggressively.
Update:
I might be wrong here and jumped the gun too early.
Looks like SQL does not dictate that the outer query has to retain any order of the inner query.
The sort is applied if a LIMIT is specified in the inner query, to reduce the inner result correctly.
Happy to close as invalid.
Attachments
Issue Links
- Blocked
-
CALCITE-3738 Missing LogicalSort for INSERT statement
- Closed
- is caused by
-
CALCITE-2798 Optimizer should remove ORDER BY in sub-query, provided it has no LIMIT or OFFSET
- Closed
- relates to
-
CALCITE-6063 If ARRAY subquery has ORDER BY (without LIMIT), rows are not sorted
- Closed