Skip to content

Commit

Permalink
0005079: Tibero bulk loader failing because table and columns quoted in
Browse files Browse the repository at this point in the history
control file

It seems like the table can not be quoted, but the column names can be
quoted.
So, changing the code to quote the column names if
db.delimited.identifier.mode parameter is true, but not quote the table
name.
Also adding the hard coded strings OPTIONALLY ENCLOSED BY '"' and
ESCAPED BY '\\' to the control file.
# Conflicts:
#	symmetric-client/src/main/java/org/jumpmind/symmetric/io/OracleBulkDatabaseWriter.java
  • Loading branch information
Philip Marzullo committed Sep 1, 2021
1 parent 6af9bc7 commit fd8f5e2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
Expand Up @@ -135,14 +135,23 @@ protected void createStagingFile() {
out.write(("CHARACTERSET " + sqlLoaderInfileCharset + "\n").getBytes(Charset.defaultCharset()));
}
out.write(getInfileControl().getBytes(Charset.defaultCharset()));
out.write(("APPEND INTO TABLE " + targetTable.getQualifiedTableName("\"", ".", ".") + "\n").getBytes(Charset.defaultCharset()));
out.write(("FIELDS TERMINATED BY '" + fieldTerminator + "'\n").getBytes(Charset.defaultCharset()));
out.write(getLineTerminatedByControl().getBytes(Charset.defaultCharset()));
out.write("TRAILING NULLCOLS\n".getBytes(Charset.defaultCharset()));

String quote = "";
if (delimitTokens) {
quote = targetPlatform.getDdlBuilder().getDatabaseInfo().getDelimiterToken();
}
out.write(("APPEND INTO TABLE " + getTargetTableName(targetTable, quote) + "\n").getBytes(Charset.defaultCharset()));
out.write(("FIELDS TERMINATED BY '" + fieldTerminator + "'\n").getBytes(Charset.defaultCharset()));
String valueEnclosedBy = getValueEnclosedBy();
if (StringUtils.isNotBlank(valueEnclosedBy)) {
out.write((valueEnclosedBy + "\n").getBytes());
}
String valueEscapedBy = getValueEscapedBy();
if (StringUtils.isNotBlank(valueEscapedBy)) {
out.write((valueEscapedBy + "\n").getBytes());
}
out.write(getLineTerminatedByControl().getBytes(Charset.defaultCharset()));
out.write("TRAILING NULLCOLS\n".getBytes(Charset.defaultCharset()));
StringBuilder columns = new StringBuilder("(");
int index = 0;
for (Column column : targetTable.getColumns()) {
Expand Down Expand Up @@ -171,6 +180,18 @@ protected void createStagingFile() {
throw new RuntimeException(e);
}
}

protected String getValueEscapedBy() {
return "";
}

protected String getValueEnclosedBy() {
return "";
}

protected String getTargetTableName(Table targetTable, String delimiterToken) {
return targetTable.getQualifiedTableName(delimiterToken, ".", ".") + "\n";
}

protected String getInfileControl() {
return "INFILE '" + dataResource.getFile().getName() + "' \"str '" + lineTerminator + "'\"\n";
Expand Down
Expand Up @@ -23,6 +23,7 @@
import java.io.File;

import org.apache.commons.lang3.StringUtils;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.symmetric.io.data.writer.DatabaseWriterSettings;
import org.jumpmind.symmetric.io.stage.IStagingManager;
Expand All @@ -48,6 +49,22 @@ public TiberoBulkDatabaseWriter(IDatabasePlatform symmetricPlatform, IDatabasePl
}
}
}

@Override
protected String getValueEscapedBy() {
return " ESCAPED BY '\\\\'";
}

@Override
protected String getValueEnclosedBy() {
return " OPTIONALLY ENCLOSED BY '\"'";
}

@Override
protected String getTargetTableName(Table targetTable, String delimiterToken) {
// Tibero does not allow quoted table names
return targetTable.getQualifiedTableName("", ".", ".") + "\n";
}

@Override
protected String getInfileControl() {
Expand Down

0 comments on commit fd8f5e2

Please sign in to comment.