Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-3046

CompileException when inserting casted value of composited user defined type into table

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.20.0
    • Component/s: None

      Description

      Reproduce the error by running following test case from ServerTest.java:

        @Test public void testInsertCastedValueOfCompositeUdt() throws Exception {
          try (Connection c = connect();
               Statement s = c.createStatement()) {
            boolean b = s.execute("create type mytype as (i int, j int)");
            assertThat(b, is(false));
            b = s.execute("create table w (i int not null, j mytype)");
            assertThat(b, is(false));
            int x = s.executeUpdate("insert into w "
                + "values (1, cast((select j from w) as mytype))");
            assertThat(x, is(1));
          }
        }
      

      Root cause of the error:

      Caused by: org.codehaus.commons.compiler.CompileException: Line 96, Column 84: Cannot determine simple type name "Record2_0"
      	at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:12211)
      	at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:6833)
      	at org.codehaus.janino.UnitCompiler.getReferenceType(UnitCompiler.java:6594)
      	at org.codehaus.janino.UnitCompiler.getType2(UnitCompiler.java:6573)
      	at org.codehaus.janino.UnitCompiler.access$13900(UnitCompiler.java:215)
      	at org.codehaus.janino.UnitCompiler$22$1.visitReferenceType(UnitCompiler.java:6481)
      	at org.codehaus.janino.UnitCompiler$22$1.visitReferenceType(UnitCompiler.java:6476)
      	at org.codehaus.janino.Java$ReferenceType.accept(Java.java:3928)
      	at org.codehaus.janino.UnitCompiler$22.visitType(UnitCompiler.java:6476)
      	at org.codehaus.janino.UnitCompiler$22.visitType(UnitCompiler.java:6469)
      	at org.codehaus.janino.Java$ReferenceType.accept(Java.java:3927)
      	at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:6469)
      	at org.codehaus.janino.UnitCompiler.access$1300(UnitCompiler.java:215)
      	at org.codehaus.janino.UnitCompiler$36.getParameterTypes2(UnitCompiler.java:10383)
      	at org.codehaus.janino.IClass$IInvocable.getParameterTypes(IClass.java:960)
      	at org.codehaus.janino.IClass$IMethod.getDescriptor2(IClass.java:1227)
      	at org.codehaus.janino.IClass$IInvocable.getDescriptor(IClass.java:983)
      	at org.codehaus.janino.IClass.getIMethods(IClass.java:248)
      	at org.codehaus.janino.IClass.getIMethods(IClass.java:237)
      	at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:492)
      	at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:981)
      	at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:951)
      	at org.codehaus.janino.UnitCompiler.access$200(UnitCompiler.java:215)
      	at org.codehaus.janino.UnitCompiler$2.visitAnonymousClassDeclaration(UnitCompiler.java:409)
      	at org.codehaus.janino.UnitCompiler$2.visitAnonymousClassDeclaration(UnitCompiler.java:406)
      	at org.codehaus.janino.Java$AnonymousClassDeclaration.accept(Java.java:1149)
      	at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:406)
      	at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:5509)
      	at org.codehaus.janino.UnitCompiler.access$9500(UnitCompiler.java:215)
      	at org.codehaus.janino.UnitCompiler$16.visitNewAnonymousClassInstance(UnitCompiler.java:4432)
      	at org.codehaus.janino.UnitCompiler$16.visitNewAnonymousClassInstance(UnitCompiler.java:4396)
      	at org.codehaus.janino.Java$NewAnonymousClassInstance.accept(Java.java:5238)
      	at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:4396)
      	at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:5662)
      	at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:5182)
      	at org.codehaus.janino.UnitCompiler.access$9100(UnitCompiler.java:215)
      	at org.codehaus.janino.UnitCompiler$16.visitMethodInvocation(UnitCompiler.java:4423)
      	at org.codehaus.janino.UnitCompiler$16.visitMethodInvocation(UnitCompiler.java:4396)
      	at org.codehaus.janino.Java$MethodInvocation.accept(Java.java:5073)
      	at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:4396)
      	at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:5662)
      	at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2580)
      	at org.codehaus.janino.UnitCompiler.access$2700(UnitCompiler.java:215)
      	at org.codehaus.janino.UnitCompiler$6.visitLocalVariableDeclarationStatement(UnitCompiler.java:1503)
      	at org.codehaus.janino.UnitCompiler$6.visitLocalVariableDeclarationStatement(UnitCompiler.java:1487)
      	at org.codehaus.janino.Java$LocalVariableDeclarationStatement.accept(Java.java:3522)
      	at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:1487)
      	at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1567)
      	at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:3388)
      	at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:1357)
      	at org.codehaus.janino.UnitCompiler.compileDeclaredMethods(UnitCompiler.java:1330)
      	at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:822)
      	at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:432)
      	at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:215)
      	at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:411)
      	at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:406)
      	at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1414)
      	at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:406)
      	at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:378)
      	at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:237)
      	at org.codehaus.janino.SimpleCompiler.compileToClassLoader(SimpleCompiler.java:465)
      	at org.codehaus.janino.ClassBodyEvaluator.compileToClass(ClassBodyEvaluator.java:313)
      	at org.codehaus.janino.ClassBodyEvaluator.cook(ClassBodyEvaluator.java:235)
      	at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:207)
      	at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:50)
      	at org.codehaus.janino.ClassBodyEvaluator.createInstance(ClassBodyEvaluator.java:347)
      	at org.apache.calcite.adapter.enumerable.EnumerableInterpretable.getBindable(EnumerableInterpretable.java:162)
      	at org.apache.calcite.adapter.enumerable.EnumerableInterpretable.toBindable(EnumerableInterpretable.java:125)
      	... 37 more
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                zhztheplayer Hongze Zhang
                Reporter:
                zhztheplayer Hongze Zhang
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m