使用apache-nifi将两列加在一起
我有以下情况。我有一个数据库表:
I have following scenario. I one database table I have :
| id | name | basic_salary | allowance |
_______________________________________|
| 1 | sach | 2000 | 1000 |
| 2 | nala | 5000 | 2500 |
|______________________________________|
添加 basic_salary
和 allow
并使其成为 net_salary
,然后插入到名为 net_salary
add basic_salary
and allowance
togther and making it as net_salary
and insert to a new table called net_salary
第一步,我使用了 ExecuteSQLRecord
处理器,可以获取所有记录。但是问题是:如何添加流文件中的这两列。
For first step, I used ExecuteSQLRecord
processor and can get all the records. But problem is : How to add those two columns coming in flowfile.
所以最终结果应该是:
| id | name | net_salary |
|________________________|
| 1 | sach | 3000 |
| 2 | nala | 7500 |
这直接与我之前的变量问题。
如何处理流文件变量以在 apache-nifi
中执行操作?
This is directly related to my previous variable question.
How to handle flowfile variables to perform operations in apache-nifi
?
我使用了如何计算PostgreSQL中多个列的总和 ExecuteSQL
处理器,但无法理解流文件变量。
I used How to compute the sum of multiple columns in PostgreSQL inside ExecuteSQL
processor, but it can not understand flowfile variables.
有是一个棘手的问题。使用两次 UpdateRecord
。
There is a tricky one. Use UpdateRecord
twice.
第一个是
Record Reader CSVReader
Record Writer CSVRecordSetWriter
Replacement Value Strategy Record Path Value
/net_salary concat(/basic_salary, ',', /allowance)
第二个是
Record Reader CSVReader
Record Writer CSVRecordSetWriter
Replacement Value Strategy Literal Value
/net_salary ${field.value:substringBefore(','):toNumber():plus(${field.value:substringAfter(','):toNumber()})}
给出结果如下。
id,name,basic_salary,allowance,net_salary
1,sach,2000,1000,3000
2,nala,5000,2500,7500