-
Notifications
You must be signed in to change notification settings - Fork 1.6k
incorrect limit result when using within subquery and union #6381
Copy link
Copy link
Closed
Labels
BugIncorrect or unexpected behaviorIncorrect or unexpected behaviorSQLIssues or changes relating to SQL executionIssues or changes relating to SQL execution
Description
To reproduce
DECLARE
@tbl := trades
SELECT * FROM (
(SELECT timestamp FROM @tbl LIMIT 1)
UNION ALL
(SELECT timestamp FROM @tbl LIMIT -1)
);| timestamp |
| --------------------------- |
| 2022-03-08T18:03:57.609765Z |
| 2022-03-08T18:03:57.609765Z |
The plan:
Union All
Limit lo: 1 skip-over-rows: 0 limit: 1
PageFrame
Row forward scan
Frame forward scan on: trades
Limit lo: -1 skip-over-rows: 0 limit: 1
PageFrame
Row forward scan
Frame forward scan on: trades
but it should be ...
DECLARE
@tbl := trades
SELECT * FROM (
(SELECT min(timestamp) FROM @tbl)
UNION ALL
(SELECT max(timestamp) FROM @tbl)
);| min(timestamp) |
| --------------------------- |
| 2022-03-08T18:03:57.609765Z |
| 2025-11-11T13:17:28.411000Z |
QuestDB version:
9.1.1
OS, in case of Docker specify Docker and the Host OS:
N/A
File System, in case of Docker specify Host File System:
N/A
Full Name:
Nick Woolmer
Affiliation:
QuestDB
Have you followed Linux, MacOs kernel configuration steps to increase Maximum open files and Maximum virtual memory areas limit?
- Yes, I have
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugIncorrect or unexpected behaviorIncorrect or unexpected behaviorSQLIssues or changes relating to SQL executionIssues or changes relating to SQL execution