Skip to content

test(sql): pin optimizer hint blocks survive format() round-trip (#38189) - #42733

Open
rusackas wants to merge 3 commits into
masterfrom
tdd/issue-38189-sql-hint-comment-corruption
Open

test(sql): pin optimizer hint blocks survive format() round-trip (#38189)#42733
rusackas wants to merge 3 commits into
masterfrom
tdd/issue-38189-sql-hint-comment-corruption

Conversation

@rusackas

@rusackas rusackas commented Aug 3, 2026

Copy link
Copy Markdown
Member

SUMMARY

Regression test for #38189, which reported that Superset's SQL parser injects a repositioned -- comment inside a /*+ SET_VAR(...) */ optimizer hint block, producing invalid SQL for StarRocks/MySQL-style engines that use the /*+ ... */ hint convention.

The original repro (no terminating ;) doesn't reproduce against the actual execution-time code path: SQLStatement.format(), the same method superset/sql/execution/executor.py and superset/sql/execution/celery_task.py call to build the SQL that's actually sent to the engine. With the currently pinned sqlglot 30.12.0, the trailing -- comment is repositioned safely after the statement, not injected inside the hint block, for that form.

However, a ;-terminated statement (as flagged in review) still hits the broken relocation branch and reproduces the corruption. So #38189 is only partially fixed and should stay open for that case. This PR adds two tests: one pinning the now-fixed no-semicolon form, and one xfail(strict=True) pinning the still-broken semicolon form so a future fix will surface as an unexpected pass and can flip to a real regression test.

TESTING INSTRUCTIONS

pytest tests/unit_tests/sql/parse_tests.py -k optimizer_hint_block

ADDITIONAL INFORMATION

)

Reporter's repro (SELECT with a /*+ SET_VAR(...) */ StarRocks/MySQL-style
optimizer hint plus a trailing -- comment) doesn't reproduce against the
actual execution-time code path: SQLStatement.format(), the same method
executor.py and celery_task.py call to build the SQL sent to the engine.
sqlglot 30.12.0 repositions the trailing comment safely after the
statement instead of injecting it inside the hint block. Passes on
current master, closing #38189 as already fixed.
@bito-code-review

bito-code-review Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #c4c877

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: bc80bcb..bc80bcb
    • tests/unit_tests/sql/parse_tests.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.56%. Comparing base (25ab961) to head (c1e7892).
⚠️ Report is 134 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42733      +/-   ##
==========================================
- Coverage   65.57%   65.56%   -0.01%     
==========================================
  Files        2818     2821       +3     
  Lines      160038   159249     -789     
  Branches    36557    36386     -171     
==========================================
- Hits       104942   104419     -523     
+ Misses      53051    52804     -247     
+ Partials     2045     2026      -19     
Flag Coverage Δ
hive 38.24% <ø> (+0.16%) ⬆️
mysql 57.78% <ø> (-0.09%) ⬇️
postgres 57.83% <ø> (-0.09%) ⬇️
presto 40.20% <ø> (+0.23%) ⬆️
python 59.22% <ø> (-0.07%) ⬇️
sqlite 57.45% <ø> (-0.09%) ⬇️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas
rusackas requested a review from sadpandajoe August 4, 2026 00:28
Comment thread tests/unit_tests/sql/parse_tests.py
@bito-code-review

Copy link
Copy Markdown
Contributor

The current test case in tests/unit_tests/sql/parse_tests.py uses a query without a terminating semicolon (LIMIT 100). To cover the semicolon form and ensure the issue remains open until the underlying formatting logic is corrected, you can add a second test case or update the existing one to include a semicolon.

Updating the test to include a semicolon would look like this:

    sql = """SELECT /*+ SET_VAR(query_timeout = 3000) */ col1, col2
FROM my_table
LIMIT 100;

-- increase timeout for large scans"""

This will verify if the formatter correctly handles the semicolon without corrupting the optimizer hint block.

tests/unit_tests/sql/parse_tests.py

sql = """SELECT /*+ SET_VAR(query_timeout = 3000) */ col1, col2
FROM my_table
LIMIT 100;

-- increase timeout for large scans"""

)

Review flagged that the no-semicolon repro passing on master doesn't mean
#38189 is fully closed: a `;`-terminated statement still hits the comment
relocation branch and corrupts the /*+ SET_VAR(...) */ hint block. Add an
xfail(strict=True) test pinning that still-broken case.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pull-request-size pull-request-size Bot added size/M and removed size/S labels Aug 8, 2026
@netlify

netlify Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 3a6e713
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a76bd9b15f8970008a6c562
😎 Deploy Preview https://deploy-preview-42733--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread tests/unit_tests/sql/parse_tests.py Outdated
@bito-code-review

bito-code-review Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #b9c9a6

Actionable Suggestions - 0
Additional Suggestions - 1
  • tests/unit_tests/sql/parse_tests.py - 1
    • xfail strict=True will fail CI on fix · Line 968-968
      The `strict=True` parameter on this xfail marker will cause the entire test suite to fail once the underlying bug is fixed. Pytest will treat a "unexpectedly passing" xfail as a failure when `strict=True` is set, which is the opposite of the desired behavior when the bug is eventually resolved.
Review Details
  • Files reviewed - 1 · Commit Range: bc80bcb..3a6e713
    • tests/unit_tests/sql/parse_tests.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Assert the trailing comment survives outside the hint block (not just
that the specific corruption string is absent), per codeant-ai review.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f0c768

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 3a6e713..c1e7892
    • tests/unit_tests/sql/parse_tests.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants