Skip to content

Fix SQL UNION column count mismatch in include/revinclude queries#5340

Merged
mikaelweave merged 1 commit intomainfrom
personal/mikaelw/fix-include-revinclude-union-column-mismatch
Jan 23, 2026
Merged

Fix SQL UNION column count mismatch in include/revinclude queries#5340
mikaelweave merged 1 commit intomainfrom
personal/mikaelw/fix-include-revinclude-union-column-mismatch

Conversation

@mikaelweave
Copy link
Contributor

@mikaelweave mikaelweave commented Jan 20, 2026

When using _include and _revinclude together in FHIR search queries, the SQL generator was producing UNION statements with mismatched column counts. Include queries projected 3 columns (T1, Sid1, IsMatch) while other branches projected 4 columns (T1, Sid1, IsMatch, IsPartial).

The fix ensures IsPartial is always projected in HandleTableKindInclude() regardless of IsIncludesOperation flag.

Added E2E regression test to verify the fix.

Related issues

AB#181200

Testing

Describe how this change was tested.

FHIR Team Checklist

  • Update the title of the PR to be succinct and less than 65 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
  • Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
  • Tag the PR with Schema Version backward compatible or Schema Version backward incompatible or Schema Version unchanged if this adds or updates Sql script which is/is not backward compatible with the code.
  • When changing or adding behavior, if your code modifies the system design or changes design assumptions, please create and include an ADR.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Patch|Skip|Feature|Breaking (reason)

When using _include and _revinclude together in FHIR search queries,
the SQL generator was producing UNION statements with mismatched column
counts. Include queries projected 3 columns (T1, Sid1, IsMatch) while
other branches projected 4 columns (T1, Sid1, IsMatch, IsPartial).

The fix ensures IsPartial is always projected in HandleTableKindInclude()
regardless of IsIncludesOperation flag.

Added E2E regression test to verify the fix.
@mikaelweave mikaelweave requested a review from a team as a code owner January 20, 2026 23:45
@mikaelweave
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mikaelweave mikaelweave added Area-SQL Area related to the SQL Server data provider Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs No-PaaS-breaking-change Bug Bug bug bug. No-ADR ADR not needed labels Jan 23, 2026
@mikaelweave mikaelweave added this to the FY26\Q3\2Wk\2Wk15 milestone Jan 23, 2026
@mikaelweave mikaelweave added the Area-AKS Area related to Kubernetes label Jan 23, 2026
@mikaelweave mikaelweave merged commit 9f706a0 into main Jan 23, 2026
61 of 69 checks passed
@mikaelweave mikaelweave deleted the personal/mikaelw/fix-include-revinclude-union-column-mismatch branch January 23, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-AKS Area related to Kubernetes Area-SQL Area related to the SQL Server data provider Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Bug Bug bug bug. No-ADR ADR not needed No-PaaS-breaking-change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants