Skip to content

Refactor getColumns() to use sp_columns_170 with fallback to sp_columns_100#2883

Merged
muskan124947 merged 22 commits intomainfrom
users/muskgupta/fix_dataTypes_sp_columns170
Feb 3, 2026
Merged

Refactor getColumns() to use sp_columns_170 with fallback to sp_columns_100#2883
muskan124947 merged 22 commits intomainfrom
users/muskgupta/fix_dataTypes_sp_columns170

Conversation

@muskan124947
Copy link
Copy Markdown
Contributor

@muskan124947 muskan124947 commented Jan 23, 2026

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

Changes

  • Refactored SQLServerDatabaseMetaData.getColumns into non-Azure and Azure DW helper methods, added shared helpers to parameterize sp_columns calls and apply filters, and updated logging.
  • Modified the vector metadata test to call DatabaseMetaData.getColumns more generically and added diagnostic output around returned column metadata.

Testing

  • Unit/integration tests updated where needed (spatial + vector metadata expectations)
  • Verified metadata returned by DatabaseMetaData.getColumns() includes newer SQL Server 2025 types when sp_columns_170 is available.
  • Backward compatibility maintained via fallback to sp_columns_100 when sp_columns_170 is not available

@muskan124947 muskan124947 self-assigned this Jan 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.getColumns into non-Azure and Azure DW helper methods, added shared helpers to parameterize sp_columns calls and apply filters, and updated logging.
  • Updated microsoft.sql.Types constants 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.getColumns more 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.

Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.23%. Comparing base (dfdadee) to head (a8f53ce).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...soft/sqlserver/jdbc/SQLServerDatabaseMetaData.java 66.66% 45 Missing and 11 partials ⚠️
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.
📢 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/test/java/com/microsoft/sqlserver/jdbc/datatypes/VectorTest.java Outdated
Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java Outdated
Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/main/java/microsoft/sql/Types.java Outdated
@muskan124947 muskan124947 changed the title [WIP] Fix getColumns() to use sp_columns_170 and data types values Refactor getColumns() to use sp_columns_170 and align data types values Jan 27, 2026
@github-project-automation github-project-automation bot moved this to In progress in MSSQL JDBC Jan 27, 2026
@muskan124947 muskan124947 added the Under Review Used for pull requests under review label Jan 27, 2026
@muskan124947 muskan124947 requested a review from Copilot January 27, 2026 09:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@muskan124947 muskan124947 changed the title Refactor getColumns() to use sp_columns_170 and align data types values Refactor getColumns() to use sp_columns_170 with fallback to sp_columns_100 Jan 29, 2026
Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java Outdated
Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed/Merged PRs

Development

Successfully merging this pull request may close these issues.

Columns of the new MSSQL 2025 data type JSON are omitted during table schema discovery JDBC driver metadata does list vector columns

4 participants