You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ruben Q L (Jira)" <ji...@apache.org> on 2022/12/12 09:46:00 UTC
[jira] [Resolved] (CALCITE-5395) RelToSql converter fails when SELECT * is under a semi-join node
[ https://issues.apache.org/jira/browse/CALCITE-5395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ruben Q L resolved CALCITE-5395.
--------------------------------
Resolution: Fixed
Fixed via https://github.com/apache/calcite/commit/0466bd577766e61703417a5c394ba01297fc0256
Thanks [~lchistov1987] for creating the ticket and [~jiajunbernoulli] for the patch!
> RelToSql converter fails when SELECT * is under a semi-join node
> ----------------------------------------------------------------
>
> Key: CALCITE-5395
> URL: https://issues.apache.org/jira/browse/CALCITE-5395
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.32.0
> Reporter: Leonid Chistov
> Assignee: Jiajun Xie
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.33.0
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> The following test case would fail if added to RelToSqlConverterTest.java:
> {code:java}
> @Test void testUnionUnderSemiJoinNode() {
> final RelBuilder builder = relBuilder();
> final RelNode base = builder
> .scan("EMP")
> .scan("EMP")
> .union(true)
> .build();
> final RelNode root = builder
> .push(base)
> .scan("DEPT")
> .join(
> JoinRelType.SEMI, builder.equals(
> builder.field(2, 1, "DEPTNO"),
> builder.field(2, 0, "DEPTNO")))
> .project(builder.field("DEPTNO"))
> .build();
> toSql(root);
> } {code}
> The exception is:
> {code:java}
> Index 7 out of bounds for length 1
> java.lang.IndexOutOfBoundsException: Index 7 out of bounds for length 1
> at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
> at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
> at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
> at java.base/java.util.Objects.checkIndex(Objects.java:359)
> at java.base/java.util.ArrayList.get(ArrayList.java:427)
> at org.apache.calcite.sql.SqlNodeList.get(SqlNodeList.java:160)
> at org.apache.calcite.rel.rel2sql.RelToSqlConverter$AliasReplacementShuttle.visit(RelToSqlConverter.java:197)
> at org.apache.calcite.rel.rel2sql.RelToSqlConverter$AliasReplacementShuttle.visit(RelToSqlConverter.java:179)
> at org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:324)
> at org.apache.calcite.sql.util.SqlShuttle$CallCopyingArgHandler.visitChild(SqlShuttle.java:134)
> at org.apache.calcite.sql.util.SqlShuttle$CallCopyingArgHandler.visitChild(SqlShuttle.java:101)
> at org.apache.calcite.sql.SqlOperator.acceptCall(SqlOperator.java:954)
> at org.apache.calcite.sql.util.SqlShuttle.visit(SqlShuttle.java:68)
> at org.apache.calcite.sql.util.SqlShuttle.visit(SqlShuttle.java:41)
> at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:161)
> at org.apache.calcite.rel.rel2sql.RelToSqlConverter.visitAntiOrSemiJoin(RelToSqlConverter.java:261) {code}
> What happens is that `AliasReplacementShuttle` expects a select list as a source of replacement, but cannot handle a case when select node has a `select *` form.
> In case of current test, `union` is transformed to `select *` form before semi-join handling occurs.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)