GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — sqlalchemy-spanner: _designate_type crashes with KeyError on TOKENLIST columns · Issue #16621 · googleapis/google-cloud-python Closed Closed Copy link Labels priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. Descriptionsqlalchemy-spanner version1.17.3 (latest as of 2026-04-12; also reproducible on 1.17.2) google-cloud-spanner version3.63.0 What happened?
Reproduction-- Create a table with a TOKENLIST column (standard Spanner FTS pattern) ALTER TABLE my_table ADD COLUMN search_content STRING(MAX); ALTER TABLE my_table ADD COLUMN search_content_tokens TOKENLIST AS (TOKENIZE_FULLTEXT(search_content)) HIDDEN; CREATE SEARCH INDEX MySearchIndex ON my_table(search_content_tokens) PARTITION BY some_id; from sqlalchemy import create_engine, inspect engine = create_engine("spanner+spanner:///projects/.../instances/.../databases/...") inspector = inspect(engine) # This crashes: cols = inspector.get_columns("my_table") Root cause`_type_map` does not include `TOKENLIST`, and `_designate_type()` has no fallback for unknown types — it does a bare dict lookup that raises `KeyError`. ImpactThis blocks all table introspection (not just the TOKENLIST table) for any database that uses Spanner full-text search, because tools like `sqlacodegen` and `MetaData.reflect()` call `get_multi_columns()` which hits this crash. The entire introspection fails, not just the one column. Two issues
Why not `NullType`?`_type_map_inv` maps `NullType → "INT64"`. If TOKENLIST were mapped to NullType, any roundtrip through Alembic `--autogenerate` would silently produce `INT64` DDL instead of `TOKENLIST`. A proper `TypeEngine` subclass preserves type identity. Why not filter HIDDEN columns?TOKENLIST columns are always `HIDDEN` (excluded from `SELECT *`), but they are readable by name and actively used in full-text search queries (`SEARCH()`, `SCORE()`, `SNIPPET()`, `DEBUG_TOKENLIST()`). Filtering them from introspection would prevent users from referencing them in ORM models. The dialect should reflect them with their proper type and let consumers decide how to handle them. Prior artThe Go client had the same issue and fixed it by adding `TOKENLIST` as a first-class `TypeBase` constant:
Suggested fixTwo complementary changes:
Fix PR: #16622 Activity
MetadataMetadataAssigneesLabelspriority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |