[
https://issues.apache.org/jira/browse/CALCITE-3046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16831423#comment-16831423
]
Hongze Zhang edited comment on CALCITE-3046 at 5/2/19 5:51 AM:
---------------------------------------------------------------
This is another problem of UDT implementation, not related to CALCITE-3045.
My assumption is that we can fix this issue by making
EnumerableRelImplementor.TypeFinder visit more parts of the expression tree
(such as the type of ConstantExpression, UnaryExpression of "Convert"), however
not sure if the execution performance would be decreased too much.
was (Author: zhztheplayer):
This is another problem of UDT implementation, not related to CALCITE-3045.
My assumption is that we can fix this issue by make
EnumerableRelImplementor.TypeFinder visit more parts of the expression tree
(such as the type of ConstantExpression, UnaryExpression of "Convert"), however
not sure if the execution performance would be decreased too much.
> CompileException when inserting casted value of composited user defined type
> ----------------------------------------------------------------------------
>
> Key: CALCITE-3046
> URL: https://issues.apache.org/jira/browse/CALCITE-3046
> Project: Calcite
> Issue Type: Bug
> Reporter: Hongze Zhang
> Priority: Major
>
> Reproduce the error by running following test case from {{ServerTest.java}}:
> {code:java}
> @Test public void testInsertCastedValueOfCompositeUdt() throws Exception {
> try (Connection c = connect();
> Statement s = c.createStatement()) {
> // CALCITE-2464: Allow to set nullability for columns of structured
> types
> 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));
> }
> }
> {code}
> Root cause of the error:
> {code}
> 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
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)