fix(spark): push LIMIT into SQL instead of client slice#2574
Conversation
Avoid full result materialization before Arrow slice; wrap dry_run in LIMIT 0 subquery after stripping trailing semicolons.
|
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)
WalkthroughSparkConnector now strips trailing semicolons and pushes query limits into Spark SQL subquery wrappers. Dry runs use cleaned SQL with ChangesSpark SQL limit 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.
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/spark.py`:
- Around line 29-30: Validate limit before the SQL construction in the
limit-handling branch, rejecting negative values with a clear connector-level
validation error. Preserve the existing int conversion and LIMIT generation for
non-negative limits, including zero.
🪄 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 Plus
Run ID: 0efd5983-ebbc-421f-83dd-a5fd8d924243
📒 Files selected for processing (2)
core/wren/src/wren/connector/spark.pycore/wren/tests/unit/test_spark_semicolon.py
|
Addressed in e1474b4 — negative limits now raise a clear connector-level ValueError before SQL construction, matching the MySQL connector's _coerce_limit pattern (zero still allowed). |
Summary
LIMIT ninto Spark SQL via subquery wrap (after semicolon strip)SELECT * FROM (...) LIMIT 0instead of client.limit(0)License
Apache-2.0 (
core/**).Motivation
Spark connector applied
limitonly aftertoPandas(), so engine still produced full results for bounded asks. Matches DuckDB/Postgres pushdown style.Verification
cd core/wren && .venv/bin/python -m pytest tests/unit/test_spark_semicolon.py -v— 5 passedDuplicate check
Summary by CodeRabbit
Bug Fixes
LIMITinto Spark SQL (instead of client-side slicing), reducing unnecessary data processing.LIMIT 0before counting, and continuing to handle trailing semicolons safely.Tests
LIMIT 0wrapping behavior.