How to change value for parameters using reformat component in Clover ETL

1.1k Views Asked by At

I am trying to find out a method on how to change the value of a parameter that I have defined and also how to create a new parameter dynamically using REFORMAT component in Clover ETL.

I have written small logic in my transform method which reformat component provides:

        function integer transform() {
            string myparam1 = getParamValue("MY_PARAM1");
            string changeParam = getParamValue("CHANGE_PARAM_VALUE");

            if(changeParam =="true"){
                myparam1 = myparam1 +"_changed";
            }
       // update the value of parameter MY_PARAM1     
       // updateParameter("MY_PARAM1", myparam1 );  

       // create a new parameter
       // createNewParameter("MY_NEW_PARAM", "some_sample_data"); 

            return OK;
        }

From clover designer I tried to check for available methods but I have not found any relevant method that helps me to provide the feature that I am looking for.

I am new to Clover ETL so I am facing difficulty in how to accomplish this, please help me if we can achive this using REFORMAT component or do we need to use a different component?

2

There are 2 best solutions below

0
On

You cannot change value(in easy way, there is maybe a way through direct access with java and model of graph, but this is probably not what you need) of parameters in CloveETL as they are used in static way, all occurences of parameters are resolved during compilation of graph and replaced with resulted values.

If you need dynamic variables, take a look at dictionaries http://doc.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/using-dictionary.html?resultof=%22%64%69%63%74%69%6f%6e%61%72%79%22%20

But you need to think, that dictionary aren't dead replacement for parameters. Static usage of parameters has some points, places of usage, that you cannot replace with dictionary.

BTW why you need to change parameter value during run of the graph? Please explain use case and maybe I could give you some pointers...

0
On

You cannot change value of graph parameters as they are set during the initialization phase of the graph. However, there are a couple of ways of achieving what you probably want:

  • Opt 1: Run your graph on a schedule and then passing the parameter value from the scheduler.

  • Opt 2: Whatever component(s) need the modified value of the parameters put them in a subgraph and create a sub-graph parameter with the same name and pass the modified value as part of your input mapping from the main graph to the sub-graph.