Uploaded image for project: 'Sqoop (Retired)'
  1. Sqoop (Retired)
  2. SQOOP-585

Bug when sqoop a join of two tables with the same column name with mysql backend

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.4.4
    • 1.4.5
    • connectors/sqlserver

    Description

      I get this error when I run the command:

      INFO: Executing SQL statement: SELECT events.*, square_applications.name as square_application, user_agents.name as user_agent from events LEFT JOIN square_applications on events.square_application_id=square_applications.id LEFT JOIN user_agents on events.user_agent_id=user_agents.id where (1 = 0)
      Aug 23, 2012 10:10:56 AM org.apache.sqoop.tool.ImportTool run
      SEVERE: Imported Failed: Duplicate Column identifier specified: 'name'

      Calling "getColumnLabel" instead of "getColumnName" in SqlManager.java fixes this problem and this still works in postgres as well as mysql. Here is my patch:

      Index: src/java/org/apache/sqoop/manager/SqlManager.java
      ===================================================================
      — src/java/org/apache/sqoop/manager/SqlManager.java (revision 1375124)
      +++ src/java/org/apache/sqoop/manager/SqlManager.java (working copy)
      @@ -135,9 +135,9 @@
      ArrayList<String> columns = new ArrayList<String>();
      ResultSetMetaData metadata = results.getMetaData();
      for (int i = 1; i < cols + 1; i++) {

      • String colName = metadata.getColumnName;
        + String colName = metadata.getColumnLabel;
        if (colName == null || colName.equals("")) {
      • colName = metadata.getColumnLabel;
        + colName = metadata.getColumnName;
        if (null == colName) { colName = "_RESULT_" + i; }

        @@ -208,9 +208,9 @@
        typeId = Types.BIGINT;
        }

      • String colName = metadata.getColumnName;
        + String colName = metadata.getColumnLabel;
        if (colName == null || colName.equals("")) { - colName = metadata.getColumnLabel(i); + colName = metadata.getColumnName(i); }

      colTypes.put(colName, Integer.valueOf(typeId));

      Attachments

        1. 585-1.4.4.txt
          3 kB
          Amit Sela
        2. 585-trunk.txt
          3 kB
          Amit Sela
        3. columnLabel.patch
          1 kB
          Vida Ha

        Issue Links

          Activity

            People

              amitsela Amit Sela
              vida@squareup.com Vida Ha
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 1h
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified