Skip to content

fix(datafusion): strip trailing semicolon before dry_run - #2463

Merged
goldmedal merged 1 commit into
Canner:mainfrom
Bartok9:fix/datafusion-dry-run-strip-semicolon
Jul 20, 2026
Merged

fix(datafusion): strip trailing semicolon before dry_run#2463
goldmedal merged 1 commit into
Canner:mainfrom
Bartok9:fix/datafusion-dry-run-strip-semicolon

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Strip trailing semicolons in DataFusion dry_run via the existing helper already used by query.
  • User SQL ending in ; no longer fails validation while limit wraps already worked.

Motivation

Other connectors (postgres, redshift, duckdb, databricks, athena) neutralize trailing semicolons before dry-run / subquery wrap. DataFusion already stripped before LIMIT wraps in query, but dry_run passed SQL through verbatim, so SELECT 1; still hit the parser as multi-statement / invalid at plan time. Reuse _strip_trailing_semicolon so dry-run matches query behavior without inventing a second path.

Verification

  • cd core/wren && .venv/bin/python -m pytest tests/unit/test_datafusion_semicolon.py -q — 7 passed
  • Real behavior proof (mocked ctx): dry_run("SELECT 1;") now invokes ctx.dry_run("SELECT 1"); SELECT ';' AS x preserved
  • Did NOT change: query LIMIT-wrap path (already correct); Apache-2.0 path core/**

License

Touches core/wren/** only (Apache-2.0).

Summary by CodeRabbit

  • Bug Fixes

    • Improved dry_run SQL preprocessing by stripping only trailing semicolons and surrounding trailing whitespace/newlines.
    • Preserved semicolons inside quoted string literals.
  • Tests

    • Added unit tests covering dry_run("SELECT 1;"), dry_run("SELECT 1; \n"), and dry_run("SELECT ';' AS x").

@github-actions github-actions Bot added python Pull requests that update Python code core labels Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Bartok9, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 566605f3-08ef-4baf-b68d-c0f87c3f9a14

📥 Commits

Reviewing files that changed from the base of the PR and between 094e3d8 and 2da09b4.

📒 Files selected for processing (2)
  • core/wren/src/wren/connector/datafusion.py
  • core/wren/tests/unit/test_datafusion_semicolon.py

Walkthrough

DataFusionConnector.dry_run now strips only trailing semicolons and whitespace before execution. Unit tests cover plain trailing semicolons, whitespace-separated terminators, and semicolons inside SQL string literals.

Changes

DataFusion dry-run semicolon handling

Layer / File(s) Summary
Dry-run normalization and validation
core/wren/src/wren/connector/datafusion.py, core/wren/tests/unit/test_datafusion_semicolon.py
dry_run removes terminating semicolons and whitespace before calling DataFusion, while tests verify preservation of semicolons inside string literals.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • Canner/WrenAI#2420: Applies equivalent trailing-semicolon handling to dry-run SQL preprocessing.
  • Canner/WrenAI#2421: Updates another connector’s dry-run normalization and literal-semicolon tests.
  • Canner/WrenAI#2430: Covers related DataFusion semicolon handling in connector SQL preprocessing and tests.

Suggested reviewers: goldmedal

Poem

A bunny trims the SQL tail,
While quoted semicolons stay in trail.
Dry runs hop through clean and bright,
Tests guard each little bite.
“No lost punctuation!” cheeps delight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: stripping trailing semicolons before DataFusion dry_run.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Bartok9
Bartok9 force-pushed the fix/datafusion-dry-run-strip-semicolon branch from ac3ad80 to 094e3d8 Compare July 10, 2026 14:49
@goldmedal

goldmedal commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

#2478 fixed the building failure of wren-core-py. Could you rebase on main to fix it?

DataFusion rejects trailing semicolons the same way limit wraps do.
Reuse the existing strip helper on dry_run so EXPLAIN-style validation
matches query behavior.
@goldmedal
goldmedal merged commit fc5949f into Canner:main Jul 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants