Skip to content

Commit

Permalink
Merge pull request #54 from bcostahitachivantara/PDI-18869
Browse files Browse the repository at this point in the history
[PDI-18869] - "TPT Bulk Loader" step is Missing SET operator in the Script
  • Loading branch information
ssamora authored Sep 24, 2020
2 parents 54f9ea2 + 84194de commit d261fbf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@ private String createInsertCommand( boolean isPreview ) {
*
* @return the string
*/
private String createUpsertCommand( boolean isPreview ) {
@VisibleForTesting
String createUpsertCommand( boolean isPreview ) {
StringBuffer updatecmd = new StringBuffer();
StringBuffer insertcmd = new StringBuffer();

updatecmd.append( " UPDATE " + getTargetSchema( isPreview ) + '.' + ( isPreview ? this.meta.getTableName() : parent.environmentSubstitute( this.meta.getTableName() ) + " SET\n" ) );
updatecmd.append( " UPDATE " + getTargetSchema( isPreview ) + '.' + ( isPreview ? this.meta.getTableName() : parent.environmentSubstitute( this.meta.getTableName() ) ) + " SET\n" );
String[] fieldTable = this.meta.getFieldTable();
String[] fieldStream = this.meta.getFieldStream();
Boolean[] fieldUpdate = this.meta.getFieldUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2018 by Hitachi Vantara : http://www.pentaho.com
* Copyright (C) 2002-2020 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand All @@ -27,6 +27,7 @@
import org.pentaho.di.core.variables.Variables;

import java.io.File;
import java.util.UUID;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
Expand Down Expand Up @@ -269,4 +270,26 @@ public void getDropTablesTest() {
String dropTables = teraDataBulkLoaderRoutines.getDropTables( true );
assertEquals( expectedDropTables, dropTables );
}

@Test
public void testCreateUpsertCommandPreview() {

String tableName = UUID.randomUUID().toString();
String schemaName = UUID.randomUUID().toString();

String[] fieldTable = new String[] {};
String[] fieldStream = new String[] {};
Boolean[] fieldUpdate = new Boolean[] {};

when( teraDataBulkLoaderMetaMock.getSchemaName() ).thenReturn( schemaName );
when( teraDataBulkLoaderMetaMock.getTableName() ).thenReturn( tableName );
when( teraDataBulkLoaderMetaMock.getFieldTable() ).thenReturn( fieldTable );
when( teraDataBulkLoaderMetaMock.getFieldStream() ).thenReturn( fieldStream );
when( teraDataBulkLoaderMetaMock.getFieldUpdate() ).thenReturn( fieldUpdate );
when( teraDataBulkLoaderMetaMock.getKeyStream() ).thenReturn( new String[] {} );

String upsertCommand = this.teraDataBulkLoaderRoutines.createUpsertCommand( true );
assertEquals( true, upsertCommand.startsWith( "' UPDATE " + schemaName + "." + tableName + " SET\n" ) );

}
}

0 comments on commit d261fbf

Please sign in to comment.