Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-26360 [Umbrella] Improvement for Hive Query Syntax Compatibility
  3. FLINK-26361

"Unexpected correlate variable $cor0" when using hive dialect to write a subquery

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      With hive dialect, can be reproduced using such code:

      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());
      

      The plan for such sql is :

      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]])
      

      The node LogicalFilter(condition=[=($cor0.value, $1)]) contains `$cor0`, but miss variablesSet. To fix it, we should pass variablesSet when create LogicalFilter.

      Attachments

        Issue Links

          Activity

            People

              luoyuxia luoyuxia
              luoyuxia luoyuxia
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: