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

Joshua James Maurice edited comment on CALCITE-5204 at 7/6/22 10:56 PM:
------------------------------------------------------------------------

[~jiajunbernoulli] , thanks. I'll take a look.

I'm uploading a repro case. Note that when I get the Enumerator directly from 
the physical plan, I see no problems. However, when I try to make a ResultSet 
via the RelRunner of a Calcite Connection, then I see this error. With the 
patch that I tentatively proposed, I see no error with the RelRunner code.


was (Author: JIRAUSER292350):
[~jiajunbernoulli] , thanks. I'll take a look.

I'm uploading a repro case. Note that when I get the Enumerator directly from 
the physical plan, I see no problems. However, when I try to make a ResultSet 
via the RelRunner of a Calcite Connection, then I see this error. With the 
patch that I tentatively proposed, I see no error with the RelRunner code.

 

 

> ColumnMetaData.Rep is incorrect for ArrayAccessor for nested arrays
> -------------------------------------------------------------------
>
>                 Key: CALCITE-5204
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5204
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.30.0
>            Reporter: Joshua James Maurice
>            Priority: Major
>         Attachments: Reproduction.java, reproduction-output.txt, 
> with-patch-output.txt
>
>
> Nested arrays don't work. ResultSet.getObject() throws because the 
> ArrayAccessor uses the wrong Rep type for the nested array use case. The 
> cause is that the Rep object is incorrect (or the code uses the wrong Rep 
> object). For one of the ArrayAccessors, the Rep object that it uses is 
> PRIMITIVE_INT instead of MULTISET. 
> Proposed fix: I am not certain that this is the correct fix, but my own 
> informal testing shows that it fixes the problem for me.
> {code:java}
> diff --git 
> a/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java 
> b/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java
> index d73f7fb..7ad3c15 100644
> --- a/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java
> +++ b/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java
> @@ -786,7 +786,7 @@ private static ColumnMetaData metaData(JavaTypeFactory 
> typeFactory, int ordinal,
>      if (type.getComponentType() != null) {
>        final ColumnMetaData.AvaticaType componentType =
>            avaticaType(typeFactory, type.getComponentType(), null);
> -      final Type clazz = typeFactory.getJavaClass(type.getComponentType());
> +      final Type clazz = typeFactory.getJavaClass(type);
>        final ColumnMetaData.Rep rep = ColumnMetaData.Rep.of(clazz);
>        assert rep != null;
>        return ColumnMetaData.array(componentType, typeName, rep);
>  {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to