[
https://issues.apache.org/jira/browse/FLINK-26361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Shengkai Fang closed FLINK-26361.
---------------------------------
Resolution: Fixed
> "Unexpected correlate variable $cor0" when using hive dialect to write a
> subquery
> ---------------------------------------------------------------------------------
>
> Key: FLINK-26361
> URL: https://issues.apache.org/jira/browse/FLINK-26361
> Project: Flink
> Issue Type: Sub-task
> Reporter: luoyuxia
> Assignee: luoyuxia
> Priority: Major
> Labels: pull-request-available
>
> With hive dialect, can be reproduced using such code:
> {code:java}
> tableEnv.executeSql("CREATE TABLE src (key string, value string)");
> tableEnv.executeSql("create view cv1 as \n"
> + "select * \n"
> + "from src b where exists\n"
> + " (select a.key \n"
> + " from src a \n"
> + " where b.value = a.value )");
> List<Row> results =
> CollectionUtil.iteratorToList(tableEnv.executeSql("select *
> from src where src"
> + ".key in (select key from cv1)").collect());
> {code}
> The plan for such sql is :
> {code:java}
> LogicalSink(table=[*anonymous_collect$1*], fields=[key, value])
> LogicalProject(key=[$0], value=[$1])
> LogicalFilter(condition=[IN($0, {
> LogicalProject(key=[$0])
> LogicalProject(key=[$0], value=[$1])
> LogicalFilter(condition=[EXISTS({
> LogicalProject(key=[$0])
> LogicalFilter(condition=[=($cor0.value, $1)])
> LogicalTableScan(table=[[test-catalog, default, src]])
> })])
> LogicalTableScan(table=[[test-catalog, default, src]])
> })])
> LogicalTableScan(table=[[test-catalog, default, src]])
> {code}
> The node LogicalFilter(condition=[=($cor0.value, $1)]) contains `$cor0`, but
> miss variablesSet. To fix it, we should pass variablesSet when create
> LogicalFilter.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)