You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by you Zhuang <zh...@gmail.com> on 2021/02/08 08:21:34 UTC

calcite variable $cor0 is not found

String sql = "select id, name, (select id from test.users where id = b.id)
as pid from test.depts b";

sqlToRelConverter.convertQuery(validatedSqlNode, false, true)

i can get the following

[main:DEBUG] org.apache.calcite.sql2rel: Plan after converting SqlNode to
RelNode
LogicalProject(ID=[$0], NAME=[$1], PID=[$SCALAR_QUERY({
LogicalProject(ID=[$0])
  LogicalFilter(condition=[=($0, $cor0.id)])
    LogicalTableScan(table=[[test, users]])
})])
  LogicalTableScan(table=[[test, depts]])


but when i execute code:

sqlNode = new RelToSqlConverter(SPARK).visitRoot(rel)

it throws the exception: variable $cor0 is not found

is it a bug issue?

Re: calcite variable $cor0 is not found

Posted by JiaTao Tao <ta...@gmail.com>.
Hi
You'd better do the subquery elimination.
org.apache.calcite.tools.Programs#subQuery
org.apache.calcite.tools.Programs.DecorrelateProgram


Regards!

Aron Tao


you Zhuang <zh...@gmail.com> 于2021年2月9日周二 上午8:31写道:

> String sql = "select id, name, (select id from test.users where id = b.id)
> as pid from test.depts b";
>
> sqlToRelConverter.convertQuery(validatedSqlNode, false, true)
>
> i can get the following
>
> [main:DEBUG] org.apache.calcite.sql2rel: Plan after converting SqlNode to
> RelNode
> LogicalProject(ID=[$0], NAME=[$1], PID=[$SCALAR_QUERY({
> LogicalProject(ID=[$0])
>   LogicalFilter(condition=[=($0, $cor0.id)])
>     LogicalTableScan(table=[[test, users]])
> })])
>   LogicalTableScan(table=[[test, depts]])
>
>
> but when i execute code:
>
> sqlNode = new RelToSqlConverter(SPARK).visitRoot(rel)
>
> it throws the exception: variable $cor0 is not found
>
> is it a bug issue?
>