Skip to content

Commit

Permalink
0002052: Remove transform when used on a primary key without the pk c…
Browse files Browse the repository at this point in the history
…olumn checked fails

0002053: Fallback to insert fails when transform is configured as update first on the LOAD side. Data is retransformed as an update.
  • Loading branch information
chenson42 committed Nov 5, 2014
1 parent ded7dda commit c2786d8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Expand Up @@ -284,7 +284,7 @@ public TransformTable enhanceWithImpliedColumns(String[] keyNames, String[] colu
boolean hasDelete = false;

if (primaryKeyColumns != null) {
for (TransformColumn xCol : primaryKeyColumns) {
for (TransformColumn xCol : transformColumns) {
if ((StringUtils.isNotBlank(xCol.getSourceColumnName()) && StringUtils.equalsIgnoreCase(xCol.getSourceColumnName(),column)) ||
StringUtils.isNotBlank(xCol.getTargetColumnName()) && StringUtils.equalsIgnoreCase(xCol.getTargetColumnName(),column)) {
if (xCol.includeOn == IncludeOnType.ALL) {
Expand Down
Expand Up @@ -197,12 +197,17 @@ public void write(CsvData data) {

List<TransformedData> dataThatHasBeenTransformed = new ArrayList<TransformedData>();
TransformTable[] transformTables = activeTransforms.toArray(new TransformTable[activeTransforms.size()]);
if (data.getDataEventType() == DataEventType.DELETE) {
if (eventType == DataEventType.DELETE) {
CollectionUtils.reverseArray(transformTables);
}

for (TransformTable transformation : transformTables) {
transformation = transformation.enhanceWithImpliedColumns(this.sourceTable.getPrimaryKeyColumnNames(),
transformation = transformation.enhanceWithImpliedColumns(
this.sourceTable.getPrimaryKeyColumnNames(),
this.sourceTable.getColumnNames());
if (eventType == DataEventType.INSERT && transformation.isUpdateFirst()) {
eventType = DataEventType.UPDATE;
}
dataThatHasBeenTransformed.addAll(transform(eventType, context, transformation,
sourceKeyValues, oldSourceValues, sourceValues));
}
Expand Down Expand Up @@ -344,10 +349,6 @@ protected boolean perform(DataContext context, TransformedData data,
// transformation
if (data.getColumnNames().length > 0) {
if (data.getTargetDmlType() != DataEventType.DELETE) {
if (data.getTargetDmlType() == DataEventType.INSERT
&& transformation.isUpdateFirst()) {
data.setTargetDmlType(DataEventType.UPDATE);
}
persistData = true;
} else {
// handle the delete action
Expand Down
Expand Up @@ -83,7 +83,7 @@ protected void refreshResourceList() {
*/
public long clean(long ttlInMs) {
synchronized (StagingManager.class) {
log.debug("Cleaning staging area");
log.trace("Cleaning staging area");
Set<String> keys = new HashSet<String>(resourceList.keySet());
long purgedFileCount = 0;
long purgedFileSize = 0;
Expand Down

0 comments on commit c2786d8

Please sign in to comment.