Open chubbard opened 7 years ago
I've looked into this further, and I don't think it's a driver problem. I've tried looking at the metadata returned from the driver from issuing both ResultSet.getMetaData(), and Connection.getMetaData().getColumns() method. Both agree the JDBC data type of a Float column in Mysql is a JDBC type of REAL. I checked the Mondrian code and it appears that in JdbcSchema it does associate Types.REAL with NUMERIC, but it's missing from JdbcDialectImpl which explains why it works for using the <Table>
element, but NOT <Query>
.
Did you know what in the JDBC spec, FLOAT is a 64 bit floating point (and likewise java.sql.Types.FLOAT)? A lot of people assume that it is a 32 bit floating point. (REAL is 32 bit floating point, and DOUBLE is, like FLOAT, a 64 bit floating point.)
MySQL's FLOAT column is a 32 bit floating point. Let's assume that their driver exposes FLOAT columns as JDBC type REAL, as it should.
In which case, I'm not sure where JDBC FLOAT columns are coming from, but we should treat them exactly the same as we handle JDBC DOUBLE columns.
In trying to work around this problem with Mondrian I tried changing my columns to Mysql Doubles, but it still reported them as Types.REAL which is strange. I'm assuming FLOAT, DOUBLE, and REAL should all be treated the same way to Mondrian. In JdbcSchema.getDatatype() it does exactly that and that's why I felt the case ladder in JdbcDialectImpl was missing the case statement for REAL.
So under what conditions will Mysql return Types.FLOAT? I don't think it will return FLOAT ever since from the JDBC docs it says "The JDBC type FLOAT is basically equivalent to the JDBC type DOUBLE. We provided both FLOAT and DOUBLE in a possibly misguided attempt at consistency with previous database APIs..." So they basically admit it was bit of screw up on their part to provide both Float and Double.
Using the mysql driver and a table with a column of Mysql Float value type. Mondrian doesn't recognize the data type because the mysql driver is returning a REAL data type when used in a Query. Exception being thrown:
In the schema the following was done:
On RolapSchema:1030 the following call returns null:
But start on JdbcDialectImpl:1136 this switch doesn't recognize Types.REAL
The Types.REAL is missing causing the null to be returned. It should be changed to:
Other things I've tried to work around it:
Add a mysql dialect query to it. That didn't work.
Changing MySQL FLOAT -> MySQL DOUBLE. Nope.
Update the Driver. It could be a driver issue because if you use Table instead of Query in the PhysicalSchema it works. But I have to limit things by account_id so I have to have the Query option working. It's easy to push this off on the driver, BUT