5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-04 02:52:19 +08:00

SQOOP-820: Escape table name in export job only if it's required by connector

(Jarek Jarcec Cecho via Cheolsoo Park)
This commit is contained in:
Cheolsoo Park 2013-01-08 10:06:56 -08:00
parent 7573450e18
commit b02ddc3975
4 changed files with 26 additions and 1 deletions

View File

@ -450,6 +450,16 @@ public String escapeTableName(String tableName) {
return tableName;
}
/**
* Return true if Sqoop common code should automatically escape table name
* when saving it to mapreduce configuration object when during export.
*
* @return True if table name should be escaped
*/
public boolean escapeTableNameOnExport() {
return false;
}
/**
* Perform any shutdown operations on the connection.
*/

View File

@ -81,6 +81,11 @@ public String escapeTableName(String tableName) {
return escapeIdentifier(tableName);
}
@Override
public boolean escapeTableNameOnExport() {
return true;
}
protected String escapeIdentifier(String identifier) {
if (identifier == null) {
return null;

View File

@ -157,6 +157,11 @@ public String escapeTableName(String tableName) {
return escapeObjectName(tableName);
}
@Override
public boolean escapeTableNameOnExport() {
return true;
}
/**
* Escape database object name (database, table, column, schema).
*

View File

@ -129,7 +129,12 @@ protected void configureOutputFormat(Job job, String tableName,
if (null == colNames) {
colNames = mgr.getColumnNames(tableName);
}
DBOutputFormat.setOutput(job, mgr.escapeTableName(tableName), colNames);
if (mgr.escapeTableNameOnExport()) {
DBOutputFormat.setOutput(job, mgr.escapeTableName(tableName), colNames);
} else {
DBOutputFormat.setOutput(job, tableName, colNames);
}
job.setOutputFormatClass(getOutputFormatClass());
job.getConfiguration().set(SQOOP_EXPORT_TABLE_CLASS_KEY, tableClassName);