Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

ReplaceText doesn't work properly

avatar
Contributor

replacetext.jpgDear all,

I want to create a CSV file on a monthly bases by executing a SQL script. For this I am using ExecuteSQL processor and ConvertAvroToJSON, SplitJSON, EvaluateJsonPath, ReplaceText and PutFile.

My problem is with ReplaceText processor. Provide a list with empty values even if the JSON values are there and are valid. Please see the attached files. I tried every recommended solution provided here on community but didn't help me.

Kind regards,
Stefan


executesql.jpgevaluatejsonpath.jpgsplitjson.jpg
1 ACCEPTED SOLUTION

avatar
Master Guru

@Stefan Constantin

As you are doing ExecuteSql to pull data the format of output flowfile is in Avro and having embedded schema with the content so we can use Embedded AvroSchema as the Schema Access Strategy in ConvertRecord processor by using embedded schema we are skipping defining Schema Registry in both Reader and Writer controller services.

Convert Record processor Configs:-

Record Reader

AvroReader

Avro Reader Configs:-

67455-avroreader.png

Record Writer

CSVRecordSetWriter

Csv set writer Configs:-

67456-csvsetwriter.png

With this configs we are reading the Avro data and converting to Csv, if you want header then keep includer header line property to True.

Flow xml for your reference avro-to-csv.xml

View solution in original post

13 REPLIES 13

avatar
Contributor

Hello @Shu,

I didn't added here but of course I tried also with upper letters and still the same issue with ConvertRecord.
With the EvaluateJsonPath, same issue again. I tried many other things but nothing worked. I was thinking that it will be really easy to output a file from a simple select query from a table but it seems that is not like that..

avatar
Master Guru

@Stefan Constantin

I tried with your sample record and i'm able to get the csv data as i have mentioned in the comment above and also i have attached my xml you can save and upload to your NiFi instance and compare both find where are you missing some configs.

Could you share your Convert Record processors Record Reader, Record Writer,Avro Schema Registry Config screenshots.

avatar
Master Guru

@Stefan Constantin

As you are doing ExecuteSql to pull data the format of output flowfile is in Avro and having embedded schema with the content so we can use Embedded AvroSchema as the Schema Access Strategy in ConvertRecord processor by using embedded schema we are skipping defining Schema Registry in both Reader and Writer controller services.

Convert Record processor Configs:-

Record Reader

AvroReader

Avro Reader Configs:-

67455-avroreader.png

Record Writer

CSVRecordSetWriter

Csv set writer Configs:-

67456-csvsetwriter.png

With this configs we are reading the Avro data and converting to Csv, if you want header then keep includer header line property to True.

Flow xml for your reference avro-to-csv.xml

avatar
Contributor

Hello everyone !
I tried with Embedded schema, like Shu mentioned, and now everything is working perfectly. I feel so bad that it was so easy and simple, just few processors...anyway, thank you for your time and help, I really appreciate it !

Kind regards,
Stefan