le.zw created NIFI-14664:
----------------------------
Summary: 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
Attachments: 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)