Question

FIELD RENAMER

  • 7 December 2022
  • 5 replies
  • 98 views

Userlevel 2

In my FIELD RENAMER processor my input 6 columns looks  like (1'result.name' , 2'result.adress.street' , 3'result.adress.city' , 4'result.adress.state', 5'result.adress.zip' , 6'result.phone' ) BUT I WANT these output as a column name like(1’name' 2'street' 3city' 4'state' 5'zip' ,6'phone' )And also want to achieve these output in single processor field renamer 


5 replies

Userlevel 2

Hello Lakshmi,

 

Have you spotted this option in the documentation, I have updated it to your example above
 

Remove a prefix or suffix

Say you want to remove an OPS prefix from a set of fields. You can do this by using the following expression to define the source fields to change:

/'result.adress.(.*)'

Then use the following expression to remove the OPS prefix:

/$1

https://docs.streamsets.com/portal/platform-datacollector/latest/datacollector/UserGuide/Processors/FieldRenamer.html?hl=field%2Crenamer

 

Let me know if this works for you

 

Anth

Userlevel 5
Badge +1

@lakshmi_narayanan_t 

To add on @antmcmullen point , I am also  attaching the pipeline  which will give you the result as expected. It covers all the scenarios in it.

 

Kindly check and let me know if it helps.

 

 

Userlevel 2

Hello Lakshmi,

 

Have you spotted this option in the documentation, I have updated it to your example above
 

Remove a prefix or suffix

Say you want to remove an OPS prefix from a set of fields. You can do this by using the following expression to define the source fields to change:

/'result.adress.(.*)'

Then use the following expression to remove the OPS prefix:

/$1

https://docs.streamsets.com/portal/platform-datacollector/latest/datacollector/UserGuide/Processors/FieldRenamer.html?hl=field%2Crenamer

 

Let me know if this works for you

 

Anth

i tried the above mention code but i got this error

Record2-Error Record1 FIELD_RENAMER_00 - Record 'rawData::0_1_3' does not contain fields '/result\.(.*)' : (View Stack Trace... )

Userlevel 2

@lakshmi_narayanan_t

To add on @antmcmullen point , I am also  attaching the pipeline  which will give you the result as expected. It covers all the scenarios in it.

 

Kindly check and let me know if it helps.

 

 

yes I saw and tried that pipe line ,as you applied to achieve the out by applying another processor like field mapper. but my question is to achieve the output by single Renamer processor is Possibile or not.

Userlevel 5
Badge +1

@lakshmi_narayanan_t 

Yes, we can handle it in one processor but it will be field specific . somehow I prepared the solution for you and its working as per case .

 

Can you please use this condition in field mapper processor as given below and it will solve your issue.

 

${str:contains(f:name(),'result.adress.') ? str:replaceAll(f:name(),'result.adress.','') : str:contains(f:name(),'result.') ? str:replaceAll(f:name(),'result.',''):f:name()}

 

 

 

Please let me know if it helps in your case or not.

 

Thanks & Regards

Bikram_

Reply