sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cheol...@apache.org
Subject git commit: SQOOP-820: Escape table name in export job only if it's required by connector
Date Tue, 08 Jan 2013 18:08:20 GMT
Updated Branches:
  refs/heads/trunk 7573450e1 -> b02ddc397


SQOOP-820: Escape table name in export job only if it's required by connector

(Jarek Jarcec Cecho via Cheolsoo Park)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/b02ddc39
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/b02ddc39
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/b02ddc39

Branch: refs/heads/trunk
Commit: b02ddc39757771fb387c2688ccd0cee74cf6032c
Parents: 7573450
Author: Cheolsoo Park <cheolsoo@apache.org>
Authored: Tue Jan 8 10:06:56 2013 -0800
Committer: Cheolsoo Park <cheolsoo@apache.org>
Committed: Tue Jan 8 10:06:56 2013 -0800

----------------------------------------------------------------------
 src/java/org/apache/sqoop/manager/ConnManager.java |   10 ++++++++++
 .../apache/sqoop/manager/PostgresqlManager.java    |    5 +++++
 .../org/apache/sqoop/manager/SQLServerManager.java |    5 +++++
 .../org/apache/sqoop/mapreduce/JdbcExportJob.java  |    7 ++++++-
 4 files changed, 26 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/b02ddc39/src/java/org/apache/sqoop/manager/ConnManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/manager/ConnManager.java b/src/java/org/apache/sqoop/manager/ConnManager.java
index 21eea93..115186f 100644
--- a/src/java/org/apache/sqoop/manager/ConnManager.java
+++ b/src/java/org/apache/sqoop/manager/ConnManager.java
@@ -451,6 +451,16 @@ public abstract class ConnManager {
   }
 
   /**
+   * Return true if Sqoop common code should automatically escape table name
+   * when saving it to mapreduce configuration object when during export.
+   *
+   * @return True if table name should be escaped
+   */
+  public boolean escapeTableNameOnExport() {
+    return false;
+  }
+
+  /**
    * Perform any shutdown operations on the connection.
    */
   public abstract void close() throws SQLException;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b02ddc39/src/java/org/apache/sqoop/manager/PostgresqlManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/manager/PostgresqlManager.java b/src/java/org/apache/sqoop/manager/PostgresqlManager.java
index 7e6284e..facdc74 100644
--- a/src/java/org/apache/sqoop/manager/PostgresqlManager.java
+++ b/src/java/org/apache/sqoop/manager/PostgresqlManager.java
@@ -81,6 +81,11 @@ public class PostgresqlManager
     return escapeIdentifier(tableName);
   }
 
+  @Override
+  public boolean escapeTableNameOnExport() {
+    return true;
+  }
+
   protected String escapeIdentifier(String identifier) {
     if (identifier == null) {
       return null;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b02ddc39/src/java/org/apache/sqoop/manager/SQLServerManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/manager/SQLServerManager.java b/src/java/org/apache/sqoop/manager/SQLServerManager.java
index 0c39599..ed9eaf8 100644
--- a/src/java/org/apache/sqoop/manager/SQLServerManager.java
+++ b/src/java/org/apache/sqoop/manager/SQLServerManager.java
@@ -157,6 +157,11 @@ public class SQLServerManager
     return escapeObjectName(tableName);
   }
 
+  @Override
+  public boolean escapeTableNameOnExport() {
+    return true;
+  }
+
   /**
    * Escape database object name (database, table, column, schema).
    *

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b02ddc39/src/java/org/apache/sqoop/mapreduce/JdbcExportJob.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/mapreduce/JdbcExportJob.java b/src/java/org/apache/sqoop/mapreduce/JdbcExportJob.java
index 7c52110..00bd910 100644
--- a/src/java/org/apache/sqoop/mapreduce/JdbcExportJob.java
+++ b/src/java/org/apache/sqoop/mapreduce/JdbcExportJob.java
@@ -129,7 +129,12 @@ public class JdbcExportJob extends ExportJobBase {
       if (null == colNames) {
         colNames = mgr.getColumnNames(tableName);
       }
-      DBOutputFormat.setOutput(job, mgr.escapeTableName(tableName), colNames);
+
+      if (mgr.escapeTableNameOnExport()) {
+        DBOutputFormat.setOutput(job, mgr.escapeTableName(tableName), colNames);
+      } else {
+        DBOutputFormat.setOutput(job, tableName, colNames);
+      }
 
       job.setOutputFormatClass(getOutputFormatClass());
       job.getConfiguration().set(SQOOP_EXPORT_TABLE_CLASS_KEY, tableClassName);


Mime
View raw message