Five Stars

Remove field from dynamic schema based on data type

Hi Folks:

 

Using Dynamic schema to read table from SQL Server, and I want to remove all "timestamp" data types.

Do you have suggestion on how to loop thru the dynamic schema and modify it at run time?

For example, can I throw a tJavaRow between my source and target, & remove the timestamp column?

If so, can you please post a sample?

thanks!!

2 REPLIES
Five Stars

Re: Remove field from dynamic schema based on data type

I have the same problem! Trying to keep a dynamic job as simple as possible so if an existing component could conditionally remove columns based on data type that'd be ideal. 

Five Stars

Re: Remove field from dynamic schema based on data type

Well, I was finally able to get around my issue by increasing the size of the field in the dynamic column with this (should be able to do other things like removing the column or changing types etc similarly): 

 

Dynamic columns = row1.newColumn;

for (int i = 0; i < columns.getColumnCount(); i++) {
DynamicMetadata columnMetadata = columns.getColumnMetadata(i);
if (columnMetadata.getDbType() == "timestamp" )
{
columnMetadata.setLength(50);
}
}

output_row.newColumn = columns;