Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
Description
We have several examples of TVFs which return some arbitrary, fixed "table", usually adding some column(s) to an actual table:
- The experimental SQL Server VECTOR_SEARCH() function accepts a table name as a parameter, and returns that table, augmented with a
distancecolumn containing the similarity distance. - The full-text search functions CONTAINSTABLE() and FREETEXTTABLE() seems to work in a similar way (confirm).
- There are apparently similar mechanisms in other databases (e.g. MongoDB, /cc @ajcvickers).
Right now, we aren't set up to properly support these. Blockers include:
- Navigation expansion throws for any unknown top-level (queryable) operator. This was likely done to avoid letting unknown operators through but without actually processing their lambda arguments; but specifically the functions above have no lambda arguments, so don't really need nav expansion processing. A possibly better way to handle this would be to open nav expansion up to provider extension, so that these provider-specific operators can be handled.
- We don't currently have a way to have a structural type that represents the wrapper returned by e.g. VECTOR_SEARCH(), and which would contain the actual user entity (representing the real table in the database).
- An actual structural type (RelationalStructuralTypeShaperExpression) is needed so that e.g. the user can bind to its properties in query (and also possibly even project it out of the database).
- This wrapper type would likely be outside of the model, at which point we have the interesting situation of a type outside the model somehow referencing a type inside the model (see e.g. liftable constant note below).
- We're also lacking the concept of an "association" that would represent the referencing of the user's entity type from this wrapper type. It isn't a navigation since there's no foreign key, and it's not a complex property since it points to an entity type. If feels like we might be missing an association type that just models simple containment - not unlike complex properties but that can point at an entity type.
- In the shaper, we have the "liftable constant" mechanism as a way to support precompiled queries; any structural type that's closed over in the shaper must be resolvable from the model. But if the structural type for the wrapper returned by the TVF isn't the model, that fails.
Activity
roji commentedon Jan 19, 2026
I was thinking about this all wrong - we already support this quite well in the query pipeline; specifically, we allow queries such as the following:
Wrapper here is an un-modeled structural type that's "instantiated" within the query and then projected out of the database.