You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Shengkai Fang (Jira)" <ji...@apache.org> on 2025/07/23 03:56:00 UTC

[jira] [Closed] (CALCITE-7106) Can not generate correlated Polymorphic Table Function

     [ https://issues.apache.org/jira/browse/CALCITE-7106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shengkai Fang closed CALCITE-7106.
----------------------------------
    Resolution: Invalid

> Can not generate correlated Polymorphic Table Function
> ------------------------------------------------------
>
>                 Key: CALCITE-7106
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7106
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.40.0
>            Reporter: Shengkai Fang
>            Priority: Major
>
> Recently, I am using Flink to support a VECTOR_SEARCH function. An similar example is 
>  
> ```
> SELECT * FROM orders, LATERAL TABLE(TOPN( TABLE Shipments, orders.productid))
> ```
>  
> But after sql2rel phase, the output tree is 
> ```
> LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], ORDERID0=[$3], ROWTIME0=[$4], RANK_NUMBER=[$5])
> +- LogicalJoin(condition=[true], joinType=[inner])
>   +- LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
>   +- LogicalTableFunctionScan(invocation=[TOPN($1, $1)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, BIGINT RANK_NUMBER)])
>     +- LogicalProject(ORDERID=[$0], ROWTIME=[$1])
>        +- LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
> ```
>  
> At my first glance, it should use Correlate rather than Join here. After debug, I find the Blackboard#lookupExp tries to use `inputs` to build expression if inputs is not null. However, in this case, inputs are not members of the current scope.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)