bamaer commented on code in PR #9520:
URL: https://github.com/apache/hop/pull/9520#discussion_r4595991474
##########
plugins/transforms/xml/src/main/java/org/apache/hop/pipeline/transforms/xml/xmljoin/XmlJoinMeta.java:
##########
@@ -120,6 +120,16 @@ public void getFields(
IValueMeta v = new
ValueMetaString(variables.resolve(this.getValueXmlField()));
v.setOrigin(name);
+ IRowMeta knownTarget = info == null || info.length == 0 ? null : info[0];
+ if (knownTarget != null) {
Review Comment:
**Blocker:** at design time `info[0]` is never null. The XML join's info
streams have no transform set (`getInfoTransformNames()` is `[null, null]`), so
`PipelineMeta.getThisTransformFields()` passes an empty `RowMeta` for both.
This branch then clears the row and the transform reports only the XML field.
Fields of `XML Join transform` in
`integration-tests/xml/0001-xml-join-test.hpl`, from
`pipelineMeta.getTransformFields()`:
| | fields |
|---|---|
| main | target + source fields + `xmloutput1` |
| this PR | `xmloutput1` |
| with the fix below | `source, timestamp, businessUnitId, plantId,
OrderHeaders, xmlOrderLists, xmloutput1` |
Joins 2–5 lose the whole target row as well. At runtime `processRow()`
already passed the real target row, so this branch only changes what the GUI
and later transforms see.
Suggested fix: treat an empty `info[0]` as unknown here (`knownTarget !=
null && !knownTarget.isEmpty()`), and look the target up by name in the
`PipelineMeta` overload, which is the one `PipelineMeta` calls:
```java
@Override
public void getFields(
PipelineMeta pipelineMeta,
IRowMeta row,
String name,
IRowMeta[] info,
TransformMeta nextTransform,
IVariables variables,
IHopMetadataProvider metadataProvider)
throws HopTransformException {
boolean targetKnown = info != null && info.length > 0 && info[0] != null
&& !info[0].isEmpty();
if (!targetKnown && pipelineMeta != null) {
TransformMeta targetTransform =
pipelineMeta.findTransform(getTargetXmlTransform());
if (targetTransform != null) {
IRowMeta[] withTarget =
new IRowMeta[] {
pipelineMeta.getTransformFields(variables, targetTransform),
info != null && info.length > 1 ? info[1] : null
};
getFields(row, name, withTarget, nextTransform, variables,
metadataProvider);
return;
}
}
getFields(row, name, info, nextTransform, variables, metadataProvider);
}
```
The new unit test passes the target row in `info`, which only `processRow()`
does. A test that goes through `PipelineMeta.getTransformFields()` would catch
this.
--
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]