1
votes

I have two string fields of unspecified length, lets call them One and Two. Now I would like to concat them, so that if One = "aaa" and Two = "bbb" the result becomes "aaabbb". Using the Concat fields step seems like a reasonable first guess for how to do this.

However, if I leave the "Length of target field" setting with the standard value of 0 I get no output. If I set it to something large, like 100, I always get extra spaces at the end. I want the resulting field to be as long as necessary to contain One + Two, not longer and not shorter. Is there anyway to do this using this step or some other one?

I have tried using the trim setting, but it trims the input and not the output. Clicking the "Minimal width" button does absolutely nothing.

This seems like it should be a pretty simple standard task. Am I missing something here?

EDIT: My input here is just a few rows from a Data grid step, without anything between the grid and the concat. I tried replacing the grid with a Generate rows step, but I get the same result (both when using fixed length for the generated fields, and when leaving the length fields blank).

My version of Kettle is 5.4.0.1-130. I am running it on a Windows 7 x64 platform.

2
"if I leave the "Length of target field" setting with the standard value of 0 I get no output" - This is strange. It works for me with testing fields (by using the "Generate Rows"-Step) without problems. Maybe there is a problem with your incoming strings? I would suggest a try with a generate rows step as well. If that works fine, we can concentrate on your incoming data. - Seb
I can only reproduce the problem if I specify the length of the two string-fields with anything but NULL, but as you wrote: "two string fields of unspecified length", this should not be the problem ... - Seb
@Seb I updated my question with info about the input. - Anders

2 Answers

1
votes

Do the configuration as shown in the figure. It correctly gives the result as the second figure. enter image description here

Result:
enter image description here

Used Data Grid step to get data.

0
votes

The configuration suggested by Marlon Abeykoon works. It also works with type "String" instead of "None".

My problem was not in the Concat fields step, but the Text file output step I used to write the result to a file. It takes its metadata about the fields from the Concat fields step, and inherits the zero length for the field therefore printing zero characters to the text file.

The solution is to go to the "Fields" tab of the output step, and there press "Get fields". That explicitly adds all the fields and their metadata to the list, so you can change the lenght field of the output field from the concat step to be empty instead of 0.