Refactor getColumns() to use sp_columns_170 with fallback to sp_columns_100#2883
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors DatabaseMetaData.getColumns to support newer SQL Server metadata stored procedures and updates Microsoft-specific SQL type codes and tests (including spatial and vector types) to align with the new values.
Changes:
- Refactored
SQLServerDatabaseMetaData.getColumnsinto non-Azure and Azure DW helper methods, added shared helpers to parameterizesp_columnscalls and apply filters, and updated logging. - Updated
microsoft.sql.Typesconstants for several SQL Server–specific types (DATETIME, SMALLDATETIME, GUID, SQL_VARIANT, GEOMETRY, GEOGRAPHY, VECTOR, JSON) and adjusted spatial metadata tests to expect the new codes. - Modified the vector metadata test to call
DatabaseMetaData.getColumnsmore generically and added diagnostic output around returned column metadata.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java | Refactors getColumns into separate non-Azure/Azure DW paths, introduces helpers for building and filtering the result sets, and intends to support sp_columns_170 with fallback to sp_columns_100. |
| src/main/java/microsoft/sql/Types.java | Adjusts Microsoft-specific SQL type code constants for datetime, GUID, SQL_VARIANT, spatial, vector, and JSON types. |
| src/test/java/com/microsoft/sqlserver/jdbc/datatypes/SQLServerSpatialDatatypeTest.java | Updates geometry/geography metadata tests to assert the new vendor type codes from ParameterMetaData and ResultSetMetaData. |
| src/test/java/com/microsoft/sqlserver/jdbc/datatypes/VectorTest.java | Changes the getColumns call to use a wildcard column pattern and logs all returned metadata for debugging of the VECTOR type mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2883 +/- ##
============================================
+ Coverage 58.87% 59.23% +0.36%
- Complexity 4778 4807 +29
============================================
Files 151 151
Lines 34748 34781 +33
Branches 5827 5829 +2
============================================
+ Hits 20457 20603 +146
+ Misses 11502 11390 -112
+ Partials 2789 2788 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…o run on sql server instance only
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Desciption
With SQL Server 2025, new data types and features such as VECTOR and enhanced JSON support have been introduced.
The legacy metadata stored procedure sp_columns_100 does not return correct or complete data type information for these newer features.
SQL Server 2025 exposes updated metadata via sp_columns_170, which aligns column metadata with newer engine capabilities.
This change updates DatabaseMetaData.getColumns() to prefer sp_columns_170 when available, while safely falling back to sp_columns_100 for backward compatibility.
The implementation is defensive and forward-compatible, ensuring no regressions on older SQL Server versions or Azure environments while allowing JDBC to automatically benefit from future metadata improvements.
Issues
JDBC driver metadata does list vector columns #2862
Columns of the new MSSQL 2025 data type JSON are omitted during table schema discovery #2878
Changes
Testing
DatabaseMetaData.getColumns()includes newer SQL Server 2025 types whensp_columns_170is available.sp_columns_100whensp_columns_170is not available