[ 
https://issues.apache.org/jira/browse/NIFI-14664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17983730#comment-17983730
 ] 

Daniel Stieglitz edited comment on NIFI-14664 at 6/19/25 5:05 PM:
------------------------------------------------------------------

[~zhongwei.long] I am not sure its those lines which create the problem. The 
same JoltTransform object is being used in each of the transforms as it is 
cached. The first time running is where the JoltTransform object is created. On 
subsequent calls, the same object is retrieved from the cache to perform the 
transform.

I believe this has to do with line 110 in your spec
{code:java}
"suggestedMax": "c.options.scales.xAxes[0].ticks.suggestedMax"{code}
I am still not sure why, but if that line is taken out then there is no 
duplication. I am still trying though to wrap my head around why that line 
should cause an issue like this.

Just on a side note I am able to recreate this issue in a unit test where I see 
the behavior you have noted.


was (Author: JIRAUSER294662):
[~zhongwei.long] I am not sure its those lines which create the problem. The 
same JoltTransform object is being used in each of the transforms as it is 
cached. The first time running is where the JoltTransform object is created. On 
subsequent calls, the same object is retrieved from the cache.

I believe this has to do with line 110 in your spec
{code:java}
"suggestedMax": "c.options.scales.xAxes[0].ticks.suggestedMax"{code}
I am still not sure why, but if that line is taken out then there is no 
duplication. I am still trying though to wrap my head around why that line 
should cause an issue like this.

Just on a side note I am able to recreate this issue in a unit test where I see 
the behavior you have noted.

> 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)

Reply via email to