One Star

[resolved] Cannot create RunIf connector

Hello,
Please take a look at my job screenshot.
I have a simple requirement:
Run the data flow through one of the tMap components based on user input.
I can't accomplish the first step of creating Run If connectors. Talend does not allow me to create Run If connector betwee tMysqlInput and with tMap components.
Please explain me how it should be done.
Thank you,
Peter.
1 ACCEPTED SOLUTION

Accepted Solutions

Re: [resolved] Cannot create RunIf connector

Then Alevy has the correct solution for you. You may need to insert a "dummy" component at the start of the job to get the "if" connector. This can be an empty tJava component.
tJava(empty) +-- if(context.user_input == "Yes" ) --> Input-->tMap-->Output
|
+-- if(context.user_input == "No" ) --> Input-->tMap-->Output
13 REPLIES
Community Manager

Re: [resolved] Cannot create RunIf connector

Hello
tMap can't accept a trigger connector, it must be a input flow, so you can't link a runIf to tMap. You can use a tFixedFlowInput to lead to tMap.
....
|
RunIf
|
tFixedFlowInput---tMap---tLogRow
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Cannot create RunIf connector

Thank you for fast reply, Shong.
I implemented your suggestion. However it does not work as intended.
FixedFlowInput reads only a single row from my MysqlInput which has hundreds of thousands rows. How do I read all rows and pass values for each column as if MysqlInput was directly connected to tMap.
Please see screenshot attached.
Community Manager

Re: [resolved] Cannot create RunIf connector

Hello
Where's your screenshot? I don't know why you will use the RunIf connector, please describe your requirement with more details.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Cannot create RunIf connector

Here is screenshot.
Two tMap have different transformations sets configured. Based on user decision I need to execute only one set of transformations, hence conditional execution.
Your forum site does not pick up images. Can you see what is going on?

Re: [resolved] Cannot create RunIf connector

if you need to base your transform on the incoming data, you should use the output filters inside the tmap to split the output into two different output tables:
step04_mapping --> tMap +--(condition 1)--> output
|
+--(condition 2)--> output
Seven Stars

Re: [resolved] Cannot create RunIf connector

You need to have a complete subjob (input --> tMap --> output) for each possible transformation with RunIf leading to the input component to control which is executed.
One Star

Re: [resolved] Cannot create RunIf connector

@alevy
Doesn't it contradict with what John suggested above?
@John
John, can you explain how to branch execution within tMap? I have prompted context variable which is defined by user input. How to put it inside tMap?

Re: [resolved] Cannot create RunIf connector

it depends on what you are checking with your if condition.
if you are checking the value of a column of your input, you should persue my suggestion.
if you are not checking a column of your input data, please use alevy's suggestion.
One Star

Re: [resolved] Cannot create RunIf connector

With my IF condition I am checking the value of a context variable set by user. Based on this variable value (either 'Yes' or 'No') I need to pass my data flow through different transformations which I coded in tMap. The output should go into the same output table.
Thank you,
Peter.

Re: [resolved] Cannot create RunIf connector

Then Alevy has the correct solution for you. You may need to insert a "dummy" component at the start of the job to get the "if" connector. This can be an empty tJava component.
tJava(empty) +-- if(context.user_input == "Yes" ) --> Input-->tMap-->Output
|
+-- if(context.user_input == "No" ) --> Input-->tMap-->Output
One Star

Re: [resolved] Cannot create RunIf connector

Thank you , John and Alevy!
Just curious, why it is not possible to fork execution at Input component?
Peter.
Seven Stars

Re: [resolved] Cannot create RunIf connector

A conditional flow connector would possibly be a useful feature to have - a number of topics have asked about it - but you can only have multiple flows directly from tMap or tReplicate anyway. You could always submit a feature request on the BugTracker Smiley Happy
A couple of other points:
-- You can achieve the same result as a conditional flow connector by having a tReplicate after your input component with each branch then having a tFilterRow containing your If condition before continuing on to the tMaps. However, this is not as efficient as a proper conditional flow connector would be because the flow is first duplicated before one branch is filtered out of existence.
-- The If condition should probably be context.user_input.equalsIgnoreCase("Yes"); == should not be used for Strings.
-- Depending on the complexity of and differences between the two different tMap transformations, you could still use Garrett's suggestion by having two output tables in tMap with an expression filter for each based on your context variable.
One Star

Re: [resolved] Cannot create RunIf connector

Thanks a lot, Alevy and John.
I implemented John's suggestion - works fine.
Peter.