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

Julian Hyde commented on CALCITE-1054:
--------------------------------------

[~maryannxue], I am seeing a failure in CoreQuidemTest (with argument 
"sql/misc.iq") that seems to occur frequently after your change and not before. 
Can you take a look, please?

{noformat}Error while executing SQL "select period("sqlDate", INTERVAL '1' 
YEAR) as p
> from "everyTypes"
> ": null
>       at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
>       at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
>       at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
>       at 
> org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218)
>       at 
> net.hydromatic.quidem.Quidem$CheckResultCommand.execute(Quidem.java:830)
>       at 
> net.hydromatic.quidem.Quidem$CompositeCommand.execute(Quidem.java:1450)
>       at net.hydromatic.quidem.Quidem.execute(Quidem.java:197)
>       at org.apache.calcite.test.QuidemTest.checkRun(QuidemTest.java:152)
>       at 
> org.apache.calcite.test.CoreQuidemTest.testSqlMisc(CoreQuidemTest.java:67)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:483)
>       at org.apache.calcite.test.QuidemTest.test(QuidemTest.java:207)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:483)
>       at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>       at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>       at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>       at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>       at org.junit.runners.Suite.runChild(Suite.java:128)
>       at org.junit.runners.Suite.runChild(Suite.java:27)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>       at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
>       at 
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
>       at 
> com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
>       at 
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
>       at 
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> Caused by: java.util.ConcurrentModificationException
>       at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:886)
>       at java.util.ArrayList$Itr.next(ArrayList.java:836)
>       at 
> org.apache.calcite.linq4j.tree.BlockBuilder.optimize(BlockBuilder.java:329)
>       at 
> org.apache.calcite.linq4j.tree.BlockBuilder.toBlock(BlockBuilder.java:311)
>       at 
> org.apache.calcite.adapter.enumerable.EnumerableCalc.implement(EnumerableCalc.java:211)
>       at 
> org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.implementRoot(EnumerableRelImplementor.java:108){noformat}

Although it's a {{ConcurrentModificationException}} I don't think it's due to 
multiple threads; it's due to the BlockBuilder.statements collection being 
modified by a function called from within a for-each loop over that same 
collection.

> NPE caused by wrong code generation for Timestamp fields
> --------------------------------------------------------
>
>                 Key: CALCITE-1054
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1054
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.6.0, 1.5.0, 1.4.0-incubating
>            Reporter: Frankie Bollaert
>            Assignee: Julian Hyde
>            Priority: Minor
>             Fix For: 1.16.0
>
>
> Problem occurs when:
> - Execute a query containing 2 checks on a Timestamp field
> - Table contains records which have NULL values for this field 
> Example query:
> {code}
> select * from aTable where aTimestamp > timestamp '2015-1-1 00:00:00' and 
> aTimestamp < timestamp '2015-2-1 00:00:00';
> {code}
> {code}
> /*  48 */   public boolean moveNext() {
> /*  49 */     while (inputEnumerator.moveNext()) {
> /*  50 */       final java.sql.Timestamp inp23_ = (java.sql.Timestamp) 
> ((Object[]) inputEnumerator.current())[23];
> /*  51 */       final long v = 
> org.apache.calcite.runtime.SqlFunctions.toLong(inp23_);
> /*  52 */       if (inp23_ != null && v > 1420070400000L && (inp23_ != null 
> && v < 1422748800000L)) {
> /*  53 */         return true;
> /*  54 */       }
> /*  55 */     }
> /*  56 */     return false;
> /*  57 */   }
> {code}
> Stack trace snippet
> {code}
> Caused by: java.lang.NullPointerException
>       at 
> org.apache.calcite.runtime.SqlFunctions.toLong(SqlFunctions.java:1094)
>       at 
> org.apache.calcite.runtime.SqlFunctions.toLong(SqlFunctions.java:1089)
>       at Baz$1$1.moveNext(ANONYMOUS.java:51)
>       at 
> org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.<init>(Linq4j.java:677)
>       at org.apache.calcite.linq4j.Linq4j.enumeratorIterator(Linq4j.java:103)
> {code}
> The generated code also looks wrong for date fields.
> {code}
> /*  15 */   public boolean moveNext() {
> /*  16 */     while (inputEnumerator.moveNext()) {
> /*  17 */       final java.sql.Date current = (java.sql.Date) 
> inputEnumerator.current();
> /*  18 */       final int v = 
> org.apache.calcite.runtime.SqlFunctions.toInt(current);
> /*  19 */       if (current != null && v > 2780 && (current != null && v < 
> 5290)) {
> /*  20 */         return true;
> /*  21 */       }
> /*  22 */     }
> /*  23 */     return false;
> /*  24 */   }
> {code}
> \\
> Other types of fields do not have this problem.  Below is what the generated 
> code looks like in the case of a String field.  *On line 20 there is a null 
> check.*  This is the type of check that needs to be generated for Timestamp 
> fields as well. 
> {code}
> select empno from sales.emps where gender > 'A' and gender < 'Z';
> {code}
> {code}
> /*  17 */  public boolean moveNext() {
> /*  18 */    while (inputEnumerator.moveNext()) {
> /*  19 */      final Object[] current = (Object[]) inputEnumerator.current();
> /*  20 */      final String inp3_ = current[3] == null ? (String) null : 
> current[3].toString();
> /*  21 */      if (inp3_ != null && 
> org.apache.calcite.runtime.SqlFunctions.gt(inp3_, 
> $L4J$C$org_apache_calcite_runtime_SqlFunctions_rtrim_A_) && (inp3_ != null && 
> org.apache.calcite.runtime.SqlFunctions.lt(inp3_, 
> $L4J$C$org_apache_calcite_runtime_SqlFunctions_rtrim_Z_))) {
> /*  22 */        return true;
> /*  23 */      }
> /*  24 */    }
> /*  25 */    return false;
> /*  26 */  }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to