You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hop.apache.org by "sramazzina (via GitHub)" <gi...@apache.org> on 2025/01/24 14:29:51 UTC
[PR] fix #4818 (hop)
sramazzina opened a new pull request, #4823:
URL: https://github.com/apache/hop/pull/4823
fix #4818 Concat transform does not trim fields
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] Run `mvn clean install apache-rat:check` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
- [ ] If you have a group of commits related to the same change, please squash your commits into one and force push your branch using `git rebase -i`.
- [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable.
To make clear that you license your contribution under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [ ] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix #4818 (hop)
Posted by "sramazzina (via GitHub)" <gi...@apache.org>.
sramazzina commented on code in PR #4823:
URL: https://github.com/apache/hop/pull/4823#discussion_r1931304173
##########
plugins/transforms/concatfields/src/main/java/org/apache/hop/pipeline/transforms/concatfields/ConcatFields.java:
##########
@@ -166,13 +167,32 @@ private Object[] concatFields(Object[] inputRowData) throws HopException {
}
private void concatField(
- StringBuilder targetField, IValueMeta valueMeta, Object valueData, String nullString)
+ StringBuilder targetField,
+ IValueMeta valueMeta,
+ Object valueData,
+ String nullString,
+ String trimType)
throws HopValueException {
if (valueMeta.isNull(valueData)) {
targetField.append(nullString);
} else {
- targetField.append(valueMeta.getString(valueData));
+ if (trimType != null) {
+ switch (trimType) {
+ case ConcatFieldsMeta.TRIM_TYPE_LEFT:
+ targetField.append(valueMeta.getString(valueData).replaceAll("^\\s+", ""));
+ break;
+ case ConcatFieldsMeta.TRIM_TYPE_RIGHT:
+ targetField.append(valueMeta.getString(valueData).replaceAll("\\s+$", ""));
+ break;
+ case ConcatFieldsMeta.TRIM_TYPE_BOTH:
+ targetField.append(valueMeta.getString(valueData).trim());
+ break;
+ default:
+ targetField.append(valueMeta.getString(valueData));
+ break;
+ }
+ }
Review Comment:
Good to know let me use it and fix the code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix #4818 (hop)
Posted by "hansva (via GitHub)" <gi...@apache.org>.
hansva commented on code in PR #4823:
URL: https://github.com/apache/hop/pull/4823#discussion_r1929710957
##########
plugins/transforms/concatfields/src/main/java/org/apache/hop/pipeline/transforms/concatfields/ConcatFields.java:
##########
@@ -166,13 +167,32 @@ private Object[] concatFields(Object[] inputRowData) throws HopException {
}
private void concatField(
- StringBuilder targetField, IValueMeta valueMeta, Object valueData, String nullString)
+ StringBuilder targetField,
+ IValueMeta valueMeta,
+ Object valueData,
+ String nullString,
+ String trimType)
throws HopValueException {
if (valueMeta.isNull(valueData)) {
targetField.append(nullString);
} else {
- targetField.append(valueMeta.getString(valueData));
+ if (trimType != null) {
+ switch (trimType) {
+ case ConcatFieldsMeta.TRIM_TYPE_LEFT:
+ targetField.append(valueMeta.getString(valueData).replaceAll("^\\s+", ""));
+ break;
+ case ConcatFieldsMeta.TRIM_TYPE_RIGHT:
+ targetField.append(valueMeta.getString(valueData).replaceAll("\\s+$", ""));
+ break;
+ case ConcatFieldsMeta.TRIM_TYPE_BOTH:
+ targetField.append(valueMeta.getString(valueData).trim());
+ break;
+ default:
+ targetField.append(valueMeta.getString(valueData));
+ break;
+ }
+ }
Review Comment:
We have a function in Const -> `org.apache.hop.core.Const#trimToType`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix #4818 (hop)
Posted by "hansva (via GitHub)" <gi...@apache.org>.
hansva merged PR #4823:
URL: https://github.com/apache/hop/pull/4823
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix #4818 (hop)
Posted by "sramazzina (via GitHub)" <gi...@apache.org>.
sramazzina commented on PR #4823:
URL: https://github.com/apache/hop/pull/4823#issuecomment-2618833907
@hansva I applied the change you suggested
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org