Exclude Chained Scenarios DOB Query Optimization#5622
Closed
mikaelweave wants to merge 8 commits into
Closed
Conversation
## What\n- Skip ScalarTemporalEqualityRewriter day-split union rewrite when the root expression contains any chain expression (forward or reverse).\n- Add regression unit tests covering both reverse-chain and forward-chain root query shapes to ensure birthdate equality stays pass-through.\n- Add an E2E forward-chain ImagingStudy started + patient birthdate + tag POST search test that mirrors the reverse-chain scenario.\n\n## Why\nUnion-expanded CTEs can shift predecessor selection in SqlQueryGenerator for complex chain queries. Skipping the scalar union rewrite for chain-containing roots preserves expected CTE ordering and prevents joins from binding to the wrong CTE branch.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Improved comments in SqlQueryGenerator and ScalarTemporalEqualityRewriter to clarify UNION ALL expansion, SMART scope unions, and DOB day-split handling, documenting current limitations and guardrails. - Refactored chaining search E2E test to use unique tenant tags and dynamic patient creation; removed redundant forward chain test. - Cleaned up Fixture class by removing static tenant tag and patient fields now handled within tests.
Add SQL-only E2E tests for partial birthdate OR/ne/total/sort and leap-day cases in DateSearchTests, plus chained birthdate month/day scenarios in ChainingSearchTests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…o local variable' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…o use Where' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Disable ScalarTemporalEqualityRewriter per-query when sort parameters are present to avoid sort/union query-shape failures, and add unit coverage for the gating behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| } | ||
|
|
||
| [Fact] | ||
| public void GivenRootExpressionContainsReverseChainAndAllowListedBirthdateExactDay_WhenRewritten_ThenPassThroughBirthdate() |
Contributor
There was a problem hiding this comment.
Can these two be a theory?
| return false; | ||
| } | ||
|
|
||
| return sortParameters == null || sortParameters.Count == 0; |
Contributor
There was a problem hiding this comment.
This will never be true, we apply type and lastupdated as default sort parameters.
Contributor
Author
There was a problem hiding this comment.
Well that explains why the test is passing...great comment thanks.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5622 +/- ##
==========================================
- Coverage 76.90% 76.89% -0.02%
==========================================
Files 997 997
Lines 36616 36631 +15
Branches 5529 5537 +8
==========================================
+ Hits 28160 28166 +6
- Misses 7104 7115 +11
+ Partials 1352 1350 -2 🚀 New features to boost your workflow:
|
auto-merge was automatically disabled
June 18, 2026 17:37
Pull request was closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a skip for the DOB rewriter for more chained / reverse chained queries.
Adds a skip for sort parameters as well,
Adds more tests for this rewriter.
Testing
local testing
e2e
unit
AB#195112