fix(databricks): strip trailing semicolon before query execute - #2477
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughDatabricks query execution now strips trailing semicolons and whitespace before calling ChangesDatabricks SQL handling
Estimated code review effort: 2 (Simple) | ~10 minutes 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.
🧹 Nitpick comments (1)
core/wren/tests/unit/test_databricks_semicolon.py (1)
48-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove unused variable and simplify exception handling.
mconn_cursor = cursor(line 53) is assigned but never referenced. Thetry/exceptblock (lines 55-59) is also unnecessary —cursor.fetchall_arrow.return_value = Nonecausesqueryto returnNone, not raise. If a real error occurred, the bareexceptwould swallow it, making the test silently pass when it should fail. Removing both clarifies intent and ensures real failures surface.♻️ Proposed cleanup
def test_query_strips_trailing_semicolon_before_execute() -> None: connector, cursor = _make_mock_connector() cursor.fetchall_arrow.return_value = None cursor.fetchmany_arrow.return_value = None - # Anything truthy so limit branch not needed - mconn_cursor = cursor - # execute should observe stripped SQL - fetchall path when limit None - try: - connector.query("SELECT 1;;") - except Exception: - # mock may return None from fetchall_arrow — only care about execute SQL - pass + connector.query("SELECT 1;;") (sent,), _ = cursor.execute.call_args assert sent == "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_databricks_semicolon.py` around lines 48 - 61, Remove the unused mconn_cursor assignment from test_query_strips_trailing_semicolon_before_execute and call connector.query("SELECT 1;;") directly without a try/except block, allowing genuine failures to surface before asserting the SQL passed to cursor.execute.
🤖 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_databricks_semicolon.py`:
- Around line 48-61: Remove the unused mconn_cursor assignment from
test_query_strips_trailing_semicolon_before_execute and call
connector.query("SELECT 1;;") directly without a try/except block, allowing
genuine failures to surface before asserting the SQL passed to cursor.execute.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 277bc968-d2e5-4d2a-93c5-bcf0bec58269
📒 Files selected for processing (2)
core/wren/src/wren/connector/databricks.pycore/wren/tests/unit/test_databricks_semicolon.py
|
The shared CI failure here ( |
a5ca95f to
9f814a1
Compare
|
Done — rebased onto latest |
9f814a1 to
1473345
Compare
dry_run already stripped; query did not. Multi-terminator user SQL could fail at the warehouse. Reuse _strip_trailing_semicolon.
1473345 to
3e3fa32
Compare
|
Thanks @goldmedal! Rebased onto latest |
Fixes F821 undefined name `_strip_trailing_semicolon` in query(); the module imports `strip_trailing_semicolon` (no leading underscore). The underscore alias only exists in tests.
Summary
_strip_trailing_semicolonon the Databricksquerypath beforecursor.execute, matchingdry_run.SELECT 1;;reaches the driver asSELECT 1.Motivation
Asymmetry with dry_run left multi-terminator SQL only partially hardened.
Apache-2.0 path:
core/wren/**.Verification
Duplicates
No open PR for query-path strip (prior #2422 was dry_run only).
Summary by CodeRabbit