问题
I have the following insert statements:
insert into temp1 values (test1, test2)
insert into temp2 values (test3)
Expected results:
insert into temp1 values (100, 200)
insert into temp2 values (300)
Essentially, I wanted to replace the first query literals test1
, test2
with value 100
, 200
respectively and for the second query replace test3
with value 300
. Can someone help with the mapping file for the above use case?
I tried with the following, but it doesn't have any effect.
Search Value (RegEx) Replacement values
(1)(.*values.*)(.*test1)(.*,)(.*test2) -> $2 val1 $4 val2
(2)(.*values.*)(.*test1) -> $2 val3
回答1:
If this is literally the extent of the mapping you need to perform, a regular ReplaceText
processor is enough. Using the settings below results in the desired output:
It simply detects every instance of test
followed by a single digit and replaces it with that digit and 00
.
If you need to use ReplaceTextWithMapping
for more complex lookups, the mapping file must be of the format:
search_value_1 replacement_value_1
search_value_2 replacement_value_2
etc.
The delimiter between the search and replacement values is \t.
--------------------------------------------------
Standard FlowFile Attributes
Key: 'entryDate'
Value: 'Wed Dec 07 10:48:24 PST 2016'
Key: 'lineageStartDate'
Value: 'Wed Dec 07 10:48:24 PST 2016'
Key: 'fileSize'
Value: '66'
FlowFile Attribute Map Content
Key: 'filename'
Value: '56196144045589'
Key: 'path'
Value: './'
Key: 'uuid'
Value: 'f6b28eb0-73b5-4d94-86c2-b7a5d4cc991e'
--------------------------------------------------
insert into temp1 values (100, 200)
insert into temp2 values (300)
来源:https://stackoverflow.com/questions/41022469/nifi-replacetextwithmapping-processor