need to convert query for tmap

Highlighted
Eight Stars RAJ
Eight Stars

need to convert query for tmap

Hi Talend Folks 

                     How to convert below query for tmap in talend

 

if(indicator='L',
if((Type='C' or Type='N') and len(Id)>2,0,
if(Name='P' or Name='R',0,Qty)

Thanks
RAJ

Accepted Solutions
Forteen Stars

Re: need to convert query for tmap

 

as I wrote above - calc number of conditions

 

first test this:

row1.indicator.equals("L")?
(row1.Type.equals("C")||row1.Type.equals("L") )&&(StringHandling.LEN(String.valueOf(row1.Id)))>2?
0 
:(row1.Name.equals("P")||row1.Name.equals("R") )?
0
:row1.Qty
:null 

it will work

 

than - check where miss logic

 

row1.indicator.equals("L")?
--- begin true 1
(row1.Type.equals("C")||row1.Type.equals("L") )&&(StringHandling.LEN(String.valueOf(row1.Id)))>2?
--- begin true 2
0
--- begin false 2 
:(row1.Name.equals("P")||row1.Name.equals("R") )?
---  begin true 3
0
--- begin false 3
:row1.Qty


???? where false 1 ????
:null  ---- (as variant)

 

in other words - each IF must include both part IF YES and IF NOT

-----------

All Replies
Forteen Stars

Re: need to convert query for tmap

try this:

row1.indicator.equals("L")?
(row1.Type.equals("C")||row1.Type.equals("L") ) && StringHandling.LEN(row1.Id) >2?
0 :(row1.Name.equals("P")||row1.Name.equals("R") )?
0 :row1.Qty

 

-----------
Eight Stars RAJ
Eight Stars

Re: need to convert query for tmap

Hi vapukov

 

Thanks for your immediate reply.

when I ran your query I am getting expression to complete error. Here I enclosed the error screenshot also.

 Screenshot (980).png

Thanks
RAJ
Forteen Stars

Re: need to convert query for tmap

check - where You miss : or routes or () or etc

 

... or attach screenshot

 

... or need to check - condition list

 

? it is IF

condition ?
true
:other condition?true:false

need count number of conditions

-----------
Eight Stars

Re: need to convert query for tmap

Hi,

 

Could you please show the Expression which you written in tmap.

 

 

Thanks,

Bharath.

 

Eight Stars RAJ
Eight Stars

Re: need to convert query for tmap

This is my Expression for tmap

 

row1.indicator.equals("L")?
(row1.Type.equals("C")||row1.Type.equals("L") ) && (StringHandling.LEN(String.valueOf(row1.Id))) >2?0 :  

(row1.Name.equals("P")||row1.Name.equals("R") )? 0 : row1.Qty

Thanks
RAJ
Forteen Stars

Re: need to convert query for tmap

 

as I wrote above - calc number of conditions

 

first test this:

row1.indicator.equals("L")?
(row1.Type.equals("C")||row1.Type.equals("L") )&&(StringHandling.LEN(String.valueOf(row1.Id)))>2?
0 
:(row1.Name.equals("P")||row1.Name.equals("R") )?
0
:row1.Qty
:null 

it will work

 

than - check where miss logic

 

row1.indicator.equals("L")?
--- begin true 1
(row1.Type.equals("C")||row1.Type.equals("L") )&&(StringHandling.LEN(String.valueOf(row1.Id)))>2?
--- begin true 2
0
--- begin false 2 
:(row1.Name.equals("P")||row1.Name.equals("R") )?
---  begin true 3
0
--- begin false 3
:row1.Qty


???? where false 1 ????
:null  ---- (as variant)

 

in other words - each IF must include both part IF YES and IF NOT

-----------

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

How OTTO Utilizes Big Data to Deliver Personalized Experiences

Read about OTTO's experiences with Big Data and Personalized Experiences

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

Talend Integration with Databricks

Take a look at this video about Talend Integration with Databricks

Watch Now