Tuesday, May 5, 2015

How to Create Context Group in Talend !!

In this post will see how to use context which will

A context group is a set of (usually) related context variables for use within a project.
The steps for creating a context group are as follows:

1. Open the metadata panel, and right-click on the context section.
2. Select the Create context group option.

3. Name the new group such as JobData.
4. Click on the Next button, and you will see the main context variable panel.
                             
                                           
5. Click on + to add a new variable and type in Name such as FileName,Input_FilePath,NumberofRows,Output_FilePath

6. Set the type of variables

                                     
7. Here one variable is of type Directory so for this click on the Values as a table tab, and click on the Default column for Input_FilePath. Click on the … icon.
 8. This will open a directory navigation window, so navigate to the Input_FilePath directory, and click on Finish.
                                       

9.Then click on the Value as tree tab and expand your variable definition. Note that the default context will be called default. To change this name and/or to add other contexts, click on the context icon on the top right hand corner.Now you will see your new/altered context show up in the main dialog. 

10.Define if you want a prompt and prompt text for each variable/context combination. Finally define a value.The Configure Contexts dialog allows you to edit existing contexts or to add new ones. Once you defined your contexts, click OK.

How to use repository context variables within jobs

Once you have created the context variables it is defined in the repository, you can easily add them to your job:
Open the job and click on the Context tab. Then click on the Repository icon in the left corner of the screen.

This pop window will appear select the Context Variables which you want to use in your job and click OK.


Now you can see the variables which you have selected is added in the context tab. Note that the variable will be available with the context prefix in the Script code column.


Creating Context using Database Connection

We will take existing database connection which we have made in database connection post named as my_db.Go to Metadata > Db Connection > my_db right click on it and select Edit connection option then click Next.


In this window click Export as context.


After you've clicked the Export as context button you’ll see the Create/Edit context group screen. Enter a name, purpose and description and click Next. 
Now you’ll see all the context variables that belong to this context group. If you want to change their names you can simply click on them and you can change. 


In the Values as table tab you can edit the values of the context variables by simply clicking the value and changing it. To add a new context, click the context symbol in the upper right corner.

The window that pops up is used to Configure Contexts. To rename the Default context, select it, click Edit, enter Development and click OkTo create a new context, click New, enter the name of the context, in for example Production, and click OK.

Here you will see that an extra column Production appeared. And click Finish.

Here we have exported the connection as a context, now we can use it in a job. Create a new job, use the connection that has been exported as a context .

No comments:

Post a Comment