Sébastien Jelsch created KYLIN-819:
--------------------------------------

             Summary: 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
            Reporter: Sébastien Jelsch


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)

Reply via email to