5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-10 22:13:07 +08:00

SQOOP-628: Postgres direct import fails on non-lowercase column names

(Paul Butler via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2012-10-12 11:01:08 -07:00
parent e57ae6aa9e
commit 3aed031676
2 changed files with 6 additions and 5 deletions

View File

@ -160,7 +160,7 @@ private String getColumnListStr(String [] cols) {
if (!first) {
sb.append(", ");
}
sb.append(col);
sb.append(escapeColName(col));
first = false;
}
@ -185,6 +185,7 @@ private String getSelectListColumnsStr(String [] cols, String tableName) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String col : cols) {
String colEscaped = escapeColName(col);
if (!first) {
sb.append(", ");
}
@ -194,12 +195,12 @@ private String getSelectListColumnsStr(String [] cols, String tableName) {
} else {
if ("bool".equalsIgnoreCase(columnTypes.get(col))) {
sb.append(String.format("case when %s=true then 'TRUE' "
+ "when %s=false then 'FALSE' end as %s", col, col, col));
+ "when %s=false then 'FALSE' end as %s", colEscaped, colEscaped, colEscaped));
} else if ("bit".equalsIgnoreCase(columnTypes.get(col))) {
sb.append(String.format("case when %s=B'1' then 'TRUE' "
+ "when %s=B'0' then 'FALSE' end as %s", col, col, col));
+ "when %s=B'0' then 'FALSE' end as %s", colEscaped, colEscaped, colEscaped));
} else {
sb.append(col);
sb.append(colEscaped);
}
}
first = false;

View File

@ -160,7 +160,7 @@ public void setUpData(String tableName, String schema) {
+ manager.escapeColName("id") + " INT NOT NULL PRIMARY KEY, "
+ manager.escapeColName("name") + " VARCHAR(24) NOT NULL, "
+ manager.escapeColName("start_date") + " DATE, "
+ manager.escapeColName("salary") + " FLOAT, "
+ manager.escapeColName("Salary") + " FLOAT, "
+ manager.escapeColName("dept") + " VARCHAR(32))");
st.executeUpdate("INSERT INTO " + fullTableName