Hi,
looks like tables with same columns will be mixed inside the engine somehow...
The following test case shows the issue:
public class SqlTest {
public static class MyTable {
public String mykey = "foo";
public Integer myvalue = 1;
}
public static class MyTable2 {
public String mykey = "foo";
public Integer myvalue = 1;
}
public static class MySchema {
public MyTable[] mytable = new MyTable[] { new MyTable() };
public MyTable2[] mytable2 = new MyTable2[] { new MyTable2() };
}
public static void main(String[] args) throws Exception {
Class.forName("net.hydromatic.optiq.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:optiq:");
OptiqConnection optiqConnection = connection.unwrap(OptiqConnection.class);
ReflectiveSchema.create(optiqConnection, optiqConnection.getRootSchema(), "TEST", mySchema);
Statement statement = optiqConnection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT \"myvalue\" from TEST.\"mytable2\"");
while(resultSet.next()) {
System.out.println(resultSet.getInt("myvalue"));
}
resultSet.close();
statement.close();
connection.close();
}
}
Both MyTable and MyTable2 have the same columns (names and types) and this will result in the following error:
Exception in thread "main" java.lang.ClassCastException: SqlTest$MyTable2 cannot be cast to SqlTest$MyTable
at Baz$1$1.current(Unknown Source)
at net.hydromatic.optiq.runtime.ObjectEnumeratorCursor$ObjectEnumeratorGetter.getObject(ObjectEnumeratorCursor.java:57)
at net.hydromatic.optiq.runtime.AbstractCursor$AccessorImpl.getObject(AbstractCursor.java:183)
at net.hydromatic.optiq.runtime.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:369)
at net.hydromatic.optiq.jdbc.OptiqResultSet.getInt(OptiqResultSet.java:255)
at SqlTest.main(SqlTest.java:62)
Thanks a lot.
best regards, -Hannes-