[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jira] [Created] (CALCITE-2346) UNION results with different column types can cause ClassCastException


Marc Prud'hommeaux created CALCITE-2346:
-------------------------------------------

             Summary: UNION results with different column types can cause ClassCastException
                 Key: CALCITE-2346
                 URL: https://issues.apache.org/jira/browse/CALCITE-2346
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.16.0
         Environment: macOS 10.13.4 (17E202)
openjdk version "10" 2018-03-20
OpenJDK Runtime Environment 18.3 (build 10+46)
OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)

            Reporter: Marc Prud'hommeaux
            Assignee: Julian Hyde


Trying to union results from two separate data types is throwing:

{code:java}
java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to java.base/java.lang.Integer
	at org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
	at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
	at org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
	at sqlline.Rows$Row.<init>(Rows.java:157)
	at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
	at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
	at sqlline.SqlLine.print(SqlLine.java:1648)

{code}

It can reproduced with the command:

{code:java}
coursier launch \
  sqlline:sqlline:1.4.0 \
  org.apache.calcite:calcite-core:1.16.0 \
  org.hsqldb:hsqldb:2.4.0 \
  net.hydromatic:scott-data-hsqldb:0.1 \
  net.hydromatic:foodmart-data-hsqldb:0.4 \
  -M sqlline.SqlLine -- \
  -d org.apache.calcite.jdbc.Driver \
  -u 'jdbc:calcite:model=inline:{"version":1.0,"schemas":[{"name":"scott","type":"jdbc","jdbcUrl":"jdbc:hsqldb:res:scott","jdbcUser":"SCOTT","jdbcPassword":"TIGER"},{"name":"foodmart","type":"jdbc","jdbcSchema":"foodmart","jdbcUrl":"jdbc:hsqldb:res:foodmart"}]}' 
{code}


The following command works fine:

{code:java}
0: jdbc:calcite:model=inline:{"version":1.0,"> select "DNAME" from "scott"."DEPT" union all select "department_description" from "foodmart"."department";
+--------------------------------+
|             DNAME              |
+--------------------------------+
| ACCOUNTING                     |
| RESEARCH                       |
| SALES                          |
| OPERATIONS                     |
| HQ General Management          |
| HQ Information Systems         |
| HQ Marketing                   |
| HQ Human Resources             |
| HQ Finance and Accounting      |
| Store Management               |
| Store Information Systems      |
| Store Permanent Checkers       |
| Store Temporary Checkers       |
| Store Permanent Stockers       |
| Store Temporary Stockers       |
| Store Permanent Butchers       |
+--------------------------------+
16 rows selected (0.069 seconds)
{code}

But when unioning two different column types:

{code:java}
0: jdbc:calcite:model=inline:{"version":1.0,"> select "DEPTNO", "DNAME" from "scott"."DEPT" union all select "department_id", "department_description" from "foodmart"."department";
+------------+--------------------------------+
|   DEPTNO   |             DNAME              |
+------------+--------------------------------+
java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to java.base/java.lang.Integer
	at org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
	at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
	at org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
	at sqlline.Rows$Row.<init>(Rows.java:157)
	at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
	at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
	at sqlline.SqlLine.print(SqlLine.java:1648)
	at sqlline.Commands.execute(Commands.java:834)
	at sqlline.Commands.sql(Commands.java:733)
	at sqlline.SqlLine.dispatch(SqlLine.java:795)
{code}

Possibly related: https://issues.apache.org/jira/browse/CALCITE-580




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)