You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Joshua James Maurice (Jira)" <ji...@apache.org> on 2022/07/06 07:20:00 UTC
[jira] [Commented] (CALCITE-5204) ColumnMetaData.Rep is incorrect for ArrayAccessor for nested arrays
[ https://issues.apache.org/jira/browse/CALCITE-5204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17563011#comment-17563011 ]
Joshua James Maurice commented on CALCITE-5204:
-----------------------------------------------
I can try to make a test case for this. However, I am unsure of the current state of affairs regarding nested structs and arrays. I've been unable to find any firm documentation about this.
> 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
>
> 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)