bamaer commented on code in PR #9202:
URL: https://github.com/apache/hop/pull/9202#discussion_r4439683393
##########
docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/enhancedjsonoutput.adoc:
##########
@@ -152,4 +152,6 @@ You can use this option (and a chain of transforms, see the
example pipeline in
== Notes
-Look at the sample provided _json-output-generate-nested-structure.hpl_ for a
better understanding about how the transform works
+The sample `json-output-generate-nested-structure.hpl` builds a nested
document with two Enhanced JSON Output transforms. The rows are sorted by
`field1`. The first transform groups `field2` and `field3` (JSON names `campo2`
and `campo3`) and passes that JSON fragment on. The second transform has no
group key. It writes `field1` as `campo1` and embeds the fragment as `details`,
under the block name `results`.
Review Comment:
The Sort rows transform sorts `field1` descending, then `field2` ascending,
so the `C` group comes first in the output. Worth saying, since #2569 is about
comparing output.
##########
docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/enhancedjsonoutput.adoc:
##########
@@ -152,4 +152,6 @@ You can use this option (and a chain of transforms, see the
example pipeline in
== Notes
-Look at the sample provided _json-output-generate-nested-structure.hpl_ for a
better understanding about how the transform works
+The sample `json-output-generate-nested-structure.hpl` builds a nested
document with two Enhanced JSON Output transforms. The rows are sorted by
`field1`. The first transform groups `field2` and `field3` (JSON names `campo2`
and `campo3`) and passes that JSON fragment on. The second transform has no
group key. It writes `field1` as `campo1` and embeds the fragment as `details`,
under the block name `results`.
Review Comment:
This reads as if `field2` and `field3` are the group keys. In the sample,
the group key is `field1` (element `key2`), and `field2` and `field3` are the
output fields. Naming the output field helps too, because the second transform
reads the fragment from it.
Suggestion:
> The first transform groups by `field1` and writes `field2` and `field3` as
`campo2` and `campo3` into the field `lvl1Details`.
##########
docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/enhancedjsonoutput.adoc:
##########
@@ -152,4 +152,6 @@ You can use this option (and a chain of transforms, see the
example pipeline in
== Notes
-Look at the sample provided _json-output-generate-nested-structure.hpl_ for a
better understanding about how the transform works
+The sample `json-output-generate-nested-structure.hpl` builds a nested
document with two Enhanced JSON Output transforms. The rows are sorted by
`field1`. The first transform groups `field2` and `field3` (JSON names `campo2`
and `campo3`) and passes that JSON fragment on. The second transform has no
group key. It writes `field1` as `campo1` and embeds the fragment as `details`,
under the block name `results`.
+
+A transform that lists fields and has no group key writes one JSON array of
those field objects. Grouped items require a group key, and the input has to be
sorted by every group key. The Group Key section above shows that file shape.
Review Comment:
This doesn't hold in three cases:
- **Force single grouped item:** with no group key, every row counts as the
same group (`sameGroup()` compares zero key indexes). All rows then merge into
one object with an array per field, not an array of field objects.
- **One input row:** the output is that single object, unless Force arrays
in JSON is checked (`serializeJson`).
- **JSON block name:** the array is wrapped in an object. The sample's
second transform does this with `results`.
Suggestion:
> With no group key and Force single grouped item unchecked, the output is
an array with one object per row. A single row gives one object unless Force
arrays in JSON is checked.
##########
docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/enhancedjsonoutput.adoc:
##########
@@ -152,4 +152,6 @@ You can use this option (and a chain of transforms, see the
example pipeline in
== Notes
-Look at the sample provided _json-output-generate-nested-structure.hpl_ for a
better understanding about how the transform works
+The sample `json-output-generate-nested-structure.hpl` builds a nested
document with two Enhanced JSON Output transforms. The rows are sorted by
`field1`. The first transform groups `field2` and `field3` (JSON names `campo2`
and `campo3`) and passes that JSON fragment on. The second transform has no
group key. It writes `field1` as `campo1` and embeds the fragment as `details`,
under the block name `results`.
+
+A transform that lists fields and has no group key writes one JSON array of
those field objects. Grouped items require a group key, and the input has to be
sorted by every group key. The Group Key section above shows that file shape.
Review Comment:
#2569 reports that the output doesn't match the page. The page still shows
no output for the sample. A `[source,json]` block with the sample's real output
would answer the issue directly. It should look like this:
```json
{"results":[{"campo1":"C","details":[{"campo2":"B","campo3":"7"},
...]},{"campo1":"B", ...},{"campo1":"A", ...}]}
```
`campo3` is a string because the Data Grid defines `field3` as String.
Please paste the block from an actual run rather than this sketch.
##########
docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/enhancedjsonoutput.adoc:
##########
@@ -152,4 +152,6 @@ You can use this option (and a chain of transforms, see the
example pipeline in
== Notes
-Look at the sample provided _json-output-generate-nested-structure.hpl_ for a
better understanding about how the transform works
+The sample `json-output-generate-nested-structure.hpl` builds a nested
document with two Enhanced JSON Output transforms. The rows are sorted by
`field1`. The first transform groups `field2` and `field3` (JSON names `campo2`
and `campo3`) and passes that JSON fragment on. The second transform has no
group key. It writes `field1` as `campo1` and embeds the fragment as `details`,
under the block name `results`.
+
+A transform that lists fields and has no group key writes one JSON array of
those field objects. Grouped items require a group key, and the input has to be
sorted by every group key. The Group Key section above shows that file shape.
Review Comment:
Nit: the rest of the page uses one sentence per line. These two paragraphs
are single long lines.
--
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]