Skip to content

Conversation

@cofin
Copy link
Member

@cofin cofin commented Dec 2, 2025

Implements full support for Google Cloud Spanner.

Includes spangres and spanner SQLGlot dialects that should eventually be considered for an upstream PR once stabilized.

cofin and others added 7 commits December 1, 2025 13:59
…ion, driver, and dialect support

- Added Spanner adapter with configuration classes for connection and pool parameters.
- Implemented Spanner SQL dialect extending BigQuery dialect to support INTERLEAVE and TTL features.
- Created Spanner driver for synchronous operations, including session management and exception handling.
- Introduced type conversion for UUID and JSON in SpannerTypeConverter.
- Developed data dictionary for querying Spanner metadata.
- Added integration tests for connection pooling, session management, and CRUD operations.
- Implemented unit tests for configuration validation, driver functionality, and type conversion.
- Updated SpannerDataDictionary to include methods for versioning, feature flags, and optimal type retrieval.
- Refactored Spanner dialect to extend BigQuery with Spanner-specific DDL features, including INTERLEAVE and TTL clauses.
- Enhanced SpannerSyncDriver to manage connection contexts and improve exception handling.
- Introduced SpannerSyncCursor for better session management.
- Updated type conversion logic in SpannerTypeConverter for UUID and JSON handling.
- Modified integration tests to utilize SpannerSyncDriver and SpannerSyncConfig for consistency.
- Added unit tests for Spanner dialect to ensure correct parsing and generation of INTERLEAVE and TTL clauses.
- Improved error handling in driver methods to provide clearer feedback on execution issues.
- Added integration tests for CRUD operations in Spanner, including select, insert, update, and delete functionalities.
- Enhanced unit tests for SpannerSyncConfig to validate connection handling and session management.
- Expanded dialect tests for Spanner to cover various SQL parsing scenarios, including DDL, DML, and advanced queries.
- Introduced unit tests for SpannerSyncStore to ensure transaction usage during set and delete operations.
- Created new tests for Spangres dialect to validate row deletion policies and ensure proper SQL rendering.
- Updated existing tests to reflect changes in TTL and interleave syntax, ensuring compatibility with Spanner's features.
@cofin cofin changed the title fea(driver)t: Google Spanner Driver fea(driver): Google Spanner Driver Dec 2, 2025
@cofin cofin changed the title fea(driver): Google Spanner Driver feat(driver): Google Spanner Driver Dec 2, 2025
cofin added 7 commits December 2, 2025 02:48
- Add sniffio to test dependencies (required by litestar since anyio
  removed it as a direct dependency)
- Rename test_adk_store.py to test_oracle_adk_store.py to avoid pytest
  module name conflict with spanner's test_adk_store.py
- Add Spanner adapter section to API reference (adapters.rst)
- Create custom SQLglot dialect guide (custom-sqlglot-dialects.md)
- Update AGENTS.md with custom dialect pattern and spanner in adapter list
Documentation updates:
- Add Spanner to drivers_and_querying.rst (overview, driver section, selection guide)
- Add Spanner to parameter-profile-registry.md
- Add SpannerADKStore to ADK extension guide with example
- Add SpannerSyncStore to Litestar extension guide
- Update guides README with all adapters including Spanner

Skills:
- Create comprehensive Spanner adapter skill
- Update adapter skills README with Spanner entry
- Update main skills README with Spanner
FixedSizePool and other Spanner session pools do not accept a database
argument in their constructor. The pool is created standalone and then
passed to the Database constructor via the pool= parameter.
- Extension test fixtures (ADK, Litestar) now depend on spanner_database
  fixture to ensure instance/database are created before use
- Fix _infer_param_types and _coerce_params to handle tuple parameters
  (cached statements can return tuple parameters)
- Fix test_crud_operations to use select_one_or_none for deleted row check
ADK Store:
- Fix BYTES column to use BYTES(MAX) (required by Spanner DDL)
- Check existing tables before DDL to avoid duplicates

Litestar Store:
- Replace select_one with select_one_or_none for nullable queries
- Check existing tables before DDL to avoid duplicates
- Remove unused api_exceptions import
- Implemented binary data encoding pattern for Spanner, including functions for converting Python bytes to base64-encoded format and vice versa.
- Updated Spanner adapter documentation to reflect new BYTES handling.
- Enhanced SpannerSyncConfig to provide batch context instead of transaction for write operations.
- Refactored SpannerSyncStore to utilize new encoding functions for session data.
- Added integration tests to verify correct handling of bytes with Spanner.
- Updated unit tests to ensure proper transaction handling and session management.
@cofin cofin merged commit 1c6a2ad into main Dec 2, 2025
15 checks passed
@cofin cofin deleted the feat/spanner-support branch December 2, 2025 22:54
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.

2 participants