[ https://issues.apache.org/jira/browse/CALCITE-5805?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17738270#comment-17738270 ]
Julian Hyde edited comment on CALCITE-5805 at 6/28/23 7:47 PM: --------------------------------------------------------------- This is a duplicate of CALCITE-985. We never completed implementation of MERGE. I haven't checked the PR, but it should complete implementation of MERGE and add tets accordingly. Also it should enable {{SqlToRelConverterTest.testMerge()}}. was (Author: julianhyde): This is a duplicate of CALCITE-985. We never completed implementation of MERGE. I haven't checked the PR, but it should complete implementation of MERGE and add tets accordingly. Also it should enable {{SqlToRelConverterTest.testMerge()}. > SqlValidatorImpl throws AssertionError while validating MERGE statement > ----------------------------------------------------------------------- > > Key: CALCITE-5805 > URL: https://issues.apache.org/jira/browse/CALCITE-5805 > Project: Calcite > Issue Type: Bug > Components: core > Reporter: Jiajun Xie > Assignee: Jiajun Xie > Priority: Major > Labels: pull-request-available > Fix For: 1.35.0 > > > For the unit test. > {code:java} > final String sql = "merge into empnullables e " > + "using (select * from emp where deptno is null) t " > + "on e.empno = t.empno " > + "when matched then update " > + "set ename = t.ename, deptno = t.deptno, sal = t.sal * .1 " > + "when not matched then insert (empno, ename, deptno, sal) " > + "values(t.empno, t.ename, 10, t.sal * .15)"; > sql(sql).ok(); // Expected it is ok, but failed{code} > * If we enable `assert`, the error will be *AssertionError.* > {code:java} > java.lang.AssertionError > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3741) > at > org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:61) > at > org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:88) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1144) > at > org.apache.calcite.sql.validate.AbstractNamespace.getRowType(AbstractNamespace.java:119) > at > org.apache.calcite.sql.validate.SelectNamespace.getRowType(SelectNamespace.java:32) > at org.apache.calcite.sql.validate.ListScope.resolve(ListScope.java:203) > at > org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:331) > at > org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:6672) > at > org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:6652) > at org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:323) > 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:956) > at > org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visitScoped(SqlValidatorImpl.java:6696) > at > org.apache.calcite.sql.validate.SqlScopedShuttle.visit(SqlScopedShuttle.java:54) > at > org.apache.calcite.sql.validate.SqlScopedShuttle.visit(SqlScopedShuttle.java:37) > at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:166) > at > org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.go(SqlValidatorImpl.java:6661) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.expand(SqlValidatorImpl.java:6235) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateJoin(SqlValidatorImpl.java:3570) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3444) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3792) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateMerge(SqlValidatorImpl.java:5263) > {code} > * If we disable `assert`, the error will be *NullPointerException.* > {code:java} > java.lang.NullPointerException: rowType > at java.util.Objects.requireNonNull(Objects.java:228) > at > org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:62) > at > org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:88) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1144) > at > org.apache.calcite.sql.validate.AbstractNamespace.getRowType(AbstractNamespace.java:119) > at > org.apache.calcite.sql.validate.SelectNamespace.getRowType(SelectNamespace.java:32) > at org.apache.calcite.sql.validate.ListScope.resolve(ListScope.java:203) > at > org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:331) > at > org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:6672) > at > org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:6652) > at org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:323) > 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:956) > at > org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visitScoped(SqlValidatorImpl.java:6696) > at > org.apache.calcite.sql.validate.SqlScopedShuttle.visit(SqlScopedShuttle.java:54) > at > org.apache.calcite.sql.validate.SqlScopedShuttle.visit(SqlScopedShuttle.java:37) > at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:166) > at > org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.go(SqlValidatorImpl.java:6661) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.expand(SqlValidatorImpl.java:6235) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateJoin(SqlValidatorImpl.java:3570) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3444) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3792) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateMerge(SqlValidatorImpl.java:5263) > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)