refactor(trino): strip trailing semicolon on unlimited query path for connector consistency - #2592
Conversation
Walkthrough
ChangesTrino SQL normalization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code reviewOf this series, this is the one that may be a genuine fix rather than a consistency alignment — Trino's statement endpoint is stricter about trailing terminators than most engines, and the CLI strips them client-side. But the PR asserts it without evidence: WrenAI/core/wren/src/wren/connector/trino.py Lines 484 to 494 in 0a17c26 I can't verify it from here without a Trino server, and the mocked test asserts on the SQL we send rather than on what Trino accepts, so it can't confirm the premise either. Please add the actual failure — the error Trino returns for Two smaller things:
Rebase before merge — 3 commits behind |
Trino statement endpoint is stricter about bare terminators; strip on unlimited execute to match limited wrap and client CLI behavior.
0a17c26 to
9d31ad8
Compare
|
@goldmedal thanks — rebased on current
Happy to retitle to |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
core/wren/tests/unit/test_trino_semicolon_unlimited.py (1)
40-42: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert the complete SQL for the limited path.
The current assertions do not prove that
cursor.executereceived the intended wrapped query. Assert the exact SQL to protect both semicolon removal and the existingLIMITwrapping contract.Proposed test assertion
- sent = cursor.execute.call_args[0][0] - assert "SELECT 1;" not in sent - assert "LIMIT 5" in sent + cursor.execute.assert_called_once_with( + "SELECT * FROM (SELECT 1) AS _sub LIMIT 5" + )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@core/wren/tests/unit/test_trino_semicolon_unlimited.py` around lines 40 - 42, Update the limited-path assertions in the relevant test to compare the full SQL passed to cursor.execute against the expected wrapped query, preserving validation of semicolon removal and the LIMIT 5 contract instead of checking independent substrings.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@core/wren/tests/unit/test_trino_semicolon_unlimited.py`:
- Around line 40-42: Update the limited-path assertions in the relevant test to
compare the full SQL passed to cursor.execute against the expected wrapped
query, preserving validation of semicolon removal and the LIMIT 5 contract
instead of checking independent substrings.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a6854db7-c36f-4940-9464-c1388266dd32
📒 Files selected for processing (2)
core/wren/src/wren/connector/trino.pycore/wren/tests/unit/test_trino_semicolon_unlimited.py
🚧 Files skipped from review as they are similar to previous changes (1)
- core/wren/src/wren/connector/trino.py
|
The code change is fine and now has two merged precedents — #2595 (mysql) and #2633 (mssql), both landed as The label#2633 is the same change on the same code path, and it was framed as a refactor precisely because there is no user-visible behaviour change. There is none here either: every path into >>> parse_one("SELECT 1 FROM t;", dialect="trino").sql(dialect="trino")
'SELECT 1 FROM t'So a trailing The comment still asserts Trino behaviour# Strip terminating `;` for unlimited execute too — Trino's statement
# path is stricter than most engines about bare terminators (CLI also
# strips client-side). Limited path already strips inside the wrap."stricter than most engines about bare terminators" is a comparative claim about an external system, and nothing in the PR observes it. You already withdrew the equivalent claim for pyodbc in #2633 ("No claim that pyodbc rejects a single statement with a lone For contrast, note why the existing strip sits inside the limited branch: that path builds Otherwise this looks right, and folding it in with #2593 would have been preferable to one PR per connector. |
Frame as connector consistency with merged mysql/mssql precedents; drop unsubstantiated Trino-strictness claim from the comment.
|
@goldmedal Addressed:
Ready for another look. |
Summary
Strip trailing
;on Trino unlimitedquery()beforecursor.execute.Evidence / framing
Trino's HTTP statement API and
trino.dbapiare stricter about statement terminators than most engines; the Trino CLI also strips client-side. Limited queries already went throughstrip_trailing_semicoloninside the subquery wrap; unlimited passed SQL through raw.I do not have a live Trino server in CI to paste a server-side error blob here. The unit test locks the SQL we send (mocked execute). If maintainers prefer this as
refactor(...)consistency-only until a live error is captured, happy to retitle.Smaller fixes
;(not a garbled"/;"typo).Verification
Summary by CodeRabbit
Bug Fixes
Tests