You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Stamatis Zampetakis (Jira)" <ji...@apache.org> on 2020/12/08 18:41:00 UTC
[jira] [Comment Edited] (CALCITE-4430) RelToSqlConverter stack
error
[ https://issues.apache.org/jira/browse/CALCITE-4430?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17246056#comment-17246056 ]
Stamatis Zampetakis edited comment on CALCITE-4430 at 12/8/20, 6:40 PM:
------------------------------------------------------------------------
Hey [~tonytao0505] did you try with the current master? You can easily check by adding a test case in
[RelToSqlConverterTest|https://github.com/apache/calcite/blob/master/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java].
was (Author: zabetak):
Hey [~tonytao0505] did you try with the current master?
> RelToSqlConverter stack error
> -----------------------------
>
> Key: CALCITE-4430
> URL: https://issues.apache.org/jira/browse/CALCITE-4430
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.24.0, 1.25.0, 1.26.0
> Environment: jdk
> {code}
> openjdk version "11.0.9.1" 2020-11-04
> OpenJDK Runtime Environment (build 11.0.9.1+1-post-Debian-1deb10u2)
> OpenJDK 64-Bit Server VM (build 11.0.9.1+1-post-Debian-1deb10u2, mixed mode, sharing)
> {code}
> maven pom
> {code:xml}
> <dependency>
> <groupId>org.apache.calcite</groupId>
> <artifactId>calcite-core</artifactId>
> <version>1.26.0</version>
> </dependency>
> <dependency>
> <groupId>com.google.guava</groupId>
> <artifactId>guava</artifactId>
> <version>23.0</version>
> </dependency>
> <dependency>
> <groupId>org.apache.commons</groupId>
> <artifactId>commons-dbcp2</artifactId>
> <version>2.7.0</version>
> </dependency>
> <dependency>
> <groupId>org.postgresql</groupId>
> <artifactId>postgresql</artifactId>
> <version>42.2.18</version>
> </dependency>
> {code}
> Reporter: TaoJIn
> Priority: Major
>
> quer:
> {code:sql}
> SELECT id, CAST(uptime AS DATE)
> FROM public.testdata
> WHERE uptime < '2011-12-01 00:00:00.000' AND id > 100
> {code}
> The logical plan as below:
> {code:java}
> LogicalProject(id=[$0], CAST=[CAST($1):DATE])
> LogicalFilter(condition=[AND(<($1, 2011-12-01 00:00:00), >($0, 100))])
> JdbcTableScan(table=[[public, testdata]])
> {code}
> Convert it to sql ,
> {code:java}
> RelToSqlConverter converter = new RelToSqlConverter(PostgresqlSqlDialect.DEFAULT);
> SqlSelect select = converter.visit(project1).asSelect();
> {code}
> it throw exception:
> {code:java}
> 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)
> {code}
> Here is this the bug explain:
> In class *RelToSqlConverter*,the stack generate 2 frames :
> * JdbcTableScan(parent was LogicalFilter)
> * LogicalFilter(parent was LogicalProject)
> On function "*public Result visit(TableScan e)*" the stack would peek and generate a result;on function "*public Result visit(Filter e)*" ,it would peek another frame and generate the result too.So on "*public Result 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 message was sent by Atlassian Jira
(v8.3.4#803005)