bamaer commented on code in PR #9367:
URL: https://github.com/apache/hop/pull/9367#discussion_r4539560533
##########
plugins/transforms/textchunker/src/main/java/org/apache/hop/pipeline/transforms/chunker/TextChunkerMeta.java:
##########
@@ -326,14 +325,41 @@ public void getFields(
}
}
+ /**
+ * Adds an output field. When the input already has a field with that name
the transform writes
+ * its values into that field, so the field takes the transform's type if
the types differ.
+ */
private static void addField(IRowMeta row, IValueMeta field, String origin)
throws HopPluginException {
String fieldName = field.getName();
- if (fieldName == null || fieldName.isEmpty() ||
row.indexOfValue(fieldName) >= 0) {
+ if (fieldName == null || fieldName.isEmpty()) {
return;
}
field.setOrigin(origin);
- row.addValueMeta(field);
+ int index = row.indexOfValue(fieldName);
+ if (index < 0) {
+ row.addValueMeta(field);
+ } else if (row.getValueMeta(index).getType() != field.getType()) {
+ row.setValueMeta(index, field);
+ }
+ }
+
+ /**
+ * Parses a resolved chunk size or overlap.
+ *
+ * @param value the resolved value
+ * @param emptyValue the value to use when nothing is configured
+ * @return the number, or {@code null} when the value is not a whole number
+ */
+ static Integer parseNumber(String value, int emptyValue) {
+ if (Utils.isEmpty(value) || value.isBlank()) {
Review Comment:
Done in 4d2047c.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]