1

I have created a microservice pipeline in streamsets. Upon making a get callout, i have to retrieve data from mysql depending on the parameters sent in the http get url using expression evaluator?

My url is supposed to be like this: http://my.url.com:0191?param1=xyz&param2=abc

I have to retrieve data based on param1 value and param2 value.

Also, how do I handle cases when the params send will be null?

metadaddy
  • 4,234
  • 1
  • 22
  • 46
Luiguixx09
  • 11
  • 1

1 Answers1

0

The URL parameters appear in the queryString record header attribute; you can parse them out in an Expression Evaluator with the Field Expression:

${str:splitKV(record:attribute('queryString'), '&', '=')}

If you set the Output Field to /, then your parameters will now be in the fields /param1 and /param2. You can use these in a MySQL query in the JDBC Lookup processor like this:

-- Assuming col1 is an integer (doesn't need quotes) and col2 is a string (needs quotes)
SELECT * FROM tablename 
WHERE col1 = ${record:value('/param1') AND col2 = '${record:value('/param2')'

You can handle nulls using the record:attributeOrDefault() function to set a default, or by using a Stream Selector to send the record along a different path.

metadaddy
  • 4,234
  • 1
  • 22
  • 46