[
https://issues.apache.org/jira/browse/NIFI-14664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17984926#comment-17984926
]
le.zw commented on NIFI-14664:
------------------------------
[~dstiegli1]
Thank you for taking the time to investigate this issue. I’ve conducted
additional tests using alternative approaches, such as the following spec:
{code:java}
[
{
"operation": "shift",
"spec": {
"*": {
"category": "c.data.labels.[&1]",
"value": "c.data.datasets[0].data"
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"max": "=max(@(1,c.data.datasets[0].data))"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"suggestedMax": "=intSum(@(1,max), 20)"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"c": {
"data": {
"datasets": {
"*": {
"label": "Orders",
"backgroundColor": "gold"
}
}
}
}
}
},
{
"operation": "default",
"spec": {
"c": {
"type": "horizontalBar",
"options": {
"scales": {
"xAxes": [
{
"gridLines": {
"display": true,
"drawOnChartArea": false,
"tickMarkLength": 8,
"zeroLineWidth": 1,
"zeroLineColor": "black",
"color": "black"
},
"ticks": {
"fontColor": "black",
"beginAtZero": true
}
}
],
"yAxes": [
{
"display": true,
"position": "left",
"gridLines": {
"display": true,
"drawOnChartArea": false,
"tickMarkLength": 8,
"color": "black"
},
"ticks": {
"fontColor": "black",
"fontSize": "8"
}
}
]
},
"legend": {
"display": false
},
"plugins": {
"datalabels": {
"anchor": "end",
"align": "end",
"color": "black",
"font": {
"size": 10,
"weight": "bold"
}
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"@": "&"
},
"suggestedMax": "c.options.scales.xAxes[0].ticks.suggestedMax"
}
}
] {code}
The transformation logic for *suggestedMax* remains consistent with the
previous implementation, but with some intermediate modifications.
Interestingly, repeated transformations no longer produce duplicates in this
scenario.
In your opinion, should this issue be categorized as a caching-related defect
or a special case in Jolt specification parsing?
I truly appreciate your attention to this matter and look forward to your
further insights.
> JoltTransformJSON repeatedly appends values to fields on re-execution
> ---------------------------------------------------------------------
>
> Key: NIFI-14664
> URL: https://issues.apache.org/jira/browse/NIFI-14664
> Project: Apache NiFi
> Issue Type: Bug
> Components: Examples
> Affects Versions: 2.4.0
> Reporter: le.zw
> Priority: Major
> Labels: jolt
> Attachments: JOLT_Test.json, image-2025-06-16-16-15-40-471.png,
> image-2025-06-16-16-25-51-932.png, image-2025-06-16-16-29-05-004.png
>
>
> input JSON
> {code:java}
> [
> {
> "category": "05-01",
> "value": 218
> },
> {
> "category": "05-02",
> "value": 219
> },
> {
> "category": "05-03",
> "value": 170
> }
> ]
> {code}
> JOLT spec:
> {code:java}
> [
> {
> "operation": "shift",
> "spec": {
> "*": {
> "category": "c.data.labels.[&1]",
> "value": "c.data.datasets[0].data"
> }
> }
> },
> {
> "operation": "modify-overwrite-beta",
> "spec": {
> "max": "=max(@(1,c.data.datasets[0].data))"
> }
> },
> {
> "operation": "modify-overwrite-beta",
> "spec": {
> "suggestedMax": "=intSum(@(1,max),20)"
> }
> },
> {
> "operation": "modify-define-beta",
> "spec": {
> "c": {
> "type": "horizontalBar",
> "data": {
> "datasets": {
> "*": {
> "label": "Orders",
> "backgroundColor": "gold"
> }
> }
> },
> "options": {
> "scales": {
> "xAxes": [
> {
> "gridLines": {
> "display": true,
> "drawOnChartArea": false,
> "tickMarkLength": 8,
> "zeroLineWidth": 1,
> "zeroLineColor": "black",
> "color": "black"
> },
> "ticks": {
> "fontColor": "black",
> "beginAtZero": true
> }
> }
> ],
> "yAxes": [
> {
> "display": true,
> "position": "left",
> "gridLines": {
> "display": true,
> "drawOnChartArea": false,
> "tickMarkLength": 8,
> "color": "black"
> },
> "ticks": {
> "fontColor": "black",
> "fontSize": "8"
> }
> }
> ]
> },
> "legend": {
> "display": false
> },
> "plugins": {
> "datalabels": {
> "anchor": "end",
> "align": "end",
> "color": "black",
> "font": {
> "size": 10,
> "weight": "bold"
> }
> }
> }
> }
> }
> }
> },
> {
> "operation": "shift",
> "spec": {
> "c": {
> "options": {
> "scales": {
> "xAxes": {
> "*": "c.options.scales.xAxes[#2].&"
> },
> "yAxes": {
> "*": "c.options.scales.yAxes[#3].&"
> }
> },
> "*": {
> "@": "c.options.&0"
> }
> },
> "*": {
> "@": "c.&0"
> }
> },
> "suggestedMax": "c.options.scales.xAxes[0].ticks.suggestedMax"
> }
> }
> ]
> {code}
> On repeated executions, the suggestedMax field is transformed into an array
> whose number of elements increases over time.
> *After the first execution, {{suggestedMax}} is a single value:*
> *!image-2025-06-16-16-25-51-932.png!*
> *After the second execution, the {{suggestedMax}} field is transformed into
> an array containing two values:*
> *!image-2025-06-16-16-29-05-004.png!*
--
This message was sent by Atlassian Jira
(v8.20.10#820010)