Review Board 1.7.22


SQOOP-467 Add support for Oracle BINARY_FLOAT and BINARY_DOUBLE data types

Review Request #7828 - Created Nov. 1, 2012 and submitted

Cheolsoo Park
trunk
SQOOP-467
Reviewers
Sqoop
jarcec
sqoop-trunk
Re-based my old patch to trunk.
ant test
ant test -Dthridparty=true

I added two test cases - one for BINARY_FLOAT and one for BINARY_DOUBLE - to the OracleCompatTest suite.
src/java/org/apache/sqoop/manager/MySQLManager.java
Revision a3f586a New Change
[20] 272 lines
[+20] [+] protected String getSchemaQuery() {
273
  }
273
  }
274

    
   
274

   
275
  private Map<String, String> colTypeNames;
275
  private Map<String, String> colTypeNames;
276
  private static final int YEAR_TYPE_OVERWRITE = Types.SMALLINT;
276
  private static final int YEAR_TYPE_OVERWRITE = Types.SMALLINT;
277

    
   
277

   
278
  @Override
278
  private int overrideSqlType(String tableName, String columnName,
279
  public String toJavaType(String tableName, String columnName, int sqlType) {
279
      int sqlType) {
280
    if (colTypeNames == null) {
280
    if (colTypeNames == null) {
281
      colTypeNames = getColumnTypeNames(tableName, options.getSqlQuery());
281
      colTypeNames = getColumnTypeNames(tableName, options.getSqlQuery());
282
    }
282
    }
283

    
   
283

   
284
    if ("YEAR".equalsIgnoreCase(colTypeNames.get(columnName))) {
284
    if ("YEAR".equalsIgnoreCase(colTypeNames.get(columnName))) {
285
      sqlType = YEAR_TYPE_OVERWRITE;
285
      sqlType = YEAR_TYPE_OVERWRITE;
286
    }
286
    }

    
   
287
    return sqlType;

    
   
288
  }
287

    
   
289

   

    
   
290
  @Override

    
   
291
  public String toJavaType(String tableName, String columnName, int sqlType) {

    
   
292
    sqlType = overrideSqlType(tableName, columnName, sqlType);
288
    return super.toJavaType(tableName, columnName, sqlType);
293
    return super.toJavaType(tableName, columnName, sqlType);
289
  }
294
  }
290

    
   
295

   
291
  @Override
296
  @Override
292
  public String toHiveType(String tableName, String columnName, int sqlType) {
297
  public String toHiveType(String tableName, String columnName, int sqlType) {
293
    if (colTypeNames == null) {
298
    sqlType = overrideSqlType(tableName, columnName, sqlType);
294
      colTypeNames = getColumnTypeNames(tableName, options.getSqlQuery());

   
295
    }

   
296

    
   

   
297
    if ("YEAR".equalsIgnoreCase(colTypeNames.get(columnName))) {

   
298
      sqlType = YEAR_TYPE_OVERWRITE;

   
299
    }

   
300

    
   

   
301
    return super.toHiveType(tableName, columnName, sqlType);
299
    return super.toHiveType(tableName, columnName, sqlType);
302
  }
300
  }
303

    
   
301

   
304
  @Override
302
  @Override
305
  public Type toAvroType(String tableName, String columnName, int sqlType) {
303
  public Type toAvroType(String tableName, String columnName, int sqlType) {
306
    if (colTypeNames == null) {
304
    sqlType = overrideSqlType(tableName, columnName, sqlType);
307
      colTypeNames = getColumnTypeNames(tableName, options.getSqlQuery());

   
308
    }

   
309

    
   

   
310
    if ("YEAR".equalsIgnoreCase(colTypeNames.get(columnName))) {

   
311
      sqlType = YEAR_TYPE_OVERWRITE;

   
312
    }

   
313

    
   

   
314
    return super.toAvroType(tableName, columnName, sqlType);
305
    return super.toAvroType(tableName, columnName, sqlType);
315
  }
306
  }
316
}
307
}
317

    
   
308

   
src/java/org/apache/sqoop/manager/OracleManager.java
Revision 6974e1b New Change
 
src/test/com/cloudera/sqoop/manager/OracleCompatTest.java
Revision 309a960 New Change
 
  1. src/java/org/apache/sqoop/manager/MySQLManager.java: Loading...
  2. src/java/org/apache/sqoop/manager/OracleManager.java: Loading...
  3. src/test/com/cloudera/sqoop/manager/OracleCompatTest.java: Loading...