Chris Green created NIFI-5060:
---------------------------------

             Summary: UpdateRecord substringAfter and substringAfterLast only 
increments by 1
                 Key: NIFI-5060
                 URL: https://issues.apache.org/jira/browse/NIFI-5060
             Project: Apache NiFi
          Issue Type: Bug
          Components: Extensions
    Affects Versions: 1.6.0
            Reporter: Chris Green
         Attachments: Validate_substringafter_Behavior.xml

This is my first submitted issue, so please feel free to point me in the 
correct direction if I make process mistakes.

Replication:

Drag a GenerateFlowFile onto the canvas and configure this property, and set 
run schedule to some high value like 600 seconds

"Custom Text" \{"value": "01230123"}

Connect GenerateFlowFile with an UpdateAttribute set to add the attribute 
"avro.schema" with a value of "{ "type": "record",
 "name": "test",
 "fields" : [\{"name": "value", "type": "string"}]
}"

 

Connect UpdateAttribute to an UpdateRecord onto the canvas, Autoterminate 
success and failure. Set the Record Reader to a new JSONTreeReader. On the 
JsonTreeReader configure it to use the "Use 'Schema Text' Attribute".

Create a JsonRecordSetWriter and set the Schema Text to:

"{ "type": "record",
"name": "test",
"fields" : [\{"name": "value", "type": "string"},
{"name": "example1", "type": "string"},
{"name": "example2", "type": "string"},
{"name": "example3", "type": "string"},
{"name": "example4", "type": "string"}]
}"

Add the following properties to UpdateRecord

 
||Heading 1||Heading 2||
|/example1|substringAfter(/value, "1") |
|/example2|substringAfter(/value, "123") |
|/example3|substringAfterLast(/value, "1")|
|/example4|substringAfterLast(/value, "123")|

 

Resulting record currently:

[ {
 "value" : "01230123",
 "example1" : "230123",
 "example2" : "30123",
 "example3" : "23",
 "example4" : "3"
} ]

 

 

Problem:

When using the UpdateRecord processor, and the substringAfter() function after 
the search phrase is found it will only increment the substring returned by 1 
rather than the length of the search term. 

Based off XPath and other implementations of substringAfter functions I've seen 
the value returned should remove the search term rather than just the first 
character of the search term.

 

 

Resulting record should be:

[ {
 "value" : "01230123",
 "example1" : "230123",
 "example2" : "30123",
 "example3" : "23",
 "example4" : "3"
} ]

 

I'm cleaning up a fix with test code that will change the increment from 1 to 
the length of the search terms. 

It appears substringBefore are not impacted by the behavior as always returns 
the index before the found search term which is the expected behavior



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to