Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Nifi CSV rows processing to sql server - Check primary key

avatar
New Contributor

Hello Community!

Hope you're all doing fine.

 

I'm beggining my Nifi studying and i'de like to replicate a process that i have running in other plataforms.

My goal is to read a CSV and process it row by row to insert into a sql server table.

 

So far so good, i was able to do this with the following:

 

GetFile -> SplitRecord -> ConvertRecord (to json) -> ConvertJSONtoSQL -> UpdateAttribute (date conversion) -> PutSQL.

 

But i need to validade if the record already exists in the destiny table. Can anyone help me with that? Already looked for but i wasn't able to find somethig like it.

 

If you guys have a solution that is better and completely different, no problem, i'm open to any change.

 

Thanks in advance!

2 ACCEPTED SOLUTIONS

avatar
New Contributor

Hello everyone!

 

I'm here to post the solution i was able to develop to solve my problem.

 

I managed to do the following:

 

GetFile -> SplitRecord (converting to JSON) -> EvaluateJsonPath (to get key columns) -> ExecuteSQL (select with keys to check if exists) -> RouteOnAttribute (to execute update or insert depending on select result) -> ExecuteSQL (It can be update or insert).

 

Capturar.PNG

View solution in original post

avatar
Master Guru

executesqlrecord or putdatabaserecord may be easier.

View solution in original post

4 REPLIES 4

avatar
New Contributor

Hello everyone!

 

I'm here to post the solution i was able to develop to solve my problem.

 

I managed to do the following:

 

GetFile -> SplitRecord (converting to JSON) -> EvaluateJsonPath (to get key columns) -> ExecuteSQL (select with keys to check if exists) -> RouteOnAttribute (to execute update or insert depending on select result) -> ExecuteSQL (It can be update or insert).

 

Capturar.PNG

avatar
Master Guru

executesqlrecord or putdatabaserecord may be easier.

avatar
New Contributor

Hello Timothy!

 

Could you elaborate, please?