[
https://issues.apache.org/jira/browse/KYLIN-819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14578739#comment-14578739
]
Sébastien Jelsch commented on KYLIN-819:
----------------------------------------
@Julian:
I don't think it's a bug in Calcite.
Reason for this issue is:
The missing fixed order of ColumnMetaData entries stores the accessor under a
false ordinal number in Calcite.
Concrete example based on _DATA_TYPE_ (see code above):
_DATA_TYPE_ was stored in Kylins columnMetaData Hash at the 22th position, even
though it should be the 5th position. This means, 5th position contains a
StringAccessor rather than an IntAccessor (see error message above).
By looking into AccessorCursor I noticed that the order is important.
https://github.com/apache/incubator-calcite/blob/master/avatica/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java#L70
If the order does not match, the accessors are stored at wrong positions cause
of _accessors.size()_.
> Fix necessary ColumnMetaData order for Calcite (Optic)
> ------------------------------------------------------
>
> Key: KYLIN-819
> URL: https://issues.apache.org/jira/browse/KYLIN-819
> Project: Kylin
> Issue Type: Bug
> Components: Driver - JDBC
> Affects Versions: v0.7.1
> Reporter: Sébastien Jelsch
> Fix For: v0.7.2
>
> Attachments: KYLIN-819-Fix-necessary-ColumnMetaData-order.patch
>
>
> The following code
> {code}
> Class.forName("org.apache.kylin.jdbc.Driver");
>
> Connection con =
> DriverManager.getConnection("jdbc:kylin://localhost:7070/simple_project",
> "admin", "KYLIN");
> DatabaseMetaData dmd = con.getMetaData();
> ResultSet result = dmd.getColumns(null, null, "SIMPLE_FACT", "%");
> while(result.next()) {
> System.out.println("dataType: "+ result.getInt(5));
> }
> {code}
> results in the following error message:
> {noformat}
> Exception in thread "main" java.lang.RuntimeException: cannot convert to long
> (net.hydromatic.optiq.runtime.AbstractCursor$StringAccessor@16107cce)
> at
> net.hydromatic.optiq.runtime.AbstractCursor$AccessorImpl.cannotConvert(AbstractCursor.java:287)
> at
> net.hydromatic.optiq.runtime.AbstractCursor$AccessorImpl.getLong(AbstractCursor.java:243)
> at
> net.hydromatic.optiq.runtime.AbstractCursor$AccessorImpl.getInt(AbstractCursor.java:239)
> at net.hydromatic.avatica.AvaticaResultSet.getInt(AvaticaResultSet.java:220)
> at
> org.mustangore.kylin.KylinConnection.newConnection(KylinConnection.java:32)
> at org.mustangore.kylin.KylinConnection.main(KylinConnection.java:20)
> {noformat}
> Tried with apache-calcite-0.9.1 and apache-calcite-0.9.2 .
> *Reason and fix*
> SQLTypeMap uses HasMap, but Calcite (Optic) needs specific order. So using
> _LinkedHashMap_ fixes this issue.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)