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

Zoltan Farkas commented on CALCITE-3488:
----------------------------------------

One can reproduce this live 
[at|https://demo.spf4j.org/avql/query?query=select%20name,%20ARRAY(select%20c2.name%20from%20friendships%20f,%20characters%20c2%20where%20f.characterId1%20=%20c.characterId%20and%20f.characterId2%20=%20c2.characterId)%20as%20friends%20from%20characters%20c]
 with the plan 
[at|https://demo.spf4j.org/avql/query/plan?query=select%20name,%20ARRAY(select%20c2.name%20from%20friendships%20f,%20characters%20c2%20where%20f.characterId1%20=%20c.characterId%20and%20f.characterId2%20=%20c2.characterId)%20as%20friends%20from%20characters%20c&_Accept=application/json]
 

for more context 
[see|https://github.com/zolyfarkas/jaxrs-spf4j-demo/wiki/AvroCalciteRest]

I would be interested to implement this if no-one else has the bandwidth. Can 
somebody point me to some docs that would help me with this? Thanks! 


> Interpreter does not implement LogicalCorelate.
> -----------------------------------------------
>
>                 Key: CALCITE-3488
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3488
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Zoltan Farkas
>            Priority: Major
>
> Example query:
> {code}
> select name,
>          ARRAY(select c2.name from friendships f, characters c2
>                             where f.characterId1 = c.characterId and 
> f.characterId2 = c2.characterId) as friends
> {code}
> where the 2 tables involved are:
> {code}
>     record Character {
>       string characterId;
>       string name = "";
>       string homeWorldPlanet;
>       string speciesName;
>     }
>     record Friendship {
>       string characterId1;
>       string characterId2;
>     }
> {code}
> the plan:
> {code}
> LogicalProject(name=[$1], friends=[$4])
>   LogicalCorrelate(correlation=[$cor0], joinType=[inner], 
> requiredColumns=[{0}])
>     LogicalTableScan(table=[[characters]])
>     Collect(field=[EXPR$0])
>       LogicalProject(name=[$2])
>         LogicalJoin(condition=[=($0, $1)], joinType=[inner])
>           LogicalProject(characterId2=[$1])
>             LogicalFilter(condition=[=($0, $cor0.characterId)])
>               LogicalTableScan(table=[[friendships]])
>           LogicalProject(characterId=[$0], name=[$1])
>             LogicalTableScan(table=[[characters]])\n
> {code}
> when interpreted, results in:
> {code}
> java.lang.UnsupportedOperationException
>       at 
> o.a.c.i.JaninoRexCompiler.lambda$compile$0(JaninoRexCompiler.java:94)[calcite-core-1.21.0.jar:1.21.0]
>       at 
> o.a.c.a.e.RexToLixTranslator.translate0(RexToLixTranslator.java:714)[^]
>       at ^.translate(^:199)[^]
>       at ^.translate0(^:684)[^]
>       at ^.translate(^:199)[^]
>       at ^.translate(^:194)[^]
>       at ^.translateList(^:928)[^]
>       at ^.translateList(^:901)[^]
>       at o.a.c.a.e.RexImpTable.implementCall(RexImpTable.java:1163)[^]
>       at ^.implementNullSemantics(^:1153)[^]
>       at ^.implementNullSemantics0(^:1043)[^]
>       at ^.lambda$createImplementor$4(^:690)[^]
>       at 
> o.a.c.a.e.RexToLixTranslator.translateCall(RexToLixTranslator.java:758)[^]
>       at ^.translate0(^:730)[^]
>       at ^.translate(^:199)[^]
>       at ^.translate0(^:684)[^]
>       at ^.translate(^:199)[^]
>       at ^.translate(^:194)[^]
>       at ^.translateList(^:928)[^]
>       at ^.translateProjects(^:169)[^]
>       at o.a.c.i.JaninoRexCompiler.compile(JaninoRexCompiler.java:101)[^]
>       at o.a.c.i.Interpreter$CompilerImpl.compile(Interpreter.java:487)[^]
>       at o.a.c.i.Nodes$CoreCompiler.compile(Nodes.java:43)[^]
>       at o.a.c.i.TableScanNode.createEnumerable(TableScanNode.java:266)[^]
>       at ^.createProjectableFilterable(^:233)[^]
>       at ^.create(^:81)[^]
>       at o.a.c.i.Nodes$CoreCompiler.visit(Nodes.java:70)[^]
>       at j.i.r.NativeMethodAccessorImpl.invoke0(Native Method)
>       at ^.invoke(^:62)[^]
>       at 
> j.i.r.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[^]
>       at j.l.r.Method.invoke(Method.java:566)[^]
>       at 
> o.a.c.u.ReflectUtil.invokeVisitorInternal(ReflectUtil.java:257)[calcite-core-1.21.0.jar:1.21.0]
>       at ^.invokeVisitor(^:214)[^]
>       at o.a.c.u.ReflectUtil$1.invokeVisitor(^:464)[^]
>       at o.a.c.i.Interpreter$CompilerImpl.visit(Interpreter.java:451)[^]
>       at o.a.c.i.Nodes$CoreCompiler.visit(Nodes.java:43)[^]
>       at o.a.c.r.BiRel.childrenAccept(BiRel.java:45)[^]
>       at o.a.c.i.Interpreter$CompilerImpl.visit(Interpreter.java:447)[^]
>       at o.a.c.i.Nodes$CoreCompiler.visit(Nodes.java:43)[^]
>       at o.a.c.r.SingleRel.childrenAccept(SingleRel.java:72)[^]
>       at o.a.c.i.Interpreter$CompilerImpl.visit(Interpreter.java:447)[^]
>       at o.a.c.i.Nodes$CoreCompiler.visit(Nodes.java:43)[^]
>       at o.a.c.r.SingleRel.childrenAccept(SingleRel.java:72)[^]
>       at o.a.c.i.Interpreter$CompilerImpl.visit(Interpreter.java:447)[^]
>       at o.a.c.i.Nodes$CoreCompiler.visit(Nodes.java:43)[^]
>       at o.a.c.r.BiRel.childrenAccept(BiRel.java:46)[^]
>       at o.a.c.i.Interpreter$CompilerImpl.visit(Interpreter.java:447)[^]
>       at o.a.c.i.Nodes$CoreCompiler.visit(Nodes.java:43)[^]
>       at o.a.c.r.SingleRel.childrenAccept(SingleRel.java:72)[^]
>       at o.a.c.i.Interpreter$CompilerImpl.visit(Interpreter.java:447)[^]
>       at o.a.c.i.Nodes$CoreCompiler.visit(Nodes.java:43)[^]
>       at o.a.c.i.Interpreter$CompilerImpl.visitRoot(Interpreter.java:405)[^]
>       at o.a.c.i.Interpreter.<init>(^:88)[^]
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to