Search code examples
pentahokettlepentaho-spoon

How to set a default value for a parameter if null?


I need to setup SYSTEM DATE as the default value for my load_date parameter if it is not provided in the runtime. I can achieve this by checking the value passed and assign it accordingly based on a NULL check. Is there an inbuilt feature to achieve this?

I even tried using the if_null step and it seems to be an issue.

This is what I get in my log

2017/11/10 14:19:13 - Spoon - Transformation opened.
2017/11/10 14:19:13 - Spoon - Launching transformation [123]...
2017/11/10 14:19:13 - Spoon - Started the transformation execution.
2017/11/10 14:19:13 - 123 - Dispatching started for transformation [123]
2017/11/10 14:19:19 - get_variables.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:19 - Write to log.0 - 
2017/11/10 14:19:19 - Write to log.0 - ------------> Linenr 1------------------------------
2017/11/10 14:19:19 - Write to log.0 - load_date = null
2017/11/10 14:19:19 - Write to log.0 - 
2017/11/10 14:19:19 - Write to log.0 - ====================
2017/11/10 14:19:19 - get_system_info.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:19 - if_null.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:19 - Write to log.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:22 - Spoon - The transformation has finished!!

This is what my transformation looks like. Embedded details in the picture for each step.

123.ktr


Solution

  • As a matter of facts the If Null does not accept a field in the replace by value, only a value.

    Although other solutions are possible, you may want to use a Modify JavaScript Value. Depending on how the the parameter is given to your transformation by the job, you may have to replace the condition by if(load_date!='null') or if(!load_date.isEmpty()).

    enter image description here