hop icon indicating copy to clipboard operation
hop copied to clipboard

[Bug]: Concat Fields trims the fields

Open EricTonissen opened this issue 1 month ago • 5 comments

Apache Hop version?

2.17

Java version?

17.0.17

Operating system

Windows

What happened?

The concatted fields with trimtype = None, are also trimmed.

Image Image

tr_param_concat_fields.txt

The reason is within the ConcatFields.java the concatField method:

 if (trimType != null) {
    targetField.append(
        Const.trimToType(
            **valueMeta.getString(valueData)**, ValueMetaBase.getTrimTypeByCode(trimType)));
  }

The ValueMetaBase.getString() performs a trim():

   if (string != null) {
        string = trim(string);
   }

Issue Priority

Priority: 3

Issue Component

Component: Pipelines

EricTonissen avatar Dec 15 '25 12:12 EricTonissen

The latest given trim type should indeed be taken. A copy of the IValueMeta object needs to be take (cloned) and then the trim type needs to be changed. Do we need an extra option, "use field trim type" in the Concat Fields dialog?

mattcasters avatar Dec 15 '25 12:12 mattcasters

I wouldn't go as far as to add an option for the "use field trim type" the get fields button should also "import" the correct trim types from the existing fields and then it's up to the developer.

hansva avatar Dec 15 '25 16:12 hansva

I agree @hansva. The last options given are the ones we should follow.

mattcasters avatar Dec 15 '25 18:12 mattcasters

@mattcasters @hansva is not clear to me if something must be fixed and what :-(

sramazzina avatar Dec 17 '25 09:12 sramazzina

It's subtle in the sense that if you have trim type set on the field metadata of an incoming field, you want to ignore that setting, even if the dialog says "None" as the trim type.

mattcasters avatar Dec 17 '25 09:12 mattcasters