Skip to content

feat: enable auto limit for Trino query runner - #7750

Merged
yoshiokatsuneo merged 3 commits into
getredash:masterfrom
bonisb:trino-auto-limit
Aug 10, 2026
Merged

feat: enable auto limit for Trino query runner#7750
yoshiokatsuneo merged 3 commits into
getredash:masterfrom
bonisb:trino-auto-limit

Conversation

@bonisb

@bonisb bonisb commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What

Make the Trino query runner inherit from BaseSQLQueryRunner instead of BaseQueryRunner so it supports the "auto limit" feature.

Why

BaseQueryRunner reports supports_auto_limit = False and implements apply_auto_limit as a no-op. Because Trino inherited directly from BaseQueryRunner:

  • the Limit 1000 toggle was hidden in the query editor (the frontend reads supports_auto_limit from the data source), and
  • the apply_auto_limit query option had no effect even when explicitly set — the query was passed through unchanged.

BaseSQLQueryRunner provides a working implementation that appends LIMIT 1000 to unbounded SELECT statements (leaving statements that already have a LIMIT/OFFSET, and non-SELECT statements, untouched).

How

  • Trino now extends BaseSQLQueryRunner.
  • Trino uses standard ANSI LIMIT n syntax, so the default limit_query = " LIMIT 1000" works unchanged.
  • Trino already overrides get_schema, so the SQL base class's _get_tables schema helpers are not used and schema loading is unaffected.

Tests

Added tests in tests/query_runner/test_trino.py covering:

  • supports_auto_limit is True
  • auto limit is appended to a SELECT with no limit
  • an existing LIMIT is preserved
  • nothing is changed when auto limit is disabled

🤖 Generated with Claude Code

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>
@bonisb bonisb changed the title Enable auto limit for Trino query runner feat: enable auto limit for Trino query runner Jun 5, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Aug 9, 2026

Copy link
Copy Markdown

Greptile Summary

This PR enables the existing SQL auto-limit behavior for Trino by changing its query-runner base class.

  • Makes Trino advertise auto-limit support.
  • Applies the standard LIMIT 1000 rewriting behavior to eligible queries.
  • Adds focused tests for enabled, disabled, and existing-limit cases.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

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

yoshiokatsuneo commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@bonisb

Thank you for your contribution !

The PR is simple enough and reasonable.
And, I confirmed that simple queries can run with Trino data source.

So, I can approve the PR.

Please note that the query hashes for existing Trino queries need to be updated.

(Ex. by running docker compose run --rm server manage query rehash )

@yoshiokatsuneo
yoshiokatsuneo merged commit 7cf3b51 into getredash:master Aug 10, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants