Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Execute Query" should allow for a no-limit option that does not run as a subquery #1454

Open
1 task done
rmargarint-nydig opened this issue Oct 8, 2024 · 1 comment
Open
1 task done
Labels
enhancement New feature or request

Comments

@rmargarint-nydig
Copy link

rmargarint-nydig commented Oct 8, 2024

Describe the feature

"Execute Query" forces a limit and runs the query as

select *
from {
 -- the sql
}
limit 500

This has the effect that it can change the behavior of the inner sql if the inner sql has ORDER BY, as ORDER BY is guaranteed to apply only to the SELECT statement it's attached to, and has no guarantee that it will be preserved accross subqueries. So if I have a query like

select *
from foo
order by bar

and I execute it, the resulting order I get in the results tab will not necessarily be ordered by bar, nor will it be ordered in the same fashion every time, nor will it necessarily give me the same limitted count of rows every time. It lead to a lot of confusion when debugging queries.

It would be super super useful to allow the limit of rows to be set to 0 / nonexistent, and when that happens remove the subquery template and just run the query as is.

Describe alternatives you've considered

No response

Who will benefit?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@rmargarint-nydig rmargarint-nydig added the enhancement New feature or request label Oct 8, 2024
@anandgupta42
Copy link
Contributor

@rmargarint-nydig Thanks for offering to help to sbumit a PR. Let us know if you need any help.

anandgupta42 added a commit that referenced this issue Jan 6, 2025
- Added new template for queries with ORDER BY clause

- Detect ORDER BY clause using case-insensitive regex

- Apply limit directly to query when ORDER BY is present to preserve ordering

- Keep existing subquery approach for queries without ORDER BY

Fixes #1454
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants