Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PDI-18114] Enabled or disabled the enforcelength #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public class VerticaBulkLoaderDialog extends BaseStepDialog implements StepDialo
private Button wDirect;
private FormData fdlDirect, fdDirect;

private Label wlEnforcelength;
private Button wEnforcelength;
private FormData fdlEnforcelength, fdEnforcelength;

private Label wlSpecifyFields;
private Button wSpecifyFields;
private FormData fdlSpecifyFields, fdSpecifyFields;
Expand Down Expand Up @@ -344,22 +348,42 @@ public void widgetSelected( SelectionEvent arg0 ) {
wDirect.setLayoutData( fdDirect );
wDirect.addSelectionListener( lsSelMod );

// Checkbox for enforcelength
wlEnforcelength = new Label( wMainComp, SWT.RIGHT );
wlEnforcelength.setText( BaseMessages.getString( PKG, "VerticaBulkLoaderDialog.Enforcelength.Label" ) );
wlEnforcelength.setToolTipText( BaseMessages.getString( PKG, "VerticaBulkLoaderDialog.Enforcelength.Tooltip" ) );
props.setLook( wlEnforcelength );
fdlEnforcelength = new FormData();
fdlEnforcelength.left = new FormAttachment( 0, 0 );
fdlEnforcelength.top = new FormAttachment( wDirect, margin );
fdlEnforcelength.right = new FormAttachment( middle, -margin );
wlEnforcelength.setLayoutData( fdlEnforcelength );
wEnforcelength = new Button( wMainComp, SWT.CHECK );
wEnforcelength.setToolTipText( BaseMessages.getString( PKG, "VerticaBulkLoaderDialog.Enforcelength.Tooltip" ) );
props.setLook( wEnforcelength );
fdEnforcelength = new FormData();
fdEnforcelength.left = new FormAttachment( middle, 0 );
fdEnforcelength.top = new FormAttachment( wDirect, margin );
fdEnforcelength.right = new FormAttachment( 100, 0 );
wEnforcelength.setLayoutData( fdEnforcelength );
wEnforcelength.addSelectionListener( lsSelMod );

// Abort on error
wlAbortOnError = new Label( wMainComp, SWT.RIGHT );
wlAbortOnError.setText( BaseMessages.getString( PKG, "VerticaBulkLoaderDialog.AbortOnError.Label" ) );
wlAbortOnError.setToolTipText( BaseMessages.getString( PKG, "VerticaBulkLoaderDialog.AbortOnError.Tooltip" ) );
props.setLook( wlAbortOnError );
fdlAbortOnError = new FormData();
fdlAbortOnError.left = new FormAttachment( 0, 0 );
fdlAbortOnError.top = new FormAttachment( wDirect, margin );
fdlAbortOnError.top = new FormAttachment( wEnforcelength, margin );
fdlAbortOnError.right = new FormAttachment( middle, -margin );
wlAbortOnError.setLayoutData( fdlAbortOnError );
wAbortOnError = new Button( wMainComp, SWT.CHECK );
wAbortOnError.setToolTipText( BaseMessages.getString( PKG, "VerticaBulkLoaderDialog.AbortOnError.Tooltip" ) );
props.setLook( wAbortOnError );
fdAbortOnError = new FormData();
fdAbortOnError.left = new FormAttachment( middle, 0 );
fdAbortOnError.top = new FormAttachment( wDirect, margin );
fdAbortOnError.top = new FormAttachment( wEnforcelength, margin );
fdAbortOnError.right = new FormAttachment( 100, 0 );
wAbortOnError.setLayoutData( fdAbortOnError );
wAbortOnError.addSelectionListener( lsSelMod );
Expand Down Expand Up @@ -829,6 +853,7 @@ public void getData() {
}

wDirect.setSelection( input.isDirect() );
wEnforcelength.setSelection( input.isEnforcelength() );
wAbortOnError.setSelection( input.isAbortOnError() );

wSpecifyFields.setSelection( input.specifyFields() );
Expand Down Expand Up @@ -864,6 +889,7 @@ private void getInfo( VerticaBulkLoaderMeta info ) {
info.setStreamName( wStreamName.getText() );

info.setDirect( wDirect.getSelection() );
info.setEnforcelength( wEnforcelength.getSelection() );
info.setAbortOnError( wAbortOnError.getSelection() );

info.setSpecifyFields( wSpecifyFields.getSelection() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,9 @@ private String buildCopyStatementSqlString() {
}

// TODO: Should eventually get a preference for this, but for now, be backward compatible.
sb.append( "ENFORCELENGTH " );
if ( !meta.isEnforcelength() ) {
sb.append("ENFORCELENGTH ");
}

if ( meta.isAbortOnError() ) {
sb.append( "ABORT ON ERROR " );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public class VerticaBulkLoaderMeta extends BaseStepMeta implements StepMetaInter
@Injection( name = "DIRECT", group = "MAIN_OPTIONS" )
private boolean direct = true;

@Injection( name = "ENFORCELENGTH", group = "MAIN_OPTIONS" )
private boolean enforcelength = true;

@Injection( name = "ABORTONERROR", group = "MAIN_OPTIONS" )
private boolean abortOnError = true;

Expand Down Expand Up @@ -205,6 +208,12 @@ public void setDirect( boolean direct ) {
this.direct = direct;
}

public boolean isEnforcelength() { return enforcelength; }

public void setEnforcelength( boolean enforcelength ) {
this.enforcelength = enforcelength;
}

public boolean isAbortOnError() {
return abortOnError;
}
Expand Down Expand Up @@ -268,6 +277,7 @@ private void readData( Node stepnode, List<? extends SharedObjectInterface> data
rejectedDataFileName = XMLHandler.getTagValue( stepnode, "rejected_data_filename" );
abortOnError = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "abort_on_error" ) );
direct = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "direct" ) );
enforcelength = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "enforcelength" ) );
streamName = XMLHandler.getTagValue( stepnode, "stream_name" );

} catch ( Exception e ) {
Expand Down Expand Up @@ -305,6 +315,7 @@ public String getXML() {
retval.append( " " + XMLHandler.addTagValue( "rejected_data_filename", rejectedDataFileName ) );
retval.append( " " + XMLHandler.addTagValue( "abort_on_error", abortOnError ) );
retval.append( " " + XMLHandler.addTagValue( "direct", direct ) );
retval.append( " " + XMLHandler.addTagValue( "enforcelength", enforcelength ) );
retval.append( " " + XMLHandler.addTagValue( "stream_name", streamName ) );

return retval.toString();
Expand Down Expand Up @@ -334,6 +345,7 @@ public void readRep( Repository rep, ObjectId id_step, List<DatabaseMeta> databa
rejectedDataFileName = rep.getStepAttributeString( id_step, "rejected_data_filename" );
abortOnError = rep.getStepAttributeBoolean( id_step, "abort_on_error" );
direct = rep.getStepAttributeBoolean( id_step, "direct" );
enforcelength = rep.getStepAttributeBoolean( id_step, "enforcelength" );
streamName = rep.getStepAttributeString( id_step, "stream_name" );
} catch ( Exception e ) {
throw new KettleException( "Unexpected error reading step information from the repository", e );
Expand All @@ -359,6 +371,7 @@ public void saveRep( Repository rep, ObjectId id_transformation, ObjectId id_ste
rep.saveStepAttribute( id_transformation, id_step, "rejected_data_filename", rejectedDataFileName );
rep.saveStepAttribute( id_transformation, id_step, "abort_on_error", abortOnError );
rep.saveStepAttribute( id_transformation, id_step, "direct", direct );
rep.saveStepAttribute( id_transformation, id_step, "enforcelength", enforcelength );
rep.saveStepAttribute( id_transformation, id_step, "stream_name", streamName );
} catch ( Exception e ) {
throw new KettleException( "Unable to save step information to the repository for id_step=" + id_step, e );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ VerticaBulkLoaderDialog.AbortOnError.Label=Abort on error
VerticaBulkLoaderDialog.AbortOnError.Tooltip=If a record is rejected, the statement will be aborted and no data will be loaded. If this option is not enabled, rejected records will be logged but will not stop the bulk load.
VerticaBulkLoaderDialog.InsertDirect.Label=Insert direct to ROS
VerticaBulkLoaderDialog.InsertDirect.Tooltip=If enabled, the statement is a COPY DIRECT statement and Vertica will insert the data directly to the ROS (Read Optimized Storage). Otherwise, the data will be inserted to the WOS (Write Optimized Storage) (e.g. a "trickle load")
VerticaBulkLoaderDialog.Enforcelength.Label=Enabled Enforcelength
VerticaBulkLoaderDialog.Enforcelength.Tooltip=If enabled, the ENFORCERLENGTH parameter to reject rows that exceed the length of the target table.
VerticaBulkLoaderDialog.Delimiter.Label=Delimiter character
VerticaBulkLoaderDialog.Delimiter.Tooltip=Specifies the single-character column delimiter used during the load. Default is the tab character (\\t). Be sure to use a character that is not found in any field of the records because Vertica does not use field quoting.
VerticaBulkLoaderDialog.NullString.Label=Null string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public boolean get() {
return meta.isDirect();
}
} );
check( "ENFORCELENGTH", new BooleanGetter() {
public boolean get() {
return meta.isEnforcelength();
}
} );
check( "ABORTONERROR", new BooleanGetter() {
public boolean get() {
return meta.isAbortOnError();
Expand Down
Loading