[teiid-issues] [JBoss JIRA] (TEIID-5116) Osisoft Translator - NULL values in numeric columns returned as zeroes

Ramesh Reddy (JIRA) issues at jboss.org
Tue Oct 24 12:29:00 EDT 2017


    [ https://issues.jboss.org/browse/TEIID-5116?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13481369#comment-13481369 ] 

Ramesh Reddy commented on TEIID-5116:
-------------------------------------

Using code above the following should do the trick

{code}
    @Override
    public Object retrieveValue(ResultSet results, int columnIndex, Class<?> expectedType) throws SQLException {
    	Object result = results.getObject(columnIndex);
    	if (result == null) {
    		return null;
    	}
    	return super.retrieveValue(results, columnIndex, expectedType);
    }
{code}

> Osisoft Translator - NULL values in numeric columns returned as zeroes
> ----------------------------------------------------------------------
>
>                 Key: TEIID-5116
>                 URL: https://issues.jboss.org/browse/TEIID-5116
>             Project: Teiid
>          Issue Type: Bug
>          Components: JDBC Connector
>    Affects Versions: 8.12.x-6.4
>            Reporter: Andrej Šmigala
>            Assignee: Ramesh Reddy
>            Priority: Critical
>
> NULL values in columns with a numeric type (all of int8, int16 etc, single, double) are returned as 0.
> This is due to a bug/quirk of the Osisoft PI JDBC driver, which is hard-coded to return false from the wasNull method.
> On the Teiid side, the code in JDBCExecutionFactory.retrieveValue() assumes (completely reasonably) that the wasNull method is implemented correctly:
> {code:java}
> case DataTypeManager.DefaultTypeCodes.INTEGER:  {
>     int value = results.getInt(columnIndex);                    
>     if(results.wasNull()) {
>         return null;
>     }
>     return Integer.valueOf(value);
> }
> {code}
> I managed to workaround the bug in the PI JDBC driver by overriding the retrieveValue() in PIExecutionFactory and replacing the calls to wasNull like this:
> {code:java}
> case DataTypeManager.DefaultTypeCodes.INTEGER: {
>     int value = results.getInt(columnIndex);
>     if (results.getObject(columnIndex) == null) {
>         return null;
>     }
>     return Integer.valueOf(value);
> }
> {code}
> but that probably isn't the best solution.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)



More information about the teiid-issues mailing list