SQOOP-2607: Direct import from Netezza and encoding

(Benjamin BONNET via Jarek Jarcec Cecho)
diff --git a/src/java/org/apache/sqoop/manager/DirectNetezzaManager.java b/src/java/org/apache/sqoop/manager/DirectNetezzaManager.java
index 2ec0770..af15824 100644
--- a/src/java/org/apache/sqoop/manager/DirectNetezzaManager.java
+++ b/src/java/org/apache/sqoop/manager/DirectNetezzaManager.java
@@ -81,6 +81,10 @@
   public static final String NETEZZA_TRUNC_STRING_LONG_ARG =
       "trunc-string";
 
+  public static final String NETEZZA_TABLE_ENCODING_OPT =
+      "netezza.table.encoding";
+  public static final String NETEZZA_TABLE_ENCODING_LONG_ARG =
+      "encoding";
 
 
   private static final String QUERY_CHECK_DICTIONARY_FOR_TABLE =
@@ -286,6 +290,9 @@
     netezzaOpts.addOption(OptionBuilder.withArgName(NETEZZA_IGNORE_ZERO_OPT)
       .withDescription("Truncate string to declared storage size")
       .withLongOpt(NETEZZA_IGNORE_ZERO_LONG_ARG).create());
+    netezzaOpts.addOption(OptionBuilder.withArgName(NETEZZA_TABLE_ENCODING_OPT)
+        .hasArg().withDescription("Table encoding")
+        .withLongOpt(NETEZZA_TABLE_ENCODING_LONG_ARG).create());
     return netezzaOpts;
   }
 
@@ -307,7 +314,12 @@
       String dir = cmdLine.getOptionValue(NETEZZA_LOG_DIR_LONG_ARG);
       conf.set(NETEZZA_LOG_DIR_OPT, dir);
     }
-
+    if (cmdLine.hasOption(NETEZZA_TABLE_ENCODING_LONG_ARG)) {
+      String encoding = cmdLine
+          .getOptionValue(NETEZZA_TABLE_ENCODING_LONG_ARG);
+      conf.set(NETEZZA_TABLE_ENCODING_OPT, encoding);
+    }
+    
     conf.setBoolean(NETEZZA_CTRL_CHARS_OPT,
       cmdLine.hasOption(NETEZZA_CTRL_CHARS_LONG_ARG));
 
diff --git a/src/java/org/apache/sqoop/mapreduce/db/netezza/NetezzaExternalTableImportMapper.java b/src/java/org/apache/sqoop/mapreduce/db/netezza/NetezzaExternalTableImportMapper.java
index 939e358..2efea53 100644
--- a/src/java/org/apache/sqoop/mapreduce/db/netezza/NetezzaExternalTableImportMapper.java
+++ b/src/java/org/apache/sqoop/mapreduce/db/netezza/NetezzaExternalTableImportMapper.java
@@ -184,8 +184,10 @@
     extTableThread.start();
     // We need to start the reader end first
 
+    final String encoding = conf
+        .get(DirectNetezzaManager.NETEZZA_TABLE_ENCODING_OPT);
     recordReader = new BufferedReader(new InputStreamReader(
-      new FileInputStream(nf.getFile())));
+      new FileInputStream(nf.getFile()), (null == encoding ? "UTF-8" : encoding)));
   }
 
   abstract protected void writeRecord(Text text, Context context)