Hi, Tao. Thank you for your report. It would be great if you can file an JIRA and provide a test case that can reproduce the error.
Best, Chunwei On Tue, Dec 8, 2020 at 2:33 PM tonytao <tonytao0...@outlook.com> wrote: > Hi folks, > > I found a RelToSqlConverter bug existed in 1.24-1.26. > > I has a logical plan as below: > > LogicalProject(id=[$0], CAST=[CAST($1):DATE]) > LogicalFilter(condition=[AND(<($1, 2011-12-01 00:00:00), >($0, > 100))]) > JdbcTableScan(table=[[public, testdata]]) > > when concert it to sql , > > RelToSqlConverter converter = new > RelToSqlConverter(PostgresqlSqlDialect.DEFAULT); > SqlSelect select = converter.visit(project1).asSelect(); > > it throw exception: > > Exception in thread "main" java.lang.NullPointerException > at java.base/java.util.Objects.requireNonNull(Objects.java:221) > at > > org.apache.calcite.rel.rel2sql.RelToSqlConverter.result(RelToSqlConverter.java:152) > at > > org.apache.calcite.rel.rel2sql.SqlImplementor.result(SqlImplementor.java:483) > at > > org.apache.calcite.rel.rel2sql.SqlImplementor$Builder.result(SqlImplementor.java:1970) > at > > org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:351) > at com.glodon.newcalcite.App.main(App.java:111) > > Here is this the bug explain: > > In RelToSqlConverter,the stack generate 2 frames : > > * JdbcTableScan(parent was LogicalFilter) > * LogicalFilter(parent was LogicalProject) > > On "visit(TableScan e)" the stack would peek and generate a result;on > "visit(Filter e)" ,it would peek another frame and generate the result > too.So on "visit(Project e)",the stack is empty,this cause the exception > happened. > > I'm not sure when "visitInput" in LogicalProject ,it should push > LogicalProject(parent is NULL) instead of LogicalFilter(parent was > LogicalProject).? > > This error not existed in 1.23. > > Best regards! > > Tao Jin > > >