feat: enable auto limit for Trino query runner - #7750
Merged
Conversation
The Trino query runner inherited from BaseQueryRunner, which reports supports_auto_limit = False and leaves apply_auto_limit as a no-op. As a result the "Limit 1000" toggle was hidden in the query editor and the apply_auto_limit option had no effect, even when set on a query. Switch Trino to inherit from BaseSQLQueryRunner so it advertises auto-limit support and appends "LIMIT 1000" to unbounded SELECTs. Trino uses standard ANSI LIMIT syntax, so the default limit_query works as-is, and Trino already overrides get_schema, so the SQL base class's schema helpers are not used. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR enables the existing SQL auto-limit behavior for Trino by changing its query-runner base class.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| redash/query_runner/trino.py | Changes Trino to inherit the shared SQL query-runner behavior; its existing schema and execution overrides remain compatible. |
| tests/query_runner/test_trino.py | Adds focused coverage for Trino auto-limit capability and query rewriting. |
Reviews (2): Last reviewed commit: "Merge branch 'master' into trino-auto-li..." | Re-trigger Greptile
yoshiokatsuneo
approved these changes
Aug 10, 2026
Contributor
|
Thank you for your contribution ! The PR is simple enough and reasonable. So, I can approve the PR. Please note that the query hashes for existing Trino queries need to be updated. (Ex. by running |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make the Trino query runner inherit from
BaseSQLQueryRunnerinstead ofBaseQueryRunnerso it supports the "auto limit" feature.Why
BaseQueryRunnerreportssupports_auto_limit = Falseand implementsapply_auto_limitas a no-op. BecauseTrinoinherited directly fromBaseQueryRunner:supports_auto_limitfrom the data source), andapply_auto_limitquery option had no effect even when explicitly set — the query was passed through unchanged.BaseSQLQueryRunnerprovides a working implementation that appendsLIMIT 1000to unboundedSELECTstatements (leaving statements that already have aLIMIT/OFFSET, and non-SELECTstatements, untouched).How
Trinonow extendsBaseSQLQueryRunner.LIMIT nsyntax, so the defaultlimit_query = " LIMIT 1000"works unchanged.Trinoalready overridesget_schema, so the SQL base class's_get_tablesschema helpers are not used and schema loading is unaffected.Tests
Added tests in
tests/query_runner/test_trino.pycovering:supports_auto_limitisTrueSELECTwith no limitLIMITis preserved🤖 Generated with Claude Code