[ 
https://issues.apache.org/jira/browse/SQOOP-2018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14280477#comment-14280477
 ] 

Veena Basavaraj commented on SQOOP-2018:
----------------------------------------

The real issue is how JDBC Connector is sending a LONG object in the object 
array when the schema says it is an Integer. ( Qian and I both agree on this, 
since we had a offline discussion)

So the fix needs to be done in extractor and loader to do this check and  
investigate why this code is sending a long
{code}
   while (resultSet.next()) {
        Object[] array = new Object[columnCount];
        for (int i = 0; i < columnCount; i++) {
          // check type of the column
          Column schemaColumn = schemaColumns[i];
          if(resultSet.getObject(i + 1) == null) {
            array[i] = GenericJdbcConnectorConstants.SQL_NULL_VALUE ;
            continue;
          }
          switch (schemaColumn.getType()) {
          case DATE:
            // convert the sql date to JODA time as prescribed the Sqoop IDF 
spec
            array[i] = 
LocalDate.fromDateFields((java.sql.Date)resultSet.getObject(i + 1));
            break;
          case DATE_TIME:
            // convert the sql date time to JODA time as prescribed the Sqoop 
IDF spec
            array[i] = 
LocalDateTime.fromDateFields((java.sql.Timestamp)resultSet.getObject(i + 1));
            break;
          case TIME:
            // convert the sql time to JODA time as prescribed the Sqoop IDF 
spec
            array[i] = 
LocalTime.fromDateFields((java.sql.Time)resultSet.getObject(i + 1));
            break;
          case FIXED_POINT:
            // todo
            break;
          default:
            //for anything else
            array[i] = resultSet.getObject(i + 1);

          }
        }
        context.getDataWr

{code}

Also I found another issue with how jdbc connector sets null objects

> GenericJDBCConnector SqlTypes INTEGER should be set 4 bytes
> -----------------------------------------------------------
>
>                 Key: SQOOP-2018
>                 URL: https://issues.apache.org/jira/browse/SQOOP-2018
>             Project: Sqoop
>          Issue Type: Bug
>            Reporter: Veena Basavaraj
>            Assignee: Veena Basavaraj
>             Fix For: 1.99.5
>
>         Attachments: SQOOP-2018-take2patch, SQOOP-2018.patch
>
>
> treat INT as 4 bytes since both MySQL and Oracle and Postgres do it so
> http://dev.mysql.com/doc/refman/5.0/en/integer-types.html
> https://docs.oracle.com/cd/E17952_01/refman-5.5-en/storage-requirements.html
> http://www.postgresql.org/docs/9.1/static/datatype-numeric.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to