LucidDB / luciddb

DEFUNCT: See README
https://github.com/LucidDB/luciddb
Apache License 2.0
53 stars 24 forks source link

[FRG-139] MedMdrJoinRelImplementor needs to generate subclass-filtering #732

Closed dynamobi-build closed 12 years ago

dynamobi-build commented 12 years ago

[reporter="jvs", created="Fri, 2 Jun 2006 17:43:40 -0500 (GMT-05:00)"] create view sequence_view as
    select
        c.table_cat,
        c.table_schem,
        c.table_name,
        c.column_name,
        s."baseValue",
        s."increment",
        s."minValue",
        s."maxValue",
        s."cycle",
        s."expired"
    from
        sys_boot.jdbc_metadata.columns_view_internal c
    inner join
        sys_fem."SQL2003"."SequenceGenerator" s
    on
        c."mofId" = s."Column"
;

0: jdbc:farrago:> select * from sequence_view;
Error: java.lang.ClassCastException:
net.sf.farrago.fem.med.FemViewColumn$Impl (state=,code=0)

Error: java.lang.ClassCastException: net.sf.farrago.fem.med.FemViewColumn$Impl (state=,code=0)
net.sf.farrago.jdbc.FarragoJdbcUtil$FarragoSqlException: java.lang.ClassCastException: net.sf.farrago.fem.med.FemViewColumn$Impl
        at net.sf.farrago.dynamic.stmt8279.ExecutableStmt$8.getNextRightIterator(Unknown Source)
        at org.eigenbase.runtime.NestedLoopCalcTupleIter.fetchNext(NestedLoopCalcTupleIter.java:81)
        at net.sf.farrago.dynamic.stmt8279.ExecutableStmt$9.fetchNext(Unknown Source)
        at org.eigenbase.runtime.TupleIterResultSet.next(TupleIterResultSet.java:90)
        at net.sf.farrago.runtime.FarragoTupleIterResultSet.next(FarragoTupleIterResultSet.java:97)
        at sqlline.SqlLine$BufferedRows.(Unknown Source)
        at sqlline.SqlLine.print(Unknown Source)

dynamobi-build commented 12 years ago

[author="jvs", created="Fri, 2 Jun 2006 17:44:32 -0500 (GMT-05:00)"] I investigated this one and it's kind of interesting. columns_view_internal produces all columns, both stored and view. But the association between column and sequence is at the StoredColumn level. The validator doesn't really understand the object hierarchy, so it lets the join go by, but the MedMdrJoinRel implementation wants to cast the column to FemStoredColumn so that it can call getSequence, hence the ClassCastException.

The best fix would be to change the codegen to generate an instanceof test and return Collections.EMPTY_SET.iterator() when the type doesn't match. The relevant code is MedMdrJoinRelImplementor.generateGetNextRightIterator.

You could achieve the same effect at the SQL level by exposing the column's "mofClassName" attribute in columns_view_internal and adding a filter WHERE "mofClassName"='StoredColumn' pre-join, but then the same problem could come up again later for another view.

I'm assigning this to you, but bounce it to me if you don't feel like writing some more write-only codegen code.

dynamobi-build commented 12 years ago

[author="jpham", created="Wed, 14 Jun 2006 18:26:18 -0500 (GMT-05:00)"] resolved in lu 6911 with an instanceof subclass test