Created on 07-19-2022 05:35 AM - edited 07-19-2022 05:38 AM
Hi,
I want to manipulate below string in updateAttribute processor. I tried replace function etc but it is not working for me. Can anyone suggest to modify below string to change DBName and TableName as per expected output.
query = ${query:replace('nrpuserorgdb2306.status', 'nrpreportdb.user_org_status')}
query : "ALTER TABLE `nrpuserorgdb2306`.`status` \nADD COLUMN `is_deleted` TINYINT NULL AFTER `code`"
Expected output:
query : ALTER TABLE `nrpreportdb`.`user_org_status` ADD COLUMN `is_test` TINYINT NULL AFTER `code`
Created 07-20-2022 05:02 AM
@AbhishekSingh It looks like the issue with the Replace Expression Language was just the ` around the database and table name. That works for me as follows:
${query:replace('`nrpuserorgdb2306`.`status`', '`nrpreportdb`.`user_org_status`')}
Here is my flow to test:
Notice the use of a simple flow to test the concept. I also set query in GenerateFlowfile and define a separate query2 in UpdateAttribute. I always work in ways that prove functionality, then when the concept is working, take the lesson learned into real flows.
Some additional Screen Shots:
Template and Flow Definition File on my GitHub:
https://github.com/cldr-steven-matison/NiFi-Templates
Created 07-20-2022 05:02 AM
@AbhishekSingh It looks like the issue with the Replace Expression Language was just the ` around the database and table name. That works for me as follows:
${query:replace('`nrpuserorgdb2306`.`status`', '`nrpreportdb`.`user_org_status`')}
Here is my flow to test:
Notice the use of a simple flow to test the concept. I also set query in GenerateFlowfile and define a separate query2 in UpdateAttribute. I always work in ways that prove functionality, then when the concept is working, take the lesson learned into real flows.
Some additional Screen Shots:
Template and Flow Definition File on my GitHub:
https://github.com/cldr-steven-matison/NiFi-Templates