[ 
https://issues.apache.org/jira/browse/CALCITE-667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14482905#comment-14482905
 ] 

Ng Jiunn Jye commented on CALCITE-667:
--------------------------------------

The delete operation work well with our custom adapter 

When I tried to add in test case in JdbcFrontLinqBackTest, the test took a long 
time to run and got into GC out of memory Exception. Do you have any idea what 
went wrong ? 
Exception and generated code below. 


  @Test public void testDelete() {
    final List<JdbcTest.Employee> employees =
        new ArrayList<JdbcTest.Employee>();
    CalciteAssert.AssertThat with = mutable(employees);
    System.out.println ("NOW TRY DELETE");
    with.query("delete from \"foo\".\"bar\" where \"empid\" = 100")
        .returns("ROWCOUNT=1\n");
  }

java.lang.OutOfMemoryError: GC overhead limit exceeded
        at Baz$2.apply(ANONYMOUS.java:45)
        at Baz$2.apply(ANONYMOUS.java:54)
        at 
org.apache.calcite.linq4j.EnumerableDefaults$6$1.current(EnumerableDefaults.java:1570)
        at 
org.apache.calcite.linq4j.EnumerableDefaults.into(EnumerableDefaults.java:2366)
        at 
org.apache.calcite.linq4j.DefaultEnumerable.into(DefaultEnumerable.java:342)
        at Baz.bind(Baz.java:57)
        at 
org.apache.calcite.jdbc.CalcitePrepare$CalciteSignature.enumerable(CalcitePrepare.java:246)
        at 
org.apache.calcite.jdbc.CalciteConnectionImpl.enumerable(CalciteConnectionImpl.java:236)
        at 
org.apache.calcite.jdbc.CalciteMetaImpl.createIterable(CalciteMetaImpl.java:463)
        at 
org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:183)
        at 
org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:63)
        at 
org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:1)
        at 
org.apache.calcite.avatica.AvaticaConnection$1.execute(AvaticaConnection.java:470)
        at 
org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:493)
        at 
org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:474)
        at 
org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:108)
        at 
org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:129)
        at 
org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:449)
        at 
org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1144)
        at 
org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1138)
        at 
org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1126)
        at 
org.apache.calcite.test.JdbcFrontLinqBackTest.testInsertDelete(JdbcFrontLinqBackTest.java:249)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        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)



Generated Code: 
FINE: Plan after physical tweaks: EnumerableTableModify(table=[[foo, bar]], 
operation=[DELETE], updateColumnList=[[]], flattened=[false]): rowcount = 15.0, 
cumulative cost = {130.0 rows, 1501.0 cpu, 0.0 io}, id = 49
  EnumerableCalc(expr#0..4=[{inputs}], expr#5=[CAST($t0):INTEGER NOT NULL], 
expr#6=[100], expr#7=[=($t5, $t6)], proj#0..4=[{exprs}], $condition=[$t7]): 
rowcount = 15.0, cumulative cost = {115.0 rows, 1501.0 cpu, 0.0 io}, id = 51
    EnumerableTableScan(table=[[foo, bar]]): rowcount = 100.0, cumulative cost 
= {100.0 rows, 101.0 cpu, 0.0 io}, id = 22


/*   1 */ org.apache.calcite.DataContext root;
/*   2 */ 
/*   3 */ public org.apache.calcite.linq4j.Enumerable bind(final 
org.apache.calcite.DataContext root0) {
/*   4 */   root = root0;
/*   5 */   final org.apache.calcite.linq4j.Enumerable _inputEnumerable = 
org.apache.calcite.schema.Schemas.queryable(root, 
root.getRootSchema().getSubSchema("foo"), 
org.apache.calcite.test.JdbcTest.Employee.class, "bar").asEnumerable();
/*   6 */   final org.apache.calcite.linq4j.AbstractEnumerable child = new 
org.apache.calcite.linq4j.AbstractEnumerable(){
/*   7 */     public org.apache.calcite.linq4j.Enumerator enumerator() {
/*   8 */       return new org.apache.calcite.linq4j.Enumerator(){
/*   9 */           public final org.apache.calcite.linq4j.Enumerator 
inputEnumerator = _inputEnumerable.enumerator();
/*  10 */           public void reset() {
/*  11 */             inputEnumerator.reset();
/*  12 */           }
/*  13 */ 
/*  14 */           public boolean moveNext() {
/*  15 */             while (inputEnumerator.moveNext()) {
/*  16 */               if (((org.apache.calcite.test.JdbcTest.Employee) 
inputEnumerator.current()).empid == 100) {
/*  17 */                 return true;
/*  18 */               }
/*  19 */             }
/*  20 */             return false;
/*  21 */           }
/*  22 */ 
/*  23 */           public void close() {
/*  24 */             inputEnumerator.close();
/*  25 */           }
/*  26 */ 
/*  27 */           public Object current() {
/*  28 */             final org.apache.calcite.test.JdbcTest.Employee current = 
(org.apache.calcite.test.JdbcTest.Employee) inputEnumerator.current();
/*  29 */             return new Object[] {
/*  30 */                 current.empid,
/*  31 */                 current.deptno,
/*  32 */                 current.name,
/*  33 */                 current.salary,
/*  34 */                 current.commission};
/*  35 */           }
/*  36 */ 
/*  37 */         };
/*  38 */     }
/*  39 */ 
/*  40 */   };
/*  41 */   final java.util.Collection collection = 
((org.apache.calcite.schema.ModifiableTable) 
root.getRootSchema().getSubSchema("foo").getTable("bar")).getModifiableCollection();
/*  42 */   final int _count = collection.size();
/*  43 */   child.select(new org.apache.calcite.linq4j.function.Function1() {
/*  44 */     public org.apache.calcite.test.JdbcTest.Employee apply(Object[] 
o) {
/*  45 */       return new org.apache.calcite.test.JdbcTest.Employee(
/*  46 */           org.apache.calcite.runtime.SqlFunctions.toInt(o[0]),
/*  47 */           org.apache.calcite.runtime.SqlFunctions.toInt(o[1]),
/*  48 */           o[2] == null ? (String) null : o[2].toString(),
/*  49 */           org.apache.calcite.runtime.SqlFunctions.toFloat(o[3]),
/*  50 */           (Integer) o[4]);
/*  51 */     }
/*  52 */     public Object apply(Object o) {
/*  53 */       return apply(
/*  54 */         (Object[]) o);
/*  55 */     }
/*  56 */   }
/*  57 */   ).into(collection);
/*  58 */   return org.apache.calcite.linq4j.Linq4j.singletonEnumerable((long) 
(collection.size() - _count));
/*  59 */ }
/*  60 */ 
/*  61 */ 
/*  62 */ public Class getElementType() {
/*  63 */   return long.class;
/*  64 */ }
/*  65 */ 
/*  66 */ 

> AvaticaResultSet.execute expecting Array Iterable from Delete Statement
> -----------------------------------------------------------------------
>
>                 Key: CALCITE-667
>                 URL: https://issues.apache.org/jira/browse/CALCITE-667
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Ng Jiunn Jye
>            Assignee: Julian Hyde
>              Labels: avatica
>         Attachments: 
> [CALCITE-667]AvaticaResultSet.executeExpectingArrayIterableFromDeleteStatement.patch
>
>
> Delete execution should return the number of rows impacted. However 
> AvaticaResultStatement.execute was expecting an array. See error stack trace 
> below. 
> This is caused by the CalcitePrepareImpl.prepare_2 RelDataType 
> createDmlRowType is not defined properly for SqlKind DELETE. Same problem for 
> UPDATE
> Error Stack: 
> Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of 
> range: 0
>       at java.util.Arrays$ArrayList.get(Arrays.java:2877)
>       at 
> org.apache.calcite.avatica.util.RecordIteratorCursor.createGetter(RecordIteratorCursor.java:59)
>       at 
> org.apache.calcite.avatica.util.AbstractCursor.createAccessor(AbstractCursor.java:80)
>       at 
> org.apache.calcite.avatica.util.AbstractCursor.createAccessors(AbstractCursor.java:70)
>       at 
> org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:187)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to