Repository navigation
fix(athena): strip trailing semicolon on unlimited query path - #2535
Conversation
7e7f1a6 to
e88b4f2
Compare
Unlimited Athena executes left client-pasted `;` intact; strip first so limited and unlimited paths are consistent.
e88b4f2 to
c96b577
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAthena query execution now strips trailing semicolons before execution and reuses the stripped SQL for limit wrapping. A focused unit test verifies semicolon removal on the unlimited query path. ChangesAthena query execution
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@core/wren/tests/unit/test_athena_strip_unlimited_query.py`:
- Around line 9-31: Replace both source-text and dummy-function tests with one
runtime behavior test using a mocked AthenaConnector, preferably via the
existing _make_mock_connector() helper or the setup pattern from
test_athena_limit_pushdown.py. Call connector.query("SELECT 1;") without a limit
and assert the mocked cursor.execute receives "SELECT 1", verifying the actual
connector interaction.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 545cfa47-6b07-4a00-b940-598cdcb8696f
📒 Files selected for processing (2)
core/wren/src/wren/connector/athena.pycore/wren/tests/unit/test_athena_strip_unlimited_query.py
Unit collection failed: f-string expression cannot include backslash. Move re.sub out of the f-string. Apply ruff format on query wrap.
|
Thanks @coderabbitai — good call. Replaced the source-text/dummy-function tests with a single runtime behavior test using a mocked |
|
Tip For best results, initiate chat on the files or code changes.
🐇 ✅ If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
core/wren/tests/unit/test_athena_strip_unlimited_query.py (1)
14-41: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove unnecessary
_CMcontext manager andcontextlib.closingpatch.
MagicMockhandles method calls out of the box. Sincecursoris already a mock (and itsclosemethod is explicitly mocked on line 29),contextlib.closingwill natively delegate the exit call tocursor.close()without raising any errors.Removing this custom context manager and the standard library patch eliminates redundant boilerplate and keeps the test purely focused on connector behavior.
♻️ Proposed refactor
-class _CM: - def __init__(self, obj): - self.obj = obj - - def __enter__(self): - return self.obj - - def __exit__(self, *a): - return False - - def _make_mock_connector(): connector = AthenaConnector.__new__(AthenaConnector) connector.connection = MagicMock() cursor = MagicMock() cursor.close = MagicMock() connector.connection.cursor.return_value = cursor return connector, cursor def test_query_unlimited_path_strips_trailing_semicolon(): connector, cursor = _make_mock_connector() - with ( - patch( - "wren.connector.athena._build_athena_arrow_table", return_value=MagicMock() - ), - patch("wren.connector.athena.contextlib.closing", side_effect=lambda c: _CM(c)), - ): + with patch( + "wren.connector.athena._build_athena_arrow_table", return_value=MagicMock() + ): connector.query("SELECT 1;")🤖 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_athena_strip_unlimited_query.py` around lines 14 - 41, Remove the `_CM` helper and the `contextlib.closing` patch from `test_query_unlimited_path_strips_trailing_semicolon`. Keep the `cursor` mock and its explicit `close` setup in `_make_mock_connector`, allowing the test to exercise the connector with the native `contextlib.closing` behavior.
🤖 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_athena_strip_unlimited_query.py`:
- Around line 14-41: Remove the `_CM` helper and the `contextlib.closing` patch
from `test_query_unlimited_path_strips_trailing_semicolon`. Keep the `cursor`
mock and its explicit `close` setup in `_make_mock_connector`, allowing the test
to exercise the connector with the native `contextlib.closing` behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 65a30c31-515d-4b86-b016-df4f5f30dbe5
📒 Files selected for processing (1)
core/wren/tests/unit/test_athena_strip_unlimited_query.py
|
Thanks @goldmedal — done. Folded the intermediate |
Summary
;when wrapping with LIMIT.cursor.execute.License
core/wren/**Apache-2.0.Verification
Summary by CodeRabbit
Bug Fixes
Tests