sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject sqoop git commit: SQOOP-2250: Sqoop2: SQ_LINK_INPUT is missing a foreign key constraint
Date Tue, 31 Mar 2015 18:11:52 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 816374bd0 -> a3362a256


SQOOP-2250: Sqoop2: SQ_LINK_INPUT is missing a foreign key constraint

(Veena Basavaraj via Abraham Elmahrek)


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

Branch: refs/heads/sqoop2
Commit: a3362a2563c03f10f221002753b6d08b0d21f378
Parents: 816374b
Author: Abraham Elmahrek <abe@apache.org>
Authored: Tue Mar 31 10:45:06 2015 -0700
Committer: Abraham Elmahrek <abe@apache.org>
Committed: Tue Mar 31 11:11:22 2015 -0700

----------------------------------------------------------------------
 .../repository/common/CommonRepositoryHandler.java      |  2 --
 .../CommonRepositoryInsertUpdateDeleteSelectQuery.java  |  2 --
 .../sqoop/repository/derby/DerbyRepoConstants.java      |  3 ++-
 .../sqoop/repository/derby/DerbyRepositoryHandler.java  |  6 +++++-
 .../sqoop/repository/derby/DerbySchemaUpgradeQuery.java |  4 ++++
 .../apache/sqoop/repository/derby/DerbyTestCase.java    | 12 +++++++++---
 6 files changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3362a25/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
index 6d076d6..b648d4d 100644
--- a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
+++ b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
@@ -1638,7 +1638,6 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler
{
 
         connectorConfigFetchStatement.setLong(1, connectorId);
         connectorConfigInputStatement.setLong(1, id);
-        connectorConfigInputStatement.setLong(3, id);
 
         List<MConfig> connectorLinkConfig = new ArrayList<MConfig>();
         List<MConfig> fromConfig = new ArrayList<MConfig>();
@@ -1704,7 +1703,6 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler
{
         driverConfigfetchStmt.setLong(1, driverId);
 
         jobInputFetchStmt.setLong(1, id);
-        jobInputFetchStmt.setLong(3, id);
 
         // FROM entity configs
         List<MConfig> fromConnectorLinkConfig = new ArrayList<MConfig>();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3362a25/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
index 3dbad01..43fabb4 100644
--- a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
+++ b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
@@ -213,7 +213,6 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
           + " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_INPUT) + " = " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID)
           + " AND " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + " = ?"
           + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + " = ?"
-          + " AND (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + " = ?" + "
OR " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + " IS NULL)"
           + " ORDER BY " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_INDEX);
 
   /**
@@ -237,7 +236,6 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
           + " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_INPUT) + " = " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID)
           + " AND  " + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + " = ?"
           + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + " = ?"
-          + " AND (" + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + " = ? OR " + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB)
+ " IS NULL)"
           + " ORDER BY " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_INDEX);
 
   /**

http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3362a25/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoConstants.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoConstants.java
b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoConstants.java
index 4e1efc2..4141434 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoConstants.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoConstants.java
@@ -43,8 +43,9 @@ public final class DerbyRepoConstants {
    * 4 - Version 1.99.4
    *     Changed to FROM/TO design.
    * 5 - Version 1.99.5
+   * 6 - Version 1.99.6
    */
-  public static final int LATEST_DERBY_REPOSITORY_VERSION = 5;
+  public static final int LATEST_DERBY_REPOSITORY_VERSION = 6;
 
   private DerbyRepoConstants() {
     // Disable explicit object creation

http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3362a25/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
index 7af912d..fc1a4b5 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
@@ -299,7 +299,7 @@ public class DerbyRepositoryHandler extends CommonRepositoryHandler {
         derbyUpgradeGenericJdbcConnectorConfigAndInputNames.execute();
       }
     }
-
+    // 1.99.5 release changes
     if (repositoryVersion < 5) {
       runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_ADD_UNIQUE_CONSTRAINT_NAME_TYPE_AND_CONFIGURABLE_ID,
conn);
       runQuery(QUERY_UPGRADE_TABLE_SQ_INPUT_ADD_UNIQUE_CONSTRAINT_NAME_TYPE_AND_CONFIG_ID,
conn);
@@ -311,6 +311,10 @@ public class DerbyRepositoryHandler extends CommonRepositoryHandler {
       // create a new table for SQ_INPUT relationships
       runQuery(QUERY_CREATE_TABLE_SQ_INPUT_RELATION, conn);
     }
+    // 1.99.6 release changes
+    if (repositoryVersion < 6) {
+      runQuery(QUERY_UPGRADE_ADD_TABLE_SQ_LINK_INPUT_CONSTRAINT_2, conn);
+    }
 
     // last step upgrade the repository version to the latest value in the code
     upgradeRepositoryVersion(conn);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3362a25/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
index 662da9f..bcdb8d8 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
@@ -325,6 +325,10 @@ public final class DerbySchemaUpgradeQuery {
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_INPUT_NAME) + " ADD CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_LNKI_SQ_LNK_NAME) + " "
       + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + ") " +
"REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " ("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID) + ")";
+  public static final String QUERY_UPGRADE_ADD_TABLE_SQ_LINK_INPUT_CONSTRAINT_2 = "ALTER
TABLE "
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_INPUT_NAME) + " ADD CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_LNKI_SQI_NAME) + " "
+      + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_INPUT) + ") " +
"REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + " ("
+      + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + ")";
 
   // table rename for FORM-> CONFIG
   public static final String QUERY_UPGRADE_DROP_TABLE_SQ_FORM_CONSTRAINT = "ALTER TABLE "

http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3362a25/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
index 5093d11..fea77ba 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
@@ -220,6 +220,8 @@ abstract public class DerbyTestCase {
       // SQOOP-1804
       runQuery(QUERY_UPGRADE_TABLE_SQ_INPUT_ADD_COLUMN_SQI_EDITABLE);
       runQuery(QUERY_CREATE_TABLE_SQ_INPUT_RELATION);
+      runQuery(QUERY_UPGRADE_ADD_TABLE_SQ_LINK_INPUT_CONSTRAINT_2);
+
     }
 
     // deprecated repository version
@@ -523,7 +525,7 @@ abstract public class DerbyTestCase {
     // Connector job (TO) config: 8-11
     // Driver JOB config: 12-15
     for (int i = 0; i < 4; i++) {
-      // First config
+      // First config inputs with config ids 1,3, 5, 7
       runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
           + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH, SQI_EDITABLE)"
           + " VALUES('I1', " + (i * 2 + 1) + ", 0, 'STRING', false, 30, 'USER_ONLY')");
@@ -531,7 +533,7 @@ abstract public class DerbyTestCase {
           + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH, SQI_EDITABLE)"
           + " VALUES('I2', " + (i * 2 + 1) + ", 1, 'MAP', false, 30, 'CONNECTOR_ONLY')");
 
-      // Second config
+      // Second config inputs with config ids 2, 4,,6 8
       runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
           + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH, SQI_EDITABLE)"
           + " VALUES('I3', " + (i * 2 + 2) + ", 0, 'STRING', false, 30, 'USER_ONLY')");
@@ -556,6 +558,7 @@ abstract public class DerbyTestCase {
 
     case 4:
     case 5:
+    case 6:
       loadConnectorAndDriverConfigVersion4();
       break;
 
@@ -583,7 +586,7 @@ abstract public class DerbyTestCase {
       runQuery("INSERT INTO SQOOP.SQ_CONNECTION(SQN_NAME, SQN_CONNECTOR) " + "VALUES('CB',
1)");
 
       for (String ci : new String[] { "1", "2" }) {
-        for (String i : new String[] { "1", "3", "13", "15" }) {
+        for (String i : new String[] { "1", "3", "15" }) {
           runQuery("INSERT INTO SQOOP.SQ_CONNECTION_INPUT"
               + "(SQNI_CONNECTION, SQNI_INPUT, SQNI_VALUE) " + "VALUES(" + ci + ", " + i
               + ", 'Value" + i + "')");
@@ -593,7 +596,9 @@ abstract public class DerbyTestCase {
 
     case 4:
     case 5:
+    case 6:
       // Insert two links - CA and CB
+      // Connector 1 has one link config
       runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONFIGURABLE) " + "VALUES('CA',
1)");
       runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONFIGURABLE) " + "VALUES('CB',
1)");
 
@@ -652,6 +657,7 @@ abstract public class DerbyTestCase {
 
     case 4:
     case 5:
+    case 6:
       for (String name : new String[] { "JA", "JB", "JC", "JD" }) {
         runQuery("INSERT INTO SQOOP.SQ_JOB(SQB_NAME, SQB_FROM_LINK, SQB_TO_LINK)" + " VALUES('"
             + name + index + "', 1, 1)");


Mime
View raw message