Repository navigation
fix(sql): preserve literal percents in where_in - #44284
Conversation
Code Review Agent Run #5e6e73Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
CI update for
This PR changes only the macro, its tests, and documentation. I am not adding an unrelated migration repair or repeatedly rerunning deterministically blocked jobs. The local Jinja module remains 202 passed, and all changed-file pre-commit hooks passed. CI unit tests/pre-commit are still running; this is not an all-green claim. |
|
Update 2026-09-15 06:42 UTC: the bounded unit retry passed: 15,431 passed, 6 skipped, 2 xfailed, followed by 1,762 and 437 passing coverage-gate tests. The required unit gate also passed. Head remains The first unit-test CI run finished with 15,430 passed, 6 skipped, 2 xfailed, and one failure: The race-test file and its query execution/DAO code are unchanged. Its complete 13-test module passes locally on both this head and a clean worktree of base Pre-commit CI passed. The integration/browser/dev-image checks remain blocked by the independently verified base migration graph. Review requested from @rusackas; PR remains open and non-draft. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #44284 +/- ##
=======================================
Coverage 80.25% 80.26%
=======================================
Files 2927 2927
Lines 173198 173240 +42
Branches 40161 40170 +9
=======================================
+ Hits 139003 139045 +42
- Misses 31601 31603 +2
+ Partials 2594 2592 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Ownership update: rechecked every current check and all reviews. There are no review threads (resolved or unresolved), and @rusackas remains requested. All 15 red checks were inspected: 12 execution jobs fail on the shared multiple-Alembic-head startup error, plus three dependent required gates. No required check is skipped; the skipped frontend/release/bot jobs are conditionally inapplicable. This remains blocked, not acceptable CI. I have coordinated #44288 / #44317 / #44283 to avoid landing duplicate merge heads, and will rebase onto the chosen upstream repair once it lands, then rerun CI here. Regarding the bot suggestion: the before/after compile assertion intentionally guards against WhereInMacro mutating the shared dialect; deterministic compilation alone does not make that assertion tautological because the macro is called between the two compilations. I have strengthened the test locally with an explicit expected compiler-escaped literal and an explanatory comment. The full Jinja module passes (202 tests), and changed-file pre-commit including mypy/ruff/pylint passes. I am holding the push for the baseline rebase to avoid a predictably blocked duplicate CI run. |
96a18dc to
144a0df
Compare
|
Ownership update for What changed in this push
CI: 46 pass, 12 skipped-as-inapplicable, 15 fail — all 15 from one master defectEvery required gate that can run is green, including The 15 failures are 12 execution jobs plus 3 aggregator gates, and I opened the log of each of the 12 individually. All 12 fail at database initialization, before any test in this PR runs, with the identical error:
This is a master defect, not a defect in this PR:
I am not adding a migration repair to this PR, and I am not re-running deterministically blocked jobs. This is explicitly not an all-green claim. The one human action neededA committer needs to merge a merge-head migration to master. #44288 already does exactly that — it adds Once #44288 (or an equivalent repair) lands, I will rebase this PR onto it and re-run CI here. Review still requested from @rusackas. No approval claimed; PR remains open and non-draft. |
|
@rusackas — Amin has assigned you for review. When you have a moment, could you please take a look? Thank you. |
144a0df to
6329ca0
Compare
Code Review Agent Run #21f093Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
CI is now fully green on
|
| Previously failing | Now |
|---|---|
test-postgres (current), test-mysql, test-sqlite, test-load-examples |
pass |
test-postgres-hive, test-postgres-presto |
pass |
cypress-matrix (chrome) |
pass |
playwright-tests (chromium), playwright-tests (chromium, /app/prefix) |
pass |
playwright-tests-experimental (chromium), playwright-tests-experimental (chromium, /app/prefix) |
pass |
docker-build (dev) |
pass |
test-postgres-required, playwright-tests-required, cypress-matrix-required |
pass |
Also green: unit-tests (current), unit-tests-required, pre-commit (current), lint-check, enforce-single-migration-head, codecov/patch, codecov/project, Analyze (python), Analyze (javascript), docker-build (superset), docker-build (lean), License Check, check-python-deps, dependency-review, python-dependency-liccheck, check-openapi-spec-drift.
I checked for hidden failures rather than trusting the checks summary alone. Enumerating all 24 workflow runs at this SHA gives success=21, skipped=3 — no failed, cancelled, action_required, or zero-job run. The 3 skipped workflows are Superset Showtime, Dependabot patch auto-approve, and the Python dependency-requirements sync, none of which apply to a three-file Python/docs PR. Check-run conclusions across every app are success=63, skipped=10, neutral=2; the two neutral ones are Netlify informational ("No header rules processed", "1898 new files uploaded"). Combined commit status is success. The 12 skipped checks are the frontend path-filtered gates (lint-frontend, validate-frontend, sharded-jest-tests, test-storybook, bundle-size, report-coverage) plus bot/Netlify-informational jobs — this PR touches no frontend files.
No failures were waived and nothing was re-run to mask a result.
Unchanged since the last push
Diff is still exactly three files: superset/jinja_context.py (+5), tests/unit_tests/jinja_context_test.py, docs/docs/using-superset/sql-templating.mdx. HEAD:superset/migrations equals master:superset/migrations (df1419fdb9ae79b3fa1f5973fe05fbea22b4338c) — this PR adds no migration.
Locally on this head: tests/unit_tests/jinja_context_test.py = 202 passed, with test_where_in_athena_parameterless_execution genuinely executing (PyAthena 2.25.0 installed, not skipped). All changed-file pre-commit hooks pass: mypy, ruff, ruff-format, pylint.
The one piece of review feedback — the bito suggestion about the before/after recompile assertion — was addressed in the previous push and carries forward: both compilations are pinned to an explicitly computed compiler-escaped literal derived from the paramstyle, and the assertions are mutation-tested (deleting the fix fails 35 cases; making the macro mutate the shared dialect fails 18).
Remaining gate
mergeStateStatus is BLOCKED solely because reviewDecision is REVIEW_REQUIRED. There is no failing or missing check. The only remaining action is a committer's approving review — @rusackas is requested. I am not merging and not converting this to a draft.
rusackas
left a comment
There was a problem hiding this comment.
Really appreciate the depth here, the SQLAlchemy percent-doubling explanation plus live Athena verification across both PyAthena versions makes this easy to trust. LGTM!
(cherry picked from commit 468936a)
TL;DR
Preserve literal percent signs in the
where_inJinja filter. On Athena, filtering for50%currently sends50%%and misses matching rows. This fixes the Superset literal-rendering boundary without changing driver behavior or rewriting raw SQL.SUMMARY
SQLAlchemy's
format/pyformatcompilers double percent signs for DBAPI interpolation.where_inreturns that compiled fragment as literal SQL, but SQL Lab callscursor.execute(query)without parameters. PyAthena consequently preserves the doubled signs. The same behavior reproduces with PyAthena 2.25.0 and 3.35.4, using SQLAlchemy 2.0.52.Undo one compiler-escaping layer only within the macro's compiled literals, conditional on
identifier_preparer._double_percents. This matches the existingDatabase.compile_sqla_queryconvention. It does not change dialect state, inject empty parameter dictionaries, change dependencies, or unescape an entire rendered query. Quote/backslash handling is retained.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
No UI layout change. SQL/result comparison:
{{ ['50%'] | where_in }}('50%%')('50%'){{ ['%%'] | where_in }}('%%%%')('%%')50%rowTESTING INSTRUCTIONS
pytest tests/unit_tests/jinja_context_test.py— 202 passed locally, with PyAthena installed (no skips).50%.%%,%(value)s, and a combined percent/underscore/apostrophe/backslash value; compare with a raw literal and a bound-parameter control.Regression coverage includes MySQL format/pyformat, PostgreSQL pyformat/named, SQLite qmark, MSSQL named, unchanged dialect compilation, numeric/NULL/empty values, and chart recompilation through
Database.compile_sqla_querywith an unrelated%%literal. A PyAthena formatter test exercises parameterless and bound paths; it is optional when PyAthena is not installed. Generic dialect regressions do not depend on PyAthena.Removing the fix made 33 new regression cases fail before adding the chart-compilation cases. Live AWS verification replayed 12 queries per PyAthena version with locked runtime dependencies (2.25.0 + boto3/botocore 1.39.13; 3.35.4 + boto3/botocore 1.41.2; SQLAlchemy 2.0.52 and tenacity 8.5.0 in both) (four baseline/fixed payload pairs and four bound controls): baseline doubled percents and matched zero rows; fixed preserved values and matched exactly one. The live harness used exact-source AST extraction of the macro and engine-spec execute method, real Jinja, and the real DBAPI; it was not a browser/API acceptance test. This reproduced the initial two-version run. All 96 result objects across the initial run and locked replays were deleted; no persistent tables were created.
Changed-file pre-commit validation includes mypy, ruff and pylint.
ADDITIONAL INFORMATION
ENABLE_TEMPLATE_PROCESSING(existing)Risk is limited to
where_inoutput for percent-escaping dialects; rollback is a revert. SQLAlchemy's separate positional-placeholder rewriting behavior is not changed by this patch.