[
https://issues.apache.org/jira/browse/CALCITE-4064?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17135546#comment-17135546
]
Ruben Q L edited comment on CALCITE-4064 at 6/15/20, 7:42 AM:
--------------------------------------------------------------
Root cause is in {{SqlFunctions$ProductComparableListEnumerator.current}}, this
line:
{code}
System.arraycopy(a, 0, flatElements, i, a.length);
{code}
throws the exception because our source array (a) contains an Integer on its
first position, and an array on its second position:
{{[1, [5, 10]]]}}
See {{System.arraycopy}} javadoc, specially the notes concerning
{{ArrayStoreException}}:
https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#arraycopy-java.lang.Object-int-java.lang.Object-int-int-
was (Author: rubenql):
Root cause is in {{SqlFunctions$ProductComparableListEnumerator.current}}, this
line:
{code}
System.arraycopy(a, 0, flatElements, i, a.length);
{code}
throws the exception because our source array (a) contains an Integer on its
first position, and an array on its second position: {{[1, [5, 10]]]}}
See {{System.arraycopy}} javadoc, specially the notes concerning
{{ArrayStoreException}}:
https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#arraycopy-java.lang.Object-int-java.lang.Object-int-int-
> Unnest on array with nested structs causes ArrayStoreException
> --------------------------------------------------------------
>
> Key: CALCITE-4064
> URL: https://issues.apache.org/jira/browse/CALCITE-4064
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.23.0
> Reporter: Ruben Q L
> Priority: Major
>
> Maybe related to CALCITE-4063.
> The problem can be reproduced by running the following query:
> {code:sql}
> select * from UNNEST(array[ROW(1, ROW(5, 10)), ROW(2, ROW(6, 12))])
> {code}
> Which fails with:
> {code}
> java.lang.ArrayStoreException
> at java.lang.System.arraycopy(Native Method)
> at
> org.apache.calcite.runtime.SqlFunctions$ProductComparableListEnumerator.current(SqlFunctions.java:2837)
> at
> org.apache.calcite.runtime.SqlFunctions$ProductComparableListEnumerator.current(SqlFunctions.java:2804)
> at
> org.apache.calcite.linq4j.EnumerableDefaults$17$1.current(EnumerableDefaults.java:2619)
> at
> org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.next(Linq4j.java:684)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)