Repository navigation
refactor(connector): share strip_trailing_semicolon in base - #2480
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:
WalkthroughCentralizes trailing-semicolon stripping in ChangesSQL preprocessing refactor
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 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 |
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/src/wren/connector/mysql.py`:
- Line 21: Remove the duplicate strip_trailing_semicolon entry from the import
statement in the MySQL connector, keeping a single import alongside
ConnectorABC.
🪄 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: 8faa526f-b212-4a68-a580-3c369cf80785
📒 Files selected for processing (21)
core/wren/src/wren/connector/athena.pycore/wren/src/wren/connector/base.pycore/wren/src/wren/connector/canner.pycore/wren/src/wren/connector/clickhouse.pycore/wren/src/wren/connector/databricks.pycore/wren/src/wren/connector/datafusion.pycore/wren/src/wren/connector/duckdb.pycore/wren/src/wren/connector/mysql.pycore/wren/src/wren/connector/oracle.pycore/wren/src/wren/connector/postgres.pycore/wren/src/wren/connector/redshift.pycore/wren/src/wren/connector/trino.pycore/wren/tests/connectors/test_canner.pycore/wren/tests/connectors/test_postgres.pycore/wren/tests/unit/test_athena_semicolon.pycore/wren/tests/unit/test_databricks_semicolon.pycore/wren/tests/unit/test_datafusion_semicolon.pycore/wren/tests/unit/test_oracle_semicolon.pycore/wren/tests/unit/test_redshift_semicolon.pycore/wren/tests/unit/test_strip_trailing_semicolon.pycore/wren/tests/unit/test_trino_parser.py
|
The shared CI failure here ( |
a87586d to
cb8f97e
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
core/wren/src/wren/connector/oracle.py (1)
17-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDrop the unused alias and keep imports contiguous
_strip_trailing_semicolonis no longer used; remove it.- Move
from wren.model.error import ...up with the other imports so the module has a single import block.🤖 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/src/wren/connector/oracle.py` around lines 17 - 21, Remove the unused _strip_trailing_semicolon alias from the module, and move the wren.model.error import into the contiguous top-level import block alongside the other imports.
🤖 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/src/wren/connector/oracle.py`:
- Around line 17-21: Remove the unused _strip_trailing_semicolon alias from the
module, and move the wren.model.error import into the contiguous top-level
import block alongside the other imports.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f4279de5-3cb2-42d1-aed9-7bca38208b1d
📒 Files selected for processing (21)
core/wren/src/wren/connector/athena.pycore/wren/src/wren/connector/base.pycore/wren/src/wren/connector/canner.pycore/wren/src/wren/connector/clickhouse.pycore/wren/src/wren/connector/databricks.pycore/wren/src/wren/connector/datafusion.pycore/wren/src/wren/connector/duckdb.pycore/wren/src/wren/connector/mysql.pycore/wren/src/wren/connector/oracle.pycore/wren/src/wren/connector/postgres.pycore/wren/src/wren/connector/redshift.pycore/wren/src/wren/connector/trino.pycore/wren/tests/connectors/test_canner.pycore/wren/tests/connectors/test_postgres.pycore/wren/tests/unit/test_athena_semicolon.pycore/wren/tests/unit/test_databricks_semicolon.pycore/wren/tests/unit/test_datafusion_semicolon.pycore/wren/tests/unit/test_oracle_semicolon.pycore/wren/tests/unit/test_redshift_semicolon.pycore/wren/tests/unit/test_strip_trailing_semicolon.pycore/wren/tests/unit/test_trino_parser.py
🚧 Files skipped from review as they are similar to previous changes (18)
- core/wren/src/wren/connector/redshift.py
- core/wren/tests/connectors/test_postgres.py
- core/wren/tests/unit/test_strip_trailing_semicolon.py
- core/wren/tests/unit/test_athena_semicolon.py
- core/wren/src/wren/connector/postgres.py
- core/wren/tests/unit/test_redshift_semicolon.py
- core/wren/tests/unit/test_trino_parser.py
- core/wren/src/wren/connector/databricks.py
- core/wren/src/wren/connector/mysql.py
- core/wren/src/wren/connector/datafusion.py
- core/wren/tests/unit/test_databricks_semicolon.py
- core/wren/src/wren/connector/base.py
- core/wren/tests/unit/test_datafusion_semicolon.py
- core/wren/src/wren/connector/trino.py
- core/wren/tests/connectors/test_canner.py
- core/wren/tests/unit/test_oracle_semicolon.py
- core/wren/src/wren/connector/duckdb.py
- core/wren/src/wren/connector/canner.py
|
Thanks @goldmedal 🙏 This branch already includes the |
|
One gap before this lands: _TRAILING_SEMICOLONS_RE = re.compile(r"[;\s]+\Z")
def _strip_trailing_semicolon(sql: str) -> str:
...
return _TRAILING_SEMICOLONS_RE.sub("", sql)This PR migrates 11 connectors (athena, canner, clickhouse, databricks, datafusion, duckdb, oracle, postgres, redshift, trino, mysql) but leaves snowflake with a 12th, byte-identical copy — so the "single shared helper" goal isn't fully met, and the description ("migrate every connector onto it" / "removes 10 local helper copies") slightly overstates it. It's almost certainly just because snowflake's copy landed after #2441 was scoped (it's not in that issue's enumeration). Since it uses the exact same regex, folding it in is a one-file mechanical change: - _TRAILING_SEMICOLONS_RE = re.compile(r"[;\s]+\Z")
- def _strip_trailing_semicolon(sql: str) -> str:
- ...
- return _TRAILING_SEMICOLONS_RE.sub("", sql)
+ from wren.connector.base import strip_trailing_semicolon(plus the two call sites, and drop the now-unused Suggest including snowflake here so the shared helper is genuinely the single source of truth before other PRs rebase onto it — the open snowflake fix adds another strip call site, and it'd be better for that to land on the shared helper than to grow the local copy. Otherwise the migration itself looks clean: no leftover local helpers in the 11, all wired to |
|
Good catch @goldmedal 🙏 — snowflake's copy landed after #2441 was scoped, so it wasn't in the enumeration. Just folded it in (b3ae60b): dropped snowflake's local |
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/src/wren/connector/snowflake.py`:
- Around line 7-9: Update test_snowflake_limit_pushdown.py to import
strip_trailing_semicolon from wren.connector.base instead of the removed
_strip_trailing_semicolon from wren.connector.snowflake, and replace all test
calls accordingly.
🪄 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: 7398ffc7-ff05-44ae-a8cb-1fb696ed3083
📒 Files selected for processing (2)
core/wren/src/wren/connector/oracle.pycore/wren/src/wren/connector/snowflake.py
…olon Fold the byte-identical local _strip_trailing_semicolon copy in snowflake.py onto wren.connector.base.strip_trailing_semicolon, so the shared helper is the single source of truth for all 12 connectors. Drops the now-unused local regex and import re.
b3ae60b to
9d9cd4e
Compare
|
Rebased onto latest |
|
Filed the follow-up plan so the remaining trailing-semicolon work stays coherent after this consolidation lands, instead of a stream of per-connector PRs:
Both #2497 and #2498 are blocked on this PR (they should import the shared helper rather than re-add local copies). Redundant PRs will be closed in favor of these: #2463 (⊂ #2483), and #2474 / #2475 (their trino/mysql multi-semicolon fix is already delivered by this PR's migration). |
|
Perfect — thanks for sequencing this @goldmedal 🙏. Consolidating to a single |
…down tests The athena and snowflake limit-pushdown tests still imported the removed private _strip_trailing_semicolon; point them at the shared wren.connector.base helper (aliased) to match the other migrated tests.
|
Pushed aa09bfd — fixed the failing |
|
Thanks — and nice catch folding athena + snowflake back in; good to have all 12 connectors on the single helper. Let's keep #2480 first, so no need to pre-rebase for a #2483-first ordering. Once this merges, #2497 and #2498 build straight on top of #2483 will be absorbed, not merged independently: its unlimited- So the path is: merge #2480 → #2497 / #2498 → close #2483 / #2463 / #2474 / #2475. Appreciate the quick turnaround on the rebase 🙏 |
|
🎉 Merged — thanks @goldmedal. Confirmed path: #2480 (done) → #2497 (unlimited |
Route query/dry_run through connector.base.strip_trailing_semicolon instead of a per-connector copy, per Canner#2441 consolidation (Canner#2480).
Summary
strip_trailing_semicolon(regex terminating-run) intowren.connector.baseand migrate connectors onto it.Motivation
Closes #2441.
Per-connector copies of
_strip_trailing_semicolondrifted (regex run vs singleremovesuffix/rstrip). Maintainers agreed in the #2430 review thread to consolidate on one helper inconnector/base.py. Scope iscore/wrenonly (Apache-2.0).Verification
core/wren/.venv/bin/python -m pytest tests/unit/test_strip_trailing_semicolon.py tests/unit/test_athena_semicolon.py tests/unit/test_databricks_semicolon.py tests/unit/test_redshift_semicolon.py tests/unit/test_oracle_semicolon.py tests/unit/test_datafusion_semicolon.py tests/unit/test_trino_parser.py::test_strip_trailing_semicolon tests/connectors/test_postgres.py -k "strip or semicolon" -q— 38 passedtests/connectors/test_canner.py -k strip— 7 passedReal behavior proof (shared helper):
strip_trailing_semicolon("SELECT 1 ; ;") == "SELECT 1"strip_trailing_semicolon("SELECT 'a;b' AS x;") == "SELECT 'a;b' AS x"Summary by CodeRabbit
Bug Fixes
EXPLAIN-style dry runs.Refactor
Tests