sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2723: Oracle connector not working with lowercase columns
Date Tue, 08 Dec 2015 13:28:16 GMT
Repository: sqoop
Updated Branches:
  refs/heads/trunk 77021d2a6 -> 203d6b726


SQOOP-2723: Oracle connector not working with lowercase columns

(David Robson via Jarek Jarcec Cecho)


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

Branch: refs/heads/trunk
Commit: 203d6b7267e399c282ed9b645b77012879c987bc
Parents: 77021d2
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Tue Dec 8 14:27:39 2015 +0100
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Tue Dec 8 14:27:39 2015 +0100

----------------------------------------------------------------------
 src/docs/user/connectors.txt                    |  7 +++++++
 .../sqoop/manager/oracle/OraOopConnManager.java |  2 +-
 .../manager/oracle/OraOopOracleQueries.java     | 20 ++++++++++----------
 .../manager/oracle/OraOopOutputFormatBase.java  |  2 +-
 4 files changed, 19 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/203d6b72/src/docs/user/connectors.txt
----------------------------------------------------------------------
diff --git a/src/docs/user/connectors.txt b/src/docs/user/connectors.txt
index c5ce4d6..7c54071 100644
--- a/src/docs/user/connectors.txt
+++ b/src/docs/user/connectors.txt
@@ -1743,6 +1743,13 @@ $ +sqoop import ... --table customers --columns "\"\"first name\"\""+
 +
 This is the equivalent of: `select "first name" from customers`
 
+If multiple columns need to be quoted, use::
+$ +sqoop import ... --table customers --columns "\"\"first name\",\"last
+name\",\"region name\"\""+
++
+This is the equivalent of: `select "first name", "last name", "region name"
+from customers`
+
 Confirm The Data Connector for Oracle and Hadoop Can Initialize The Oracle Session
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/203d6b72/src/java/org/apache/sqoop/manager/oracle/OraOopConnManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/manager/oracle/OraOopConnManager.java b/src/java/org/apache/sqoop/manager/oracle/OraOopConnManager.java
index 55a2b4c..9d74625 100644
--- a/src/java/org/apache/sqoop/manager/oracle/OraOopConnManager.java
+++ b/src/java/org/apache/sqoop/manager/oracle/OraOopConnManager.java
@@ -544,7 +544,7 @@ public class OraOopConnManager extends GenericJdbcManager {
   @Override
   public String escapeColName(String colName) {
 
-    return super.escapeColName(colName); // <- See notes at top about escaped
+    return escapeOracleColumnName(colName); // <- See notes at top about escaped
                                          // column names
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/203d6b72/src/java/org/apache/sqoop/manager/oracle/OraOopOracleQueries.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/manager/oracle/OraOopOracleQueries.java b/src/java/org/apache/sqoop/manager/oracle/OraOopOracleQueries.java
index ea64c6d..82e4266 100644
--- a/src/java/org/apache/sqoop/manager/oracle/OraOopOracleQueries.java
+++ b/src/java/org/apache/sqoop/manager/oracle/OraOopOracleQueries.java
@@ -680,7 +680,7 @@ public final class OraOopOracleQueries {
       if (idx > 0) {
         columnList.append(",");
       }
-      columnList.append(result.get(idx).getName());
+      columnList.append("\"").append(result.get(idx).getName()).append("\"");
     }
     sql =
         String.format("SELECT %s FROM %s WHERE 0=1", columnList.toString(),
@@ -1176,12 +1176,12 @@ public final class OraOopOracleQueries {
       if (insertClause.length() > 0) {
         insertClause.append(",");
       }
-      insertClause.append(String.format("target.%s", columnName));
+      insertClause.append(String.format("target.\"%s\"", columnName));
 
       if (valuesClause.length() > 0) {
         valuesClause.append(",");
       }
-      valuesClause.append(String.format("source.%s", columnName));
+      valuesClause.append(String.format("source.\"%s\"", columnName));
 
       if (!OraOopUtilities.stringArrayContains(mergeColumnNames, columnName,
           true)) {
@@ -1199,7 +1199,7 @@ public final class OraOopOracleQueries {
           if (updateClause.length() > 0) {
             updateClause.append(",");
           }
-          updateClause.append(String.format("target.%1$s = source.%1$s",
+          updateClause.append(String.format("target.\"%1$s\" = source.\"%1$s\"",
               columnName));
 
         }
@@ -1244,12 +1244,12 @@ public final class OraOopOracleQueries {
       if (targetColumnsClause.length() > 0) {
         targetColumnsClause.append(",");
       }
-      targetColumnsClause.append(String.format("a.%s", columnName));
+      targetColumnsClause.append(String.format("a.\"%s\"", columnName));
 
       if (sourceColumnsClause.length() > 0) {
         sourceColumnsClause.append(",");
       }
-      sourceColumnsClause.append(String.format("b.%s", columnName));
+      sourceColumnsClause.append(String.format("b.\"%s\"", columnName));
     }
 
     String sourceClause = sourceColumnsClause.toString();
@@ -1313,7 +1313,7 @@ public final class OraOopOracleQueries {
       if (idx > 0) {
         columnClause.append(",");
       }
-      columnClause.append("a." + columnNames.get(idx));
+      columnClause.append("a.\"" + columnNames.get(idx) + "\"");
     }
 
     StringBuilder rowEqualityClause = new StringBuilder();
@@ -1339,9 +1339,9 @@ public final class OraOopOracleQueries {
         rowEqualityClause.append("OR");
       }
 
-      rowEqualityClause.append(String.format("(a.%1$s <> b.%1$s "
-          + "OR (a.%1$s IS NULL AND b.%1$s IS NOT NULL) "
-          + "OR (a.%1$s IS NOT NULL AND b.%1$s IS NULL))", columnName));
+      rowEqualityClause.append(String.format("(a.\"%1$s\" <> b.\"%1$s\" "
+          + "OR (a.\"%1$s\" IS NULL AND b.\"%1$s\" IS NOT NULL) "
+          + "OR (a.\"%1$s\" IS NOT NULL AND b.\"%1$s\" IS NULL))", columnName));
     }
 
     String sqlJoin = null;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/203d6b72/src/java/org/apache/sqoop/manager/oracle/OraOopOutputFormatBase.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/manager/oracle/OraOopOutputFormatBase.java b/src/java/org/apache/sqoop/manager/oracle/OraOopOutputFormatBase.java
index 7c4d1c5..8f7016a 100644
--- a/src/java/org/apache/sqoop/manager/oracle/OraOopOutputFormatBase.java
+++ b/src/java/org/apache/sqoop/manager/oracle/OraOopOutputFormatBase.java
@@ -354,7 +354,7 @@ abstract class OraOopOutputFormatBase<K extends SqoopRecord, V>
extends
         if (colCount > 0) {
           sqlNames.append("\n,");
         }
-        sqlNames.append(columnName);
+        sqlNames.append("\"").append(columnName).append("\"");
 
         // column values...
         if (colCount > 0) {


Mime
View raw message