Skip to content

Allow table-valued functions to accept non-scalar parameters #37535

Description

@roji

Our TableValuedExpression currently accepts scalar parameters only (SqlExpression). However, we have some cases where we need to pass non-scalars. For example, SQL Server's VECTOR_DISTANCE() accepts a table expression - including alias:

SELECT TOP (10) s.id,
                s.title,
                r.distance
FROM VECTOR_SEARCH(
         TABLE = dbo.sessions AS s,
         COLUMN = embedding,
         SIMILAR_TO = @qv,
         METRIC = 'cosine',
         TOP_N = 10
     ) AS r
WHERE accepted = 1
ORDER BY r.distance;

Similarly, FREETEXTTABLE():

SELECT FT_TBL.Description  
    ,KEY_TBL.RANK  
FROM Production.ProductDescription AS FT_TBL   
    INNER JOIN FREETEXTTABLE(Production.ProductDescription,  
    Description,   
    'high level of performance',  
    LANGUAGE N'English', 2) AS KEY_TBL  
ON FT_TBL.ProductDescriptionID = KEY_TBL.[KEY]  
ORDER BY RANK DESC;  

Outside of SQL Server usage is probably quite limited; PostgreSQL has json_populate_recordset(), which accepts any record/composite type. Though it's unclear as of yet whether these would be considered scalars or not, If/when we implement support for records/composites.

In any case, there seems to be no harm in relaxing the parameter type; note that any code currently passing SqlExpression continues to work - we've just relaxed the accepted parameter type (this is potentially a provider-facing binary break, but very low-impact).

Activity

  1. self-assigned this
    on Jan 19, 2026
  2. added theissue type on Jan 19, 2026
  3. added this to the 11.0.0 milestone on Jan 19, 2026
  4. added 7 commits that reference this issue on Jan 19, 2026
    960fdf2
    ac808b5
    b5a32c4
    4efae67
    ab8971f
    6364719
    233af64
  5. added 4 commits that reference this issue on Jan 28, 2026
    0bdd842
    be80ffc
    969e531
    701e1b6
  6. added a commit that references this issue on Feb 4, 2026
    d19634d
  7. changed the issue type fromtoon Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions