Skip to content

Conversation

@Ananya2
Copy link
Contributor

@Ananya2 Ananya2 commented Sep 15, 2025

Overview
This PR backports the fix from #2773 into the release/13.2 branch.

Problem

DatabaseMetaData.getIndexInfo() was returning incorrect NON_UNIQUE values due to inconsistent handling between sp_statistics and sys.indexes result sets.

  • sp_statistics: NON_UNIQUE with 1 = not unique, 0 = unique
  • sys.indexes: is_unique with 1 = unique, 0 = not unique

The method was merging results from both sources without properly converting the sys.indexes.is_unique values to the expected JDBC NON_UNIQUE format, causing the same index to appear as both unique and non-unique.

Solution

  • Added proper conversion logic: CASE WHEN i.is_unique = 1 THEN 0 ELSE 1 END AS NON_UNIQUE
  • Applied consistent NON_UNIQUE value mapping across all index queries
  • Ensured compatibility with both regular SQL Server and Azure Synapse Analytics

Testing

  • Verified correct NON_UNIQUE values for unique and non-unique indexes

Closes #2771

@Ananya2 Ananya2 self-assigned this Sep 15, 2025
@Ananya2 Ananya2 changed the title Backport: Fix NON_UNIQUE value inconsistency in DatabaseMetaData.getIndexInfo()… Backport: Fix NON_UNIQUE value inconsistency in DatabaseMetaData.getIndexInfo() Sep 15, 2025
@Ananya2 Ananya2 merged commit 35e0958 into release/13.2 Sep 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants