fix(spark): strip trailing semicolon before sql/dry_run#2464
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 (2)
WalkthroughSpark query and dry-run execution now strip trailing semicolons and whitespace before calling the Spark session. Unit tests cover normalization, string literals, unchanged SQL, and the dry-run zero-row limit. ChangesSpark SQL normalization
Estimated code review effort: 2 (Simple) | ~10 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.
🧹 Nitpick comments (1)
core/wren/tests/unit/test_spark_semicolon.py (1)
16-26: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove unused mock variables
dfanddfto.Lines 18-20 create
dfanddftoasMagicMockobjects that are never used. The actual mock chain is set up on line 24 viasession.sql.return_value.toPandas.return_value, making these variables dead code that adds confusion about the test's mock setup.🧹 Proposed cleanup
def test_query_strips_trailing_semicolon_before_sql() -> None: connector, session = _make_mock_connector() - df = MagicMock() - df.attrs = {} - dfto = MagicMock() # pandas DF mock for pa.Table.from_pandas import pandas as pd🤖 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_spark_semicolon.py` around lines 16 - 26, Remove the unused MagicMock variables df and dfto from test_query_strips_trailing_semicolon_before_sql; retain only the session.sql.return_value.toPandas.return_value setup needed by the test.
🤖 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_spark_semicolon.py`:
- Around line 16-26: Remove the unused MagicMock variables df and dfto from
test_query_strips_trailing_semicolon_before_sql; retain only the
session.sql.return_value.toPandas.return_value setup needed by the test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9e41eb13-e1b9-465d-8584-7d69ce3d0a23
📒 Files selected for processing (2)
core/wren/src/wren/connector/spark.pycore/wren/tests/unit/test_spark_semicolon.py
CodeRabbit trivial nit on Canner#2464.
|
Addressed CodeRabbit trivial: removed unused |
CodeRabbit trivial nit on Canner#2464.
e9a26bd to
e331b6f
Compare
|
#2478 fixed the building failure of |
CodeRabbit trivial nit on Canner#2464.
e331b6f to
6a9b5f2
Compare
|
@goldmedal Done — rebased onto current |
CodeRabbit trivial nit on Canner#2464.
6a9b5f2 to
7f1d274
Compare
|
This PR should also change to the shared |
|
@Bartok9, could you modify this PR? |
Spark Connect sql() mishandles trailing semicolons; strip them with the same terminating-run helper pattern used by other connectors.
CodeRabbit trivial nit on Canner#2464.
Route query/dry_run through connector.base.strip_trailing_semicolon instead of a per-connector copy, per Canner#2441 consolidation (Canner#2480).
7f1d274 to
fda0362
Compare
|
@goldmedal Done — refactored to route |
Summary
;/ whitespace before Spark Connectsql()in bothqueryanddry_run.Motivation
Postgres/redshift/duckdb/databricks/datafusion already sanitize trailing semicolons before plan/execute paths. Spark still passed raw SQL into
SparkSession.sql(...), so statements likeSELECT 1;hit Connect/parser multi-statement roughness and pouch provenance protection. Reuse the terminating-run strip helper so literals such asSELECT ';'stay intact while terminal;is removed.Verification
core/wren/.venv/bin/python -m pytest tests/unit/test_spark_semicolon.py -q— 4 passedquery("SELECT 1;", limit=2)callssql("SELECT 1"); dry_run strips trailing whitespace+semicolonLicense
core/wren/**only (Apache-2.0).Summary by CodeRabbit