Skip to content

Conversation

@Ananya2
Copy link
Contributor

@Ananya2 Ananya2 commented Nov 12, 2025

Problem

DatabaseMetaData.getIndexInfo() fails on Azure Synapse serverless SQL pool with error:
PROCEDURE 'sp_statistics' is not supported in the current database

This occurs because Synapse serverless SQL pool does not support the sp_statistics stored procedure that the JDBC driver relies on for index metadata retrieval.

Solution

Implemented a robust try-catch fallback mechanism in getIndexInfoAzureDW() method:

Changes Made:

  1. Added try-catch wrapper around sp_statistics execution in Azure DW path
  2. Fallback to sys.indexes query when sp_statistics fails using existing INDEX_INFO_QUERY_DW constant
  3. Removed unique filtering to ensure consistent behavior across all execution paths
  4. Proper error logging for debugging sp_statistics failures

Technical Details:

  • Fallback Query: Uses sys.indexes, sys.index_columns, sys.columns, and sys.tables system views
  • NON_UNIQUE Mapping: Correctly maps i.is_unique = 1 to NON_UNIQUE = 0 (JDBC standard)
  • Error Handling: Graceful fallback with appropriate logging for troubleshooting
  • Consistency: Both main execution path and fallback path return all indexes without unique filtering

Testing:

  • Works on regular Azure SQL Database (sp_statistics available)
  • Works on Azure Synapse serverless SQL pool (fallback to sys.indexes)
  • Maintains backward compatibility with existing applications
  • Returns consistent index metadata format across all platforms

@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.31%. Comparing base (f58f35a) to head (5b65603).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...soft/sqlserver/jdbc/SQLServerDatabaseMetaData.java 0.00% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2839      +/-   ##
============================================
- Coverage     56.35%   56.31%   -0.04%     
  Complexity     4519     4519              
============================================
  Files           151      151              
  Lines         34435    34442       +7     
  Branches       5736     5738       +2     
============================================
- Hits          19405    19396       -9     
- Misses        12404    12417      +13     
- Partials       2626     2629       +3     

☔ View full report in Codecov by Sentry.
📢 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.

@machavan machavan added this to the 13.3.0 milestone Nov 12, 2025
@Ananya2 Ananya2 merged commit ab791e8 into main Nov 13, 2025
17 of 19 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.

Invoking DatabaseMetadata.getIndexInfo() reports "PROCEDURE 'sp_statistics' is not supported"

5 participants