Skip to content

fix(spanner): implement common schema collections - #16056

Open
alaricd wants to merge 16 commits into
googleapis:mainfrom
alaricd:codex/spanner-schema-collections
Open

alaricd wants to merge 16 commits into
googleapis:mainfrom
alaricd:codex/spanner-schema-collections

Conversation

@alaricd

@alaricd alaricd commented Oct 29, 2026 •

Copy link
Copy Markdown

Summary

Implement the common ADO.NET DbConnection.GetSchema collections and populate schema metadata for both Spanner SQL dialects.

  • Detect the connected database dialect from INFORMATION_SCHEMA.SCHEMATA.CATALOG_NAME.
  • Build DataTypes from dialect-supported types and merge in INFORMATION_SCHEMA.COLUMNS.SPANNER_TYPE, so types visible in the database—including types added by newer server versions—are discovered dynamically.
  • Report known CLR mappings from the provider, and leave ADO.NET properties as DBNull when Spanner does not provide enough information to make an accurate claim.
  • Correct common collection handling, restrictions, identifier patterns, and reserved word rows.

Resolves #16055.

Upstream baseline and reproduction

Updated against googleapis/google-cloud-dotnet main at 1fa1c85336968d0bc822ee83117c31279c2c9791 (2026-10-29). The upstream baseline has no SpannerConnection.GetSchema override, so calls use DbConnection's unsupported default. The PR regression tests exercise the missing common collections and the newly populated schema metadata.

Root cause and patch

SpannerConnection did not implement the common schema collection contract. The previous PR version also lacked live database discovery, provided incomplete type aliases/arrays, and did not accurately distinguish known metadata from unknown fields. The patch adds database dialect/type discovery, complete type collection columns, documented baseline type aliases, observed type merging, dialect-specific identifiers, and DBNull for metadata that cannot be asserted accurately.

Spanner does not currently expose a SQL catalog of parser keywords or a server product version query. Reserved words therefore use the published language references, selected by the live database dialect. Product version fields remain DBNull; the provider's ServerVersion value 0.0 is a placeholder. Type families and their ADO.NET provider mappings have a documented baseline, while observed names are sourced from the connected database's information schema.

Contract and references

This implements the common ADO.NET schema collections and preserves DBNull for unknown metadata values as permitted by the provider contract. References:

The provider project retains its existing target frameworks (netstandard2.1;net462); tests run on the repository's .NET 8 target. No target framework or public API change is introduced.

Tests and validation

  • Focused schema tests: dotnet test ... --no-restore -f net8.0 --filter FullyQualifiedName~GetSchema — 16 passed, 0 failed.
  • Provider build: dotnet build ... --no-restore -f netstandard2.1 — passed, 0 warnings, 0 errors.
  • Regression assertions cover common collections, dialect metadata, standard and observed types, arrays, unknown custom type fields, and keyword list formatting.
  • Live Spanner integration tests for both SQL dialects were not run because no Spanner emulator or test database is configured in this environment. The query against INFORMATION_SCHEMA is therefore not integration-verified here.
  • The local SDK is .NET 11 preview; focused tests target net8.0 and passed. The repository's pinned .NET SDK 8.0.426 is not installed.

Discovery

Found through pengdows.AdoNetApiTest.conformance.

Remaining limitations

Spanner does not expose SQL catalogs for its parser keyword set or a reliable server product version in the inspected references. Those fields cannot be made database-dynamic with the documented SQL interfaces; keyword data follows the published dialect references and version fields remain unknown. Live dialect integration validation remains outstanding.

@alaricd
alaricd requested a review from a team as a code owner October 29, 2026 07:16
@google-cla

google-cla Bot commented Oct 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements the GetSchema method in SpannerConnection to expose common ADO.NET metadata collections such as MetaDataCollections, DataSourceInformation, DataTypes, Restrictions, and ReservedWords, along with corresponding unit tests. The review feedback correctly points out that, according to the ADO.NET specification, the collectionName parameter must be case-insensitive. Additionally, since none of the supported collections allow restrictions, the implementation should throw an ArgumentException if any restrictionValues are provided. The unit tests should also be expanded to verify this case-insensitivity and the exception behavior, including asserting on the exception message.

Comment thread apis/Google.Cloud.Spanner.Data/Google.Cloud.Spanner.Data/SpannerConnection.cs Outdated
@alaricd
alaricd force-pushed the codex/spanner-schema-collections branch from e55bb9c to f697ee7 Compare October 29, 2026 07:26
@alaricd alaricd changed the title Implement common DbConnection schema collections fix(spanner): implement common schema collections Oct 29, 2026
@alaricd
alaricd force-pushed the codex/spanner-schema-collections branch from f697ee7 to 6bff0f4 Compare October 29, 2026 07:34
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Oct 29, 2026
@alaricd
alaricd marked this pull request as draft October 29, 2026 13:35
@alaricd
alaricd marked this pull request as ready for review October 29, 2026 15:01
@amanda-tarafa
amanda-tarafa self-requested a review October 29, 2026 16:25
@amanda-tarafa
amanda-tarafa marked this pull request as draft October 29, 2026 16:25
@amanda-tarafa amanda-tarafa self-assigned this Oct 29, 2026
@alaricd
alaricd marked this pull request as ready for review October 29, 2026 18:37

This branch has not been deployed

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

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement the standard DbConnection schema collections

2 participants