Something strange with the node transformer

When I use the node transformer and setup a pattern, It ignores any pattern I set an just iterates over the next nodes.

For example:
If I setup the node transformer like this, I expect to set a new key/val pair under data2.Node1.test = test

But it will set the test/test key/val pair on the first node, even ignoring the data2 pattern:

Even if I just use data2 as only pattern it also puts the value in data.
So it looks to me that “pattern” does not do anything, it just moves to the next node:

Testcase transformer:

{
  "type": "transformer",
  "specification": {
    "prototype": "node",
    "parameters": {
      "nodeTransformers": [
        {
          "prototype": "value-setter",
          "parameters": {
            "configurations": [
              {
                "value": "test",
                "mappers": [],
                "key": "test"
              }
            ]
          }
        }
      ],
      "pattern": "data2"
    }
  }
}

Testdata transformer:

{
  "data": [
    {
      "Node1": [
        {"data" : "data"},
        {"data" : "data"}
      ]
    },
    {
      "Node2": [
        {"data" : "data"},
        {"data" : "data"}
      ]
    }
  ],
  "data2" : [
    {
      "Node1": [
        {"data" : "data"},
        {"data" : "data"}
      ]
    },
    {
      "Node2": [
        {"data" : "data"},
        {"data" : "data"}
      ]
    }
  ]
}

Hi again Rick.

Yea i’ve ran into this problem aswell, and after my findings it seems like there is 2 different node transformers, one of them (The one you used) seems to work different than the other one. maybe someone can answer us what the difference is since i found this strange aswell.

I found this solution to work, start with the “Execute entity transformer” transformer and find “Node, transform nodes” inside, this one will do what you want.

Output:

2 Likes

Hi @Rickvzanden, @mko,

It’s correct that the Node Transformer doesn’t work as expected. We will discuss with the team whether the transformer is still needed.

Thanks, Martin for showing the workaround using “Node, transform nodes” under “Execute entity transformer”.

1 Like

Hi @Gugi

The node data transformer → Node transformer still has a few issues.
Any update on this topic?

To clarify the issues we run into:

  1. The pattern is ignored, does not match on key name
    This problem only occurs in the “Data transformer” version.

For example:
If I got two array keys, and specify to use a certain key as pattern it will move trough both keys.

A simple example with the next test data:

{
    "array_one" : [{"test" : "test"}],
    "array_two" : [{"test" : "test"}]
}

Transformer:

{
  "type": "list-transformer",
  "specification": {
    "parameters": {
      "filters": [],
      "transformers": [
        {
          "prototype": "node",
          "parameters": {
            "nodeTransformers": [
              {
                "prototype": "value-setter",
                "parameters": {
                  "configurations": [
                    {
                      "value": "test2",
                      "mappers": [],
                      "key": "test2"
                    }
                  ]
                }
              }
            ],
            "pattern": "array_two"
          }
        }
      ]
    },
    "prototype": "data",
    "meta": {}
  }
}

Result:

{
  "array_one": {
    "0": {
      "test": "test"
    },
    "test2": "test2"
  },
  "array_two": {
    "0": {
      "test": "test"
    },
    "test2": "test2"
  }
}
  1. The pattern does not go nodes deeper then the first pattern level. Adding pattern levels like pattern.pattern2.* do not work.
    Edit: This problem also only seems to occur in the data transformer version.

Result:

{
  "array_one": {
    "0": {
      "test": "test"
    },
    "test2": "test2"
  },
  "array_two": {
    "0": {
      "test": "test"
    },
    "test2": "test2"
  }
}

Any chance the team could check them out?

Hi @Rickvzanden, we don’t think we will fix the issue with the “Node Transformer” under the “Data, transform data using mappers and conditions”. We will check with the team on what will we do with the transformer in the future.

We would suggest using the nested “Execute entity transformers” → “Node, transform nodes” for your current and future integrations, as @mko suggested.

Please let us know if you have any concerns.

Ok, good to know.

I am already using the Entity Node Transformer in my new and future projects so thats all good. Just was curious about these database transformer version and this old post :slight_smile:

I will flag MKO’s reply as a solution.

1 Like