Home / Talend

Printing Your Input and Output Query - TALEND

Rating: 5.0Blog-star
Views: 3566
by Ravindra Savaram
Last modified: December 17th 2020

Printing your input query

If your result set isn’t as expected and you are struggling to understand why, then it is really useful to be able to see the QUERY that was executed to give you the result. This recipe shows how this can be done.

If you would like to Enrich your career with a Talend certified professional, then visit Mindmajix - A Global online training platform: “Talend Certification Course” . This course will help you to achieve excellence in this domain.

Getting ready

Open the job jo_cook_ch07_0030_printInputQuery, which is a copy of the job from the previous recipe.

How to do it…

The steps to be performed are as follows:

  • Add a tJava component.

  • Add OnSubjobOk from tMysqlInput to tJava.

  • Open tJava and add the following line:

System.out.println("nExecuted query: n"+ ((String)globalMap.get("tMysqlInput_1_QUERY")));
  • Run the job, and you will see the query as it was sent to the database.

How it works…

Many of the Talend components will drop information to globalMap, for use by downstream components/subjobs.

In the case of tMysqlInput, one of the values written to globalMap is the query that was used to produce the result set, which is what we printed in the tJava component.

--------          Also Read: Talend Tutorial          --------

Printing your output QUERY

This recipe shows how to achieve an update, delete, or insert, which are all functions available through tMysqlOutput.

Getting ready

Open the job jo_cook_ch07_0050_printOutputSQL, which is a copy of the job from the previous recipe.

How to do it…

The steps to be performed are as follows:

  • Add tJavaRow and link it to tMysqlOutput.

  • Add the following code:

System.out.println(((String)globalMap.get("tMysqlOutput_1_QUERY") ));
  • Run the job. You will see that the output is all null.

  • Open the tMysqlOutput component and click on the Advanced settings

  • Click the field Enable debug mode as shown in the following screenshot:

Advanced settings

  • Run the job, and you will see the individual SQL statements that were executed.

Frequently Asked TALEND Interview Questions & Answers

How it works…

Before using a tMysqlOutput component, you must first set the Mode to Debug in the Advanced tab for the component. This will allow you to capture the query for every row written to the table.

Explore TALEND Sample Resumes! Download & Edit, Get Noticed by Top Employers!Download Now!

About Author

NameRavindra Savaram
Author Bio


Ravindra Savaram is a Content Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.