linkedin/coral

Hive -> RelNode representation for Lateral Views has LogicalJoin as a RelNode

Opened this issue · 0 comments

For a given Hive SQL with Lateral View, the RelNode representation generated has LogicalCorrelate / LogicalJoin depending on input SQL's syntax.

For Input hive SQL - SELECT col FROM (SELECT ARRAY('a1', 'a2') as a) LATERAL VIEW EXPLODE(a) a_alias AS col
RelNode representation is -

LogicalProject(col=[$1])
  LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
    LogicalProject(a=[ARRAY('a1', 'a2')])
      LogicalValues(tuples=[[{ 0 }]])
    HiveUncollect
      LogicalProject(col=[$cor0.a])
        LogicalValues(tuples=[[{ 0 }]])

For Input SQL - SELECT arr.alias FROM foo LATERAL VIEW EXPLODE(ARRAY('a', 'b')) arr as alias
RelNode representation -

LogicalProject(alias=[$3])
  LogicalJoin(condition=[true], joinType=[inner])
    LogicalTableScan(table=[[hive, default, foo]])
    HiveUncollect
      LogicalProject(col=[ARRAY('a', 'b')])
        LogicalValues(tuples=[[{ 0 }]])

Both translations should result only in LogicalCorrelate in the RelNode representation.