You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Kent Nguyen (Jira)" <ji...@apache.org> on 2020/12/11 05:48:00 UTC

[jira] [Updated] (CALCITE-4181) Avatica throw exception when select field is a List

     [ https://issues.apache.org/jira/browse/CALCITE-4181?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kent Nguyen updated CALCITE-4181:
---------------------------------
    Description: 
Currently Calcite supports array columns from both ArrayImpl or List input.

It also supports both struct and plain java object data format.

The issue is that an exception is thrown when data is a list of plain java objects, while it works fine when data is a list of struct or an array of plain java objects.

I have created unit tests to demonstrate the bug.

Currently these unit tests pass: arraysOfStructs(), listOfStructs(), arrayOfJavaObjects() but listOfJavaObject() is failed.

Method org.apache.calcite.avatica.util.AbstractCursor.ArrayAccessor.convertValue() misses a case for Types.OTHER, which is for general java objects, hence the exception is thrown.

The pull request adds that missing type and makes all four unit tests pass.

Reference link: https://github.com/apache/calcite-avatica/blob/master/core/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java#L1346


  was:
When a select field is a list of java object, for example List<MapRecord>, ArrayAccessor.getObject() throws an exception. The convertValue() function throws that exception when the list component type is Types.OTHER:

[https://github.com/apache/calcite-avatica/blob/master/core/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java#L1346]

Any component type that does not exactly match the types in this list will be considered Types.OTHER:

[https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/type/JavaToSqlTypeConversionRules.java#L45-L82]

If Types.OTHER is treated the same way as Types.JAVA_OBJECT then it will work for a select query that includes an object in its field list.


> Avatica throw exception when select field is a List<?>
> ------------------------------------------------------
>
>                 Key: CALCITE-4181
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4181
>             Project: Calcite
>          Issue Type: Bug
>          Components: avatica
>    Affects Versions: avatica-1.17.0
>            Reporter: Kent Nguyen
>            Assignee: Kent Nguyen
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Currently Calcite supports array columns from both ArrayImpl or List input.
> It also supports both struct and plain java object data format.
> The issue is that an exception is thrown when data is a list of plain java objects, while it works fine when data is a list of struct or an array of plain java objects.
> I have created unit tests to demonstrate the bug.
> Currently these unit tests pass: arraysOfStructs(), listOfStructs(), arrayOfJavaObjects() but listOfJavaObject() is failed.
> Method org.apache.calcite.avatica.util.AbstractCursor.ArrayAccessor.convertValue() misses a case for Types.OTHER, which is for general java objects, hence the exception is thrown.
> The pull request adds that missing type and makes all four unit tests pass.
> Reference link: https://github.com/apache/calcite-avatica/blob/master/core/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java#L1346



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