1

I have a question regarding the output of a job.

Would it be possible to make an output of a job dynamic? What I mean is being able to configure a wanted output via a property or something? The user should be able to choose in what kind of database he wants the data to be imported by modifying a property.

Apparently, this can be done using a runIf - I unfortunately could not figure out how to do that.

The run if can only be used for booleans. For instance when a condition is met, the existence (or non-existence) of a file, if the number of rows returned is greater than 100, and countless other conditions.

How would it be possible the check if the context variable equals a specific String? For instance, if context.test = "postgres" then tpostgresqloutput, if context.test = "snowflake" then tsnowflakeoutput?

e.g.

job > tPostgresqlOutput > run if > context.test = "postgres"
job > tsnowflakeoutput > run if > context.test = "snowflake"

Thanks, BR

Djabone
  • 424
  • 4
  • 17

1 Answers1

2

For String comparison in RunIf, you can use:

context.test.equalsIgnoreCase("postgres")

You may want to connect the appropriate dataflow to the above RunIf depending on whether it is postgres or snowflake.

CleanBold
  • 1,551
  • 1
  • 14
  • 37
  • Thanks for your help, that leads to a type mismatch - cannot convert from boolean to String – Djabone Aug 03 '21 at 11:59
  • The condition in RunIf should evaluate to Boolean, that is what the expression does. I assume your context.test variable is String datatype. Where do you get "cannot convert from boolean to String" error? – CleanBold Aug 03 '21 at 12:39
  • Exactly, my context.test is a String datatype. tMap -> tjavarow -> runif -> db is what I do – Djabone Aug 03 '21 at 12:45
  • 1
    RunIf is used for control flow, not dataflow. You might need to change your flow like this: RunIf -> Source -> tMap -> tJavaRow -> db_postgres. This will be order1 of runIf if context.test is postgres. And in order2, you can do the same for snowflake. – CleanBold Aug 03 '21 at 17:54
  • Makes a lot more sense. I'll try that and will let you know how it went. Thank you! – Djabone Aug 04 '21 at 09:19
  • I tried it and attached screenshots of my job for a better understanding. I still can't make it work. – Djabone Aug 04 '21 at 09:30
  • @Djabone -Did you write the condition in the settings of RunIf link? context.test.equalsIgnoreCase("postgres"). The code that you shown - if is blank means there is no condition written in settings of RunIf link. – CleanBold Aug 04 '21 at 17:05
  • Yes of course. That's what is disturbing me ... the tjava contains context.test.equalsIgnoreCase("postgres") >runif > rest of job – Djabone Aug 05 '21 at 09:05
  • @Djabone - Have you written the condition in tJava or RunIf? You have to write inside RunIf (not tJava). – CleanBold Aug 05 '21 at 10:29
  • Well, that was the problem. I literally did not find any document saying the condition had to be in the IF trigger. Thought it had to be in a msgBox or a java component before the if. Thank you, it's working fine now. I'll mark your answer as correct! Another thing is that the more databases I have, the bigger my job is since I always have to duplicate it with different outputs per db. Would be really cool if there was a "nicer" way to do it :) – Djabone Aug 05 '21 at 11:50