Skip to content

Commit

Permalink
0003716: MSSQL bulk loader fails when truncate table is used as part of
Browse files Browse the repository at this point in the history
the load with a different target database and schema
  • Loading branch information
jumpmind-josh committed Sep 11, 2018
1 parent a000d14 commit 549b92e
Showing 1 changed file with 12 additions and 9 deletions.
Expand Up @@ -85,7 +85,8 @@ public boolean start(Table table) {
String qualifiedName = sourceTable.getFullyQualifiedTableName();
if (writerSettings.isIgnoreMissingTables()) {
if (!missingTables.contains(qualifiedName)) {
log.warn("Did not find the {} table in the target database", qualifiedName);
log.info("Did not find the {} table in the target database. This might have been part of a sql "
+ "command (truncate) but will work if the fully qualified name was in the sql provided", qualifiedName);
missingTables.add(qualifiedName);
}
} else {
Expand All @@ -94,7 +95,7 @@ public boolean start(Table table) {
}

needsBinaryConversion = false;
if (! batch.getBinaryEncoding().equals(BinaryEncoding.HEX)) {
if (! batch.getBinaryEncoding().equals(BinaryEncoding.HEX) && targetTable != null) {
for (Column column : targetTable.getColumns()) {
if (column.isOfBinaryType()) {
needsBinaryConversion = true;
Expand All @@ -104,13 +105,15 @@ public boolean start(Table table) {
}
databaseTable = getPlatform(table).getTableFromCache(sourceTable.getCatalog(), sourceTable.getSchema(),
sourceTable.getName(), false);
String[] csvNames = targetTable.getColumnNames();
String[] columnNames = databaseTable.getColumnNames();
needsColumnsReordered = false;
for (int i = 0; i < csvNames.length; i++) {
if (! csvNames[i].equals(columnNames[i])) {
needsColumnsReordered = true;
break;
if (targetTable != null) {
String[] csvNames = targetTable.getColumnNames();
String[] columnNames = databaseTable.getColumnNames();
needsColumnsReordered = false;
for (int i = 0; i < csvNames.length; i++) {
if (! csvNames[i].equals(columnNames[i])) {
needsColumnsReordered = true;
break;
}
}
}
//TODO: Did this because start is getting called multiple times
Expand Down

0 comments on commit 549b92e

Please sign in to comment.