You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Lai Yeong Wei <yw...@origineit.com> on 2015/06/02 08:55:31 UTC

Update to ModifiableTable

Hi All,

I am attempting to fire the query below into the
JdbcTest#AbstractModifiableTable which is an implementation of
ModifiableTable,

String sql = "update \"foo\".\"bar\" set \"deptno\" = 90 where \"empid\" =
2";

1. It hit into an IndexOutOfBoundsException thrown at JavaRowFormat.java:47
(Refer full stack trace below)

2. The Plan after converting SqlNode to RelNode appears wanting to project
the "90" expression within a LogicalProject, which does not seemed right
(refer below for plan)

Feel free to shed some lights.

Thanks!

/****************************************************************************/

Stack Trace for IndexOutOfBoundsException for #1,

java.sql.SQLException: error while executing SQL "update "foo"."bar" set
"deptno" = 90 where "empid" = 2": index (5) must be less than size (5)
at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
at
org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:129)
at
org.apache.calcite.avatica.AvaticaStatement.execute(AvaticaStatement.java:138)
at
org.apache.calcite.test.JdbcFrontLinqBackTest.testUpdate(JdbcFrontLinqBackTest.java:407)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:94)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:619)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.IndexOutOfBoundsException: index (5) must be less than
size (5)
at
com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:305)
at
com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:284)
at
com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:81)
at
org.apache.calcite.adapter.enumerable.JavaRowFormat$1.javaFieldClass(JavaRowFormat.java:47)
at
org.apache.calcite.adapter.enumerable.PhysTypeImpl.getJavaFieldType(PhysTypeImpl.java:484)
at
org.apache.calcite.adapter.enumerable.EnumerableTableModify.implement(EnumerableTableModify.java:111)
at
org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.implementRoot(EnumerableRelImplementor.java:99)
at
org.apache.calcite.adapter.enumerable.EnumerableInterpretable.toBindable(EnumerableInterpretable.java:92)
at
org.apache.calcite.prepare.CalcitePrepareImpl$CalcitePreparingStmt.implement(CalcitePrepareImpl.java:1056)
at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:293)
at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:188)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:680)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:570)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:539)
at
org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:173)
at
org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:504)
at
org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:506)
at
org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:127)
... 25 more

/***************************************************************************************/

Plan after converting SqlNode to RelNode for #2,

LogicalTableModify(table=[[foo, bar]], operation=[UPDATE],
updateColumnList=[[deptno]], flattened=[false])
  LogicalProject(empid=[$0], deptno=[$1], name=[$2], salary=[$3],
commission=[$4], EXPR$0=[90])
    LogicalFilter(condition=[=(CAST($0):INTEGER NOT NULL, 2)])
      EnumerableTableScan(table=[[foo, bar]])