Skip to content

fix(wren): bigquery and duckdb LIMIT wrap breaks on SQL ending in a trailing comment - #2734

Merged
goldmedal merged 1 commit into
Canner:mainfrom
AmirF194:fix/2733-limit-wrap-bigquery-duckdb-trailing-comment
Sep 14, 2026
Merged

goldmedal merged 1 commit into
Canner:mainfrom
AmirF194:fix/2733-limit-wrap-bigquery-duckdb-trailing-comment

Conversation

@AmirF194

@AmirF194 AmirF194 commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Refs #2733. Only bigquery.py and duckdb.py here, so this doesn't close it: see the scope note below.

bigquery.py's _apply_limit and duckdb.py's query()/dry_run() wrap on one line too, so a trailing SQL line comment eats the closing paren, alias and LIMIT clause the same way postgres.py did before #2728. Wrapped both onto their own line, matching the postgres.py/athena.py shape.

bigquery.py's dry_run() never wraps (no LIMIT there), so it needed no change.

Scoped to these two connectors: they cover both cases you verified live in the issue (DuckDB and BigQuery). canner.py, clickhouse.py, databricks.py, oracle.py, redshift.py and trino.py have the same shape and are a natural fast-follow, left out here to keep the diff small.

Added a regression test per call site with a trailing-comment SQL string; each fails on the unmodified wrap and passes with it multiline. Ran tests/unit/ (1450 passed, 2 skipped) and ruff format/ruff check on src/, all clean.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed limited queries containing trailing SQL line comments so closing syntax and LIMIT clauses are processed correctly.
    • Improved consistency of wrapped query formatting across BigQuery and DuckDB connectors.
  • Tests

    • Added coverage for limited and dry-run queries containing trailing line comments.
    • Updated expectations for multiline wrapped queries.

…railing comment

Canner#2728 fixed this for postgres. bigquery.py's _apply_limit and duckdb.py's
query()/dry_run() wrap the caller's SQL the same way, on one line, so a
trailing SQL line comment eats the closing paren, alias and LIMIT clause.
Put the wrap on its own line, same technique as postgres.py/athena.py.

Regression test per connector with a trailing-comment SQL string, fails on
the unmodified wrap and passes with it multiline.
@github-actions github-actions Bot added python Pull requests that update Python code core labels Sep 9, 2026
@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 36a6cc93-b9e6-47f8-adb7-8f210414a8fd

📥 Commits

Reviewing files that changed from the base of the PR and between 19495ee and 661216c.

📒 Files selected for processing (5)
  • core/wren/src/wren/connector/bigquery.py
  • core/wren/src/wren/connector/duckdb.py
  • core/wren/tests/unit/test_bigquery_semicolon.py
  • core/wren/tests/unit/test_duckdb_file_listing.py
  • core/wren/tests/unit/test_duckdb_semicolon_unlimited.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

BigQuery and DuckDB now use multiline SQL wrappers for limited queries and dry runs. Tests cover trailing line comments, semicolons, literals, and nested limits.

Changes

SQL limit wrappers

Layer / File(s) Summary
BigQuery limit wrapper
core/wren/src/wren/connector/bigquery.py, core/wren/tests/unit/test_bigquery_semicolon.py
_apply_limit now places inner SQL on separate lines. Tests cover trailing comments, semicolons, and nested limits.
DuckDB limit wrappers
core/wren/src/wren/connector/duckdb.py, core/wren/tests/unit/test_duckdb_file_listing.py, core/wren/tests/unit/test_duckdb_semicolon_unlimited.py
query and dry_run now place inner SQL on separate lines. Tests cover trailing comments, semicolons, and string literals.

Priority: ⬇️ Low

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

Merge Risk: ⚪ Minimal · up to 66121

BigQuery and DuckDB limited-query wrappers now safely preserve trailing SQL line comments while retaining existing semicolon and limit behavior. The affected paths have focused regression coverage, with no remaining merge-readiness risk identified.

Suggested reviewers: bartok9

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, affected connectors, tests, and reported results. However, it does not provide the required reproduction with the actual error output, and it does not explicitly i… Add the failing SQL reproduction and actual error output under a failure section. Add an explicit duplicate-check statement that lists the open PRs reviewed, or states that no duplicates were found. Use the template headings if possible.
Docstring Coverage ⚠️ Warning Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the BigQuery and DuckDB LIMIT-wrapping defect involving trailing SQL comments.
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.
Full details: Description check

Explanation

The description explains the change, affected connectors, tests, and reported results. However, it does not provide the required reproduction with the actual error output, and it does not explicitly identify which open PRs were checked for duplicates.

  • Fix all pre-merge checks with AI
✨ 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

A rabbit wraps each query line
Newlines keep comments in design
Semicolons stay in place
Limits close with proper space
Hop, the tests now pass in time

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

AmirF194 added a commit to AmirF194/WrenAI that referenced this pull request Sep 9, 2026
… in a trailing comment

Canner#2733 is the fast-follow to Canner#2728 (postgres) and Canner#2734 (bigquery/duckdb):
oracle.py's query()/dry_run(), redshift.py's query()/dry_run() and
trino.py's query()/dry_run() all wrap the caller's SQL on one line, so a
trailing SQL line comment eats the closing paren, alias/ROWNUM clause and
LIMIT clause. Put the wrap on its own line, same technique as postgres.py.

Regression test per connector with a trailing-comment SQL string, fails on
the unmodified wrap and passes with it multiline. Scope limited to these
three connectors; canner.py/clickhouse.py/databricks.py/datafusion.py are
left for a separate PR since open drafts Canner#2551/Canner#2552 already touch those
wrap lines for an unrelated parameter-binding change.

Signed-off-by: Amir Fathi <[email protected]>

@goldmedal goldmedal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AmirF194 👍

@goldmedal
goldmedal merged commit 0be34c0 into Canner:main Sep 14, 2026
13 checks passed
@AmirF194

Copy link
Copy Markdown
Contributor Author

Glad it landed. The trailing-comment case was the kind of thing that only shows up once someone's SQL happens to end that way.

@AmirF194
AmirF194 deleted the fix/2733-limit-wrap-bigquery-duckdb-trailing-comment branch September 14, 2026 02:12
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