YunJie created FLINK-41782:
------------------------------

             Summary: Aliasing LATERAL TABLE(VECTOR_SEARCH(...)) fails with 
CannotPlanException in batch mode
                 Key: FLINK-41782
                 URL: https://issues.apache.org/jira/browse/FLINK-41782
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
    Affects Versions: 2.2.1
            Reporter: YunJie


On Flink 2.2.1 in synchronous batch mode, adding a table alias to a correlated 
VECTOR_SEARCH call makes the query fail during planning. This reproduces with 
Flink's values test connector.

h3. Steps to reproduce
Use the batch VectorSearchITCase on release-2.2.1. In the inherited 
VectorSearchITCaseBase.testSimple() test, keep the existing src and vector 
tables and append only AS hit to the original SQL:

{code:sql}
SELECT *
FROM src,
LATERAL TABLE(
  VECTOR_SEARCH(TABLE vector, DESCRIPTOR(`vector`), src.vector, 2)
) AS hit;
{code}

h3. Expected
The query with the table alias plans successfully and returns the same six rows 
and scores as the original query.

h3. Actual
The original query returns six rows. The aliased query produces a 
FlinkLogicalJoin above a FlinkLogicalTableFunctionScan and fails during 
planning:

{code}
org.apache.calcite.plan.RelOptPlanner$CannotPlanException
There are not enough rules to produce a node with desired properties:
convention=BATCH_PHYSICAL, FlinkRelDistributionTraitDef=any, sort=[].
Missing conversion is FlinkLogicalTableFunctionScan[convention: LOGICAL -> 
BATCH_PHYSICAL]
{code}

h3. References
* [Upstream test 
method|https://github.com/apache/flink/blob/release-2.2.1/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/utils/VectorSearchITCaseBase.java#L67-L76]
* [Batch test 
configuration|https://github.com/apache/flink/blob/release-2.2.1/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/batch/sql/VectorSearchITCase.java#L27-L40]
* [Reproduction in the Hudi 
discussion|https://github.com/apache/hudi/issues/20966#issuecomment-7280736384]



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to