Review Board 1.7.22


SQOOP-1149: Support custom postgres types (e.g. inet for IP addresses) - which includes postgres enums.

Review Request #12949 - Created July 25, 2013 and updated

Nick White
Reviewers
Sqoop
sqoop-trunk
The patch adds a PostgresqlExportJob that replaces the OutputFormat (if needed) with a PostgresqlExportOutputFormat that inserts casts into the generated SQL statement (e.g. insert into mytable values (?, ?::inet, ?)). The patch also consolidates the various functions on ConnManager that return SQL type ints and type names into just one for each. This means the chunks of code in various parts of the codebase that select which of the three (former) methods to call can be replaced with a single call - and the call "routing" logic only appears in one place (ConnManager).
I've added two cases to PostgresqlExportTest and tested them against a 9.3 database.
src/java/com/cloudera/sqoop/lib/JdbcWritableBridge.java
Revision 316547f New Change
[20] 104 lines
[+20] [+] public static BlobRef readBlobRef(int colNum, ResultSet r)
105
  public static ClobRef readClobRef(int colNum, ResultSet r)
105
  public static ClobRef readClobRef(int colNum, ResultSet r)
106
      throws SQLException {
106
      throws SQLException {
107
    return org.apache.sqoop.lib.JdbcWritableBridge.readClobRef(colNum, r);
107
    return org.apache.sqoop.lib.JdbcWritableBridge.readClobRef(colNum, r);
108
  }
108
  }
109

    
   
109

   

    
   
110
  public static Object readObject(int colNum, ResultSet r)

    
   
111
      throws SQLException {

    
   
112
    return org.apache.sqoop.lib.JdbcWritableBridge.readObject(colNum, r);

    
   
113
  }

    
   
114

   
110
  public static void writeInteger(Integer val, int paramIdx, int sqlType,
115
  public static void writeInteger(Integer val, int paramIdx, int sqlType,
111
      PreparedStatement s) throws SQLException {
116
      PreparedStatement s) throws SQLException {
112
    org.apache.sqoop.lib.JdbcWritableBridge.writeInteger(
117
    org.apache.sqoop.lib.JdbcWritableBridge.writeInteger(
113
        val, paramIdx, sqlType, s);
118
        val, paramIdx, sqlType, s);
114
  }
119
  }
[+20] [20] 67 lines
[+20] [+] public static void writeBlobRef(BlobRef val, int paramIdx,
182
  public static void writeClobRef(ClobRef val, int paramIdx,
187
  public static void writeClobRef(ClobRef val, int paramIdx,
183
      int sqlType, PreparedStatement s) throws SQLException {
188
      int sqlType, PreparedStatement s) throws SQLException {
184
    org.apache.sqoop.lib.JdbcWritableBridge.writeClobRef(
189
    org.apache.sqoop.lib.JdbcWritableBridge.writeClobRef(
185
        val, paramIdx, sqlType, s);
190
        val, paramIdx, sqlType, s);
186
  }
191
  }

    
   
192

   

    
   
193
  public static void writeObject(Object val, int paramIdx,

    
   
194
      int sqlType, PreparedStatement s) throws SQLException {

    
   
195
      org.apache.sqoop.lib.JdbcWritableBridge.writeObject(

    
   
196
          val, paramIdx, sqlType, s);

    
   
197
  }
187
}
198
}
src/java/org/apache/sqoop/lib/JdbcWritableBridge.java
Revision afde585 New Change
 
src/java/org/apache/sqoop/manager/ConnManager.java
Revision f4b22f9 New Change
 
src/java/org/apache/sqoop/manager/PostgresqlManager.java
Revision bd882b9 New Change
 
src/java/org/apache/sqoop/orm/ClassWriter.java
Revision 1bd2a41 New Change
 
src/test/com/cloudera/sqoop/manager/PostgresqlExportTest.java
Revision 0ac4599 New Change
 
  1. src/java/com/cloudera/sqoop/lib/JdbcWritableBridge.java: Loading...
  2. src/java/org/apache/sqoop/lib/JdbcWritableBridge.java: Loading...
  3. src/java/org/apache/sqoop/manager/ConnManager.java: Loading...
  4. src/java/org/apache/sqoop/manager/PostgresqlManager.java: Loading...
  5. src/java/org/apache/sqoop/orm/ClassWriter.java: Loading...
  6. src/test/com/cloudera/sqoop/manager/PostgresqlExportTest.java: Loading...