feat(spanner/spansql): Add support for tokenlist and create search index - #11522
Conversation
|
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. |
|
Thanks for the review, I have now fixed your comments. |
|
Awesome thanks! I did not do an exhaustive review, these were just things I ran into when I pulled your branch and was running some local tests, but the changes all seem to work for me, so fingers crossed :) |
|
@rasviitanen it's not working if we combine it with other function. Example would be: It's working just fine in spanner studio. But in Go code:
|
|
@karunacybozu Thanks for your comments! I would suggest to submit a PR of your own to add additional string functions such as One could argue that the error message from the parser is a bit cryptic though, maybe we could improve it in a follow-up. |
|
@rahul2393 It would be greatly appreciated if this could be reviewed, not sure who to ping 🙏 |
|
@rahul2393 looks like my branch was outdated, had to merge main again. Could you readd |
Followup from googleapis#11522
… introspection Spanner full-text search uses TOKENLIST columns, but _type_map does not include this type and _designate_type() crashes with KeyError on any unrecognized type string. This change: 1. Adds TOKENLIST to _type_map, mapped to NullType (it is an infrastructure-only type not read/written by applications). 2. Adds a fallback in _designate_type() so unrecognized types return NullType with a warning instead of crashing. This future-proofs against new Spanner types. The Go client had the same issue and fixed it in googleapis/google-cloud-go#11522 (released in spanner v1.78.0). Fixes googleapis#16621
… in introspection Spanner full-text search uses TOKENLIST columns (always HIDDEN and generated), but the dialect does not recognize this type — _type_map has no entry and _designate_type() crashes with KeyError on any unrecognized type string. This change: 1. Adds a first-class TOKENLIST type (TypeEngine subclass) with forward mapping (_type_map), inverse mapping (_type_map_inv), and DDL compilation (SpannerTypeCompiler.visit_TOKENLIST). This ensures schema introspection can roundtrip correctly through Alembic and other DDL tools. 2. Adds a fallback in _designate_type() so unrecognized types return NullType with a warning instead of crashing. This future-proofs against new Spanner types. 3. Filters HIDDEN columns in get_multi_columns() by checking INFORMATION_SCHEMA.COLUMNS.IS_HIDDEN. HIDDEN columns are excluded from SELECT *, cannot be written to, and are infrastructure-only (e.g. TOKENLIST columns backing search indexes). They should not appear in reflected models. The Go client had the same gap and fixed it in googleapis/google-cloud-go#11522 (released in spanner v1.78.0), which added TOKENLIST as a first-class TypeBase and HIDDEN as a property of ColumnDef. Fixes googleapis#16621
… in introspection Spanner full-text search uses TOKENLIST columns, but the dialect does not recognize this type — _type_map has no entry and _designate_type() crashes with KeyError on any unrecognized type string. This change: 1. Adds a first-class TOKENLIST type (TypeEngine subclass) with forward mapping (_type_map), inverse mapping (_type_map_inv), and DDL compilation (SpannerTypeCompiler.visit_TOKENLIST). This ensures schema introspection roundtrips correctly through Alembic and other DDL tools, and allows TOKENLIST columns to be referenced in SEARCH()/SCORE()/SNIPPET() queries via SQLAlchemy. 2. Adds a fallback in _designate_type() so unrecognized types return NullType with a warning instead of crashing. This future-proofs against new Spanner types. The Go client had the same gap and fixed it in googleapis/google-cloud-go#11522 (released in spanner v1.78.0), which added TOKENLIST as a first-class TypeBase. Fixes googleapis#16621
… in introspection Spanner full-text search uses TOKENLIST columns, but the dialect does not recognize this type — _type_map has no entry and _designate_type() crashes with KeyError on any unrecognized type string. This change: 1. Adds a first-class TOKENLIST type (TypeEngine subclass) with forward mapping (_type_map), inverse mapping (_type_map_inv), and DDL compilation (SpannerTypeCompiler.visit_TOKENLIST). This ensures schema introspection roundtrips correctly through Alembic and other DDL tools, and allows TOKENLIST columns to be referenced in SEARCH()/SCORE()/SNIPPET() queries via SQLAlchemy. 2. Adds a fallback in _designate_type() so unrecognized types return NullType with a warning instead of crashing. This future-proofs against new Spanner types. The Go client had the same gap and fixed it in googleapis/google-cloud-go#11522 (released in spanner v1.78.0), which added TOKENLIST as a first-class TypeBase. Fixes googleapis#16621
Adds support for parsing
tokenlistandcreate search indexin spanner/spansql.Fixes #11466