[ https://issues.apache.org/jira/browse/SQOOP-585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14060180#comment-14060180 ]
ASF subversion and git services commented on SQOOP-585: ------------------------------------------------------- Commit e2d6499da8567888989908ddcd078f046e859679 in sqoop's branch refs/heads/trunk from [~jarcec] [ https://git-wip-us.apache.org/repos/asf?p=sqoop.git;h=e2d6499 ] SQOOP-585: Bug when sqoop a join of two tables with the same column name with mysql backend (Amit Sela via Jarek Jarcec Cecho) > Bug when sqoop a join of two tables with the same column name with mysql > backend > -------------------------------------------------------------------------------- > > Key: SQOOP-585 > URL: https://issues.apache.org/jira/browse/SQOOP-585 > Project: Sqoop > Issue Type: Bug > Components: connectors/sqlserver > Affects Versions: 1.4.4 > Environment: - Mysql server backend (Postgres is fine) > - using a --query argument to join over two tables with identical column > names. Here is an example of my sqoop command: > JAVA_HOME=/usr ./bin/sqoop import \ > --query '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 $CONDITIONS' \ > --boundary-query "SELECT MIN(id), MAX(id) from events"\ > --split-by events.id \ > --target-dir /tmp/sqoop/events \ > --connect jdbc:mysql://localhost/development_database > Reporter: Vida Ha > Priority: Minor > Labels: patch > Attachments: 585-1.4.4.txt, 585-trunk.txt, columnLabel.patch > > Original Estimate: 1h > Remaining Estimate: 1h > > 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(i); > + String colName = metadata.getColumnLabel(i); > if (colName == null || colName.equals("")) { > - colName = metadata.getColumnLabel(i); > + colName = metadata.getColumnName(i); > if (null == colName) { > colName = "_RESULT_" + i; > } > @@ -208,9 +208,9 @@ > typeId = Types.BIGINT; > } > > - String colName = metadata.getColumnName(i); > + String colName = metadata.getColumnLabel(i); > if (colName == null || colName.equals("")) { > - colName = metadata.getColumnLabel(i); > + colName = metadata.getColumnName(i); > } > > colTypes.put(colName, Integer.valueOf(typeId)); -- This message was sent by Atlassian JIRA (v6.2#6252)