You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2022/06/02 23:03:00 UTC
[jira] [Commented] (CALCITE-5178) Scalar subquery in scalar subquery generates plan that will not compile
[ https://issues.apache.org/jira/browse/CALCITE-5178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17545679#comment-17545679 ]
Julian Hyde commented on CALCITE-5178:
--------------------------------------
A similar query has a related error at runtime:
{code:java}
> select array (select (1, 2));
Error: Error while executing SQL "select array (select (1, 2))": class [Ljava.lang.Object; cannot be cast to class Baz$Record2_1 ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; Baz$Record2_1 is in unnamed module of loader org.codehaus.commons.compiler.util.reflect.ByteArrayClassLoader @5731caaf) (state=,code=0)
{code}
Some other similar queries work just fine:
{noformat}
> select (select array [(1, 2)]);
+----------+
| EXPR$0 |
+----------+
| [{1, 2}] |
+----------+
1 row selected (0.035 seconds)
> select ((select 1), 2);
+--------+
| EXPR$0 |
+--------+
| {1, 2} |
+--------+
1 row selected (0.024 seconds)
{noformat}
> Scalar subquery in scalar subquery generates plan that will not compile
> -----------------------------------------------------------------------
>
> Key: CALCITE-5178
> URL: https://issues.apache.org/jira/browse/CALCITE-5178
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Priority: Major
>
> Scalar subquery in scalar subquery generates plan that will not compile. Example:
> {code:java}
> > select (select (1, 2));
> Error: Error while executing SQL "select (select (1, 2))": Error while compiling generated Java code:
> ...
> public static class Record2_3 implements java.io.Serializable {
> public boolean f0;
> public Object[] f1;
> ...
> }
> java.util.List accumulatorAdders = new java.util.LinkedList();
> accumulatorAdders.add(new org.apache.calcite.linq4j.function.Function2() {
> public Record2_3 apply(Record2_3 acc, Record2_1 in) {
> if (acc.f0) {
> throw new IllegalStateException(
> "more than one value in agg SINGLE_VALUE");
> }
> acc.f0 = true;
> acc.f1 = in;
> return acc;
> }
> public Record2_3 apply(Object acc, Object in) {
> return apply(
> (Record2_3) acc,
> (Record2_1) in);
> }
> }
> );
> ...
> {code}
> Note the line {{acc.f1 = in;}} is attempting to assign a {{Record2_1}} value to a {{Object[]}} field.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)