Talend Open Studio Cookbook - Rick Barton - E-Book

Talend Open Studio Cookbook E-Book

Rick Barton

0,0
34,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Data integration is a key component of an organization's technical strategy, yet historically the tools have been very expensive. Talend Open Studio is the world's leading open source data integration product and has played a huge part in making open source data integration a popular choice for businesses worldwide.This book is a welcome addition to the small but growing library of Talend Open Studio resources. From working with schemas to creating and validating test data, to scheduling your Talend code, you will get acquainted with the various Talend database handling techniques. Each recipe is designed to provide the key learning point in a short, simple and effective manner.This comprehensive guide provides practical exercises that cover all areas of the Talend development lifecycle including development, testing, debugging and deployment. The book delivers design patterns, hints, tips, and advice in a series of short and focused exercises that can be approached as a reference for more seasoned developers or as a series of useful learning tutorials for the beginner.The book covers the basics in terms of schema usage and mappings, along with dedicated sections that will allow you to get more from tMap, files, databases and XML.

Geared towards the whole lifecycle, the Talend Open Studio Cookbook shows readers great ways to handle everyday tasks, and provides an insight into all areas of a development cycle including coding, testing, and debugging of code to provide start-to-finish coverage of the product.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 297

Veröffentlichungsjahr: 2013

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Talend Open Studio Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introduction and General Principles
Before you begin
Installing the software
How to do it…
Enabling tHashInput and tHashOutput
How to do it…
2. Metadata and Schemas
Introduction
Schema metadata
Schemas
Repository schemas
Generic schemas
Shared schemas
Generated data sources
Fixed schemas and columns
Hand-cranking a built-in schema
Getting ready
How to do it…
How it works…
There’s more...
Date patterns
Nullable elements
Propagating schema changes
Getting ready
How to do it…
How it works…
There’s more…
Creating a generic schema from the existing metadata
How to do it…
How it works…
Cutting and pasting schema information
Getting ready
How to do it…
How it works…
There’s more…
Dropping schemas to empty components
Getting ready
How to do it…
How it works…
There’s more…
Creating schemas from lists
Getting ready
How to do it...
How it works…
There’s more…
3. Validating Data
Introduction
Enabling and disabling reject flows
Getting ready
How to do it…
How it works…
There's more...
See also
Gathering all rejects prior to killing a job
Getting ready
How to do it…
How it works…
There's more...
See also
Validating against the schema
Getting ready
How to do it…
How it works…
Rejecting rows using tMap
Getting ready
How to do it…
How it works…
There's more…
Checking a column against a list of allowed values
Getting ready
How to do it…
How it works…
There's more…
See also
Checking a column against a lookup
Getting ready
How to do it…
How it works…
Creating validation rules for more complex requirements
Getting ready
How to do it…
How it works…
There's more…
See also
Creating binary error codes to store multiple test results
Getting ready
How to do it…
How it works…
There's more…
Decrypting the error code
4. Mapping Data
Introduction
The tMap component
Single line of code
Batch versus real time
Simple mapping and tMap time savers
Getting ready
How to do it...
How it works...
There's more…
Creating tMap expressions
Getting ready
How to do it...
How it works...
There's more…
Testing expressions
Expression editor
Getting around the 'one line' limitation
See Also
Using the ternary operator for conditional logic
Getting ready
How to do it...
Single ternary expression: if-then-else
Ternary in ternary: if-then-elsif-then-else
How it works…
There's more…
Using intermediate variables in tMap
Getting ready
How to do it…
How it works…
There's more…
Filtering input rows
Getting ready
How to do it...
How it works…
There's more…
Splitting an input row into multiple outputs based on input conditions
Getting ready
How to do it...
How it works…
There's more…
Joining data using tMap
Getting ready
How to do it...
How it works…
There's more…
See Also
Hierarchical joins using tMap
Getting ready
How to do it...
How it works…
Using reload at each row to process real-time / near real-time data
Getting ready
How to do it...
How it works…
Loading the data into memory
The globalMap key
The WHERE clause
The result
There's more…
5. Using Java in Talend
Introduction
Performing one-off pieces of logic using tJava
Getting ready
How to do it…
How it works…
See also
Setting the context and globalMap variables using tJava
Getting ready
How to do it…
How it works…
There's more…
See also
Adding complex logic into a flow using tJavaRow
Getting ready
How to do it…
How it works…
Creating pseudo components using tJavaFlex
Getting ready
How to do it…
How it works…
There's more…
Creating custom functions using code routines
Getting ready
How to do it…
How it works…
There's more…
See also
Importing JAR files to allow use of external Java classes
Getting ready
How to do it…
How it works…
There's more…
6. Managing Context Variables
Introduction
Transportable code
Context variables
Common values in contexts
Passing command line parameters
Setting context variables in the code
Database context variables
Creating a context group
How to do it...
How it works...
There’s more…
Context types
Prompt for variable values using the tree mode
Adding a context group to your job
Getting ready
How to do it...
How it works…
There’s more…
Adding contexts to a context group
Getting ready
How to do it...
There’s more…
Using tContextLoad to load contexts
Getting ready
How to do it...
How it works...
There’s more…
Print operations
Warnings
Context file location
Using implicit context loading to load contexts
Getting ready
How to do it...
How it works...
There’s more…
Turning implicit context loading on and off in a job
Getting ready
How to do it...
How it works...
Setting the context file location in the operating system
Getting ready
How to do it...
How it works…
There’s more…
Variable not present
Implicit context load
7. Working with Databases
Introduction
Setting up a database connection
Getting ready
How to do it...
How it works...
There's more…
Using the connection
Always create database connections
Connection names
Context
Importing the table schemas
Getting ready
How to do it…
How it works...
There's more…
Reading from database tables
Getting ready
How to do it…
Selected rows and columns
Multiple tables and complex queries
How it works…
There's more…
Efficiency versus readability
SQL string
SQL style
Using context and globalMap variables in SQL queries
Getting ready
How to do it…
How it works…
There's more…
The globalMap variables
Developing the query
Reloading at each row
Printing your input query
Getting ready
How to do it…
How it works…
There's more…
Writing to a database table
Getting ready
How to do it…
How it works…
There's more…
Creating tables
Update and delete keys
Batches
Bulk loading
Bulk loading to temp table
Printing your output query
Getting ready
How to do it…
How it works…
There's more…
Managing database sessions
Getting ready
How to do it…
How it works…
Executions
There's more…
Multiple outputs
Don't forget the commit
Committing but not closing
Passing a session to a child job
Getting ready
How to do it…
How it works…
Selecting different fields and keys for insert, update, and delete
Getting ready
How to do it…
How it works…
There's more...
Updating
Deleting
Capturing individual rejects and errors
Getting ready
How to do it…
How it works…
There's more…
Die on error
Efficiency
Error management
Database and table management
Getting ready
How to do it…
How it works…
There's more…
Managing surrogate keys for parent and child tables
Getting ready
How to do it…
How it works…
There's more...
Added efficiency using hashMap key table
Ranges
Sequences
Auto increment keys
The LastInsertId component
Auto increment procedure
Rewritable lookups using an in-process database
Background
Getting ready
How to do it…
How it works…
In-memory components
Initialize the data
tMap
Write back
There's more…
Memory
See also
8. Managing Files
Introduction
Appending records to a file
Getting ready
How to do it...
How it works...
There's more…
Concatenating files using the append method
Reading rows using a regular expression
Getting ready
How to do it...
How it works...
There's more…
Using temporary files
Getting ready
How to do it...
How it works...
There's more…
See also
Storing intermediate data in the memory using tHashMap
Getting ready
How to do it...
How it works...
There's more…
Reading headers and trailers using tMap
Getting ready
How to do it...
How it works...
There's more…
Reading headers and trailers with no identifiers
Getting ready
How to do it...
How it works...
Using the information in the header and trailer
Getting ready
How to do it...
Validation subjob
Use the header information subjob
How it works...
Validating using the trailer information
Using the header information in the detail
There's more…
Adding a header and trailer to a file
Getting ready
How to do it...
How it works...
There's more…
See also
Moving, copying, renaming, and deleting files and folders
Getting ready
How to do it...
Copying a file to another directory
Copying file to a different name
Renaming a file
Moving a file
Deleting a file
How it works...
There's more…
Capturing file information
Getting ready
How to do it...
How it works...
There's more…
Processing multiple files at once
Getting ready
How to do it...
How it works...
There's more…
Processing control/validation files
Getting ready
How to do it...
How it works...
There's more…
Creating and writing files depending on the input data
Getting ready
How to do it...
How it works...
tJavaRow code explained
There's more…
9. Working with XML, Queues, and Web Services
Introduction
Using tXMLMap to read XML
Getting ready
How to do it...
How it works...
There's more…
Document objects
XML Structure
Using tXMLMap to create an XML document
Getting ready
How to do it...
How it works...
There's more…
Reading complex hierarchical XML
Getting ready
How to do it...
How it works...
There's more…
Managing the relationships
File information
XML to database mapping
XPATH
Web service XML
Writing complex XML
Understanding the XML structure
Node
Method
Java DOM
Getting ready
How to do it...
How it works...
So here we go…
tWriteXMLField
Code utilities
tFlowToIterate
tHash components
XPATH Condition
Putting it all together
There's more…
Job "shape"
Calling a SOAP web service
Getting ready...
How to do it...
How it works...
There’s more…
Decoding the response
Using web service calls in-flow
Calling a RESTful web service
Getting ready
How to do it...
How it works...
There's more…
Reading and writing to a queue
Getting ready
How to do it...
How it works...
There's more…
Ensuring lossless queues using sessions
Getting ready
How to do it...
How it works...
There's more…
10. Debugging, Logging, and Testing
Introduction
Debugging
Logging
Testing
Find the location of compilation errors using the Problems tab
Getting ready
How to do it...
How it works...
There's more…
Locating execution errors from the console output
Getting ready
How to do it...
How it works...
There's more…
See also
Using the Talend debug mode – row-by-row execution
Getting ready
How to do it...
How it works...
There's more…
See also
Using the Java debugger to debug Talend jobs
Getting ready
How to do it...
How it works...
There's more…
Using tLogRow to show data in a row
Getting ready
How to do it...
How it works...
There's more…
Using tJavaRow to display row information
Getting ready
How to do it...
How it works...
There's more…
Using tJava to display status messages and variables
Getting ready
How to do it...
How it works...
Printing out the context
Getting ready
How to do it...
How it works...
There's more…
Dumping the console output to a file from within a job
Getting ready
How to do it...
How it works...
There's more…
Creating simple test data using tRowGenerator
Getting ready
How to do it...
How it works...
There's more…
Creating complex test data using tRowGenerator, tFlowToIterate, tMap, and sequences
Getting ready
How to do it...
How it works...
There's more…
Creating random test data using lookups
Getting ready
How to do it...
How it works...
There's more…
Creating test data using Excel
Getting ready
How to do it...
How it works...
There's more…
Testing logic – the most-used pattern
Getting ready
How to do it...
How it works...
There's more…
Killing a job from within tJavaRow
Getting ready
How to do it...
How it works...
11. Deploying and Scheduling Talend Code
Introduction
Context Variables
Executable code
Managing job dependencies within Talend
Creating compiled executables
How to do it...
How it works…
Using a different context
Getting ready
How to do it…
How it works…
There's more…
Adding command-line context parameters
Getting ready
How to do it…
How it works…
There's more…
Managing job dependencies
Getting ready
How to do it…
How it works…
There's more…
Die on error
Adding error checks to the schedule
Restartability
Capturing and acting on different return codes
Getting ready
How to do it…
How it works…
There's more…
Returning codes from a child job without tDie
Getting ready
How to do it…
How it works…
There's more…
Passing parameters to a child job
Getting ready
How to do it…
How it works…
There's more
Executing non-Talend objects and operating system commands
Getting ready
How to do it…
How it works…
There's more…
12. Common Mistakes and Other Useful Hints and Tips
Introduction
My tab is missing
How to do it…
Show view:
Reset the perspective
Finding the code routine
How to do it…
Finding a new context variable
How to do it…
Reloads going missing at each row global variable
How to do it...
Dragging component globalMap variables
Some complex date formats
Capturing tMap rejects
Adding job name, project name, and other job specific information
Printing tMap variables
Stopping memory errors in Talend
Increasing the memory allocated to a job
Reducing lookup data
Using hashMap/in-memory tables
Splitting the job
Dropping data to disk
Split the files
Hardware solutions
A. Common Type Conversions
B. Management of Contexts
Introduction
Manipulating contexts in Talend Open Studio
Understanding implicit context loading
Understanding tContextLoad
Manually checking and setting contexts
Index

Talend Open Studio Cookbook

Talend Open Studio Cookbook

Copyright © 2013 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: October 2013

Production Reference: 2221013

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78216-726-6

www.packtpub.com

Cover Image by Artie Ng (<[email protected]>)

Credits

Author

Rick Barton

Reviewers

Robert Baumgartner

Mustapha EL HASSAK

Viral Patel

Stéphane Planquart

Acquisition Editor

James Jones

Lead Technical Editor

Amey Varangaonkar

Technical Editors

Monica John

Mrunmayee Patil

Tarunveer Shetty

Sonali Vernekar

Project Coordinator

Abhijit Suvarna

Proofreader

Clyde Jenkins

Indexer

Tejal R. Soni

Production Coordinator

Adonia Jones

Cover Work

Adonia Jones

About the Author

Rick Barton is a freelance consultant who has specialized in data integration and ETL for the last 13 years as part of an IT career spanning over 25 years.

After gaining a degree in Computer Systems from Cardiff University, he began his career as a firmware programmer before moving into Mainframe data processing and then into ETL tools in 1999.

He has provided technical consultancy to some of the UK’s largest companies, including banks and telecommunications companies, and was a founding partner of a “Big Data” integration consultancy.

Four years ago he moved back into freelance development and has been working almost exclusively with Talend Open Studio and Talend Integration Suite, on multiple projects, of various sizes, in UK. It is on these projects that he has learned many of the lessons that can be found in this, his first book.

I would like to thank my wife Ange for support and my children, Alice and Ed for putting up with my weekend writing sessions.

I’d also like to thank the guys at Packt for keeping me motivated and productive and for making it so easy to get started. Their professionalism and most especially their confidence in me, has allowed me to do something I never thought I would.

About the Reviewers

Robert Baumgartner has a degree in Business Informatics from Austria, Europe, where he is living today. He began his career in 2002 as a business intelligence consultant working for different service companies. After this he was working in the paper industry sector as a consultant and project manager for an enterprise resource planning (ERP) system. In 2009 he founded his company “datenpol”—a service integrator specialist in selected open source software products focusing on business intelligence and ERP. Robert is an open source enthusiast who held several speeches at open source events. The products he is working on are OpenERP, Talend Data Integration, and JasperReports. He is contributing to the open source community by sharing his knowledge with blog entries at his company blog http://www.datenpol.at/blog and he commits software to github like the OpenERP Talend Connector component which can be found at https://github.com/baumgaro/OpenERP-Talend-Component.

Mustapha EL HASSAK is a computer sciences fanatic since many years, he obtained a Bachelor’s Degree in Mathematics in 2003 then attended university to study Information Technology. After five years of study, he joined the largest investment bank in Morocco as an IT engineer. After that he worked in EAI, an IT services company specialized in insurance, as a senior developer responsible of data migration. He has always worked with Talend Open Studio and sometimes with Business Objects. This is the first time he is working on a book, but he wrote several articles in French and English about Talend on his personal blog.

I would like to thank my parents, Khadija and Hassan, Said, my brother and Asmae, my sister for their support over the years. And I express my gratitude to Halima, my wife for her continued support and encouragement. Finally, I would like to thank Sirine, my little girl.

Viral Patel holds Masters in Information Technology (Professional) from University of Southern Queensland, Australia. He loves playing with Data. His area of interest and current work includes Data Analytics, Data Mining, and Data warehousing. He holds Certification in Talend Open Studio and Talend Enterprise Data Integration. He has more than four years of experience in Data Analytics, Business Intelligence, and Data warehousing.

He currently works as ETL Consultant for Steria India Limited. It is an European MNC providing consulting services in various sectors. Prior to Steria, he was working as BI Consultant where he has successfully implemented BI/DW cycle and provided consultation to various clients.

I would like to thank my grandfather Vallabhbhai, father Manubhai (who is my role model), mother Geetaben, my wife Hina, my sister Toral and my lovely son Vraj. Without their love and support, I would be incomplete in my life. I thank them all for being in my life and supporting me.

Stéphane Planquart is a Lead Developer with a long expertise in Data Management. He started to program when he was ten years old. In twenty years, he worked on C, C++, Java, Python, Oracle, DB2, MySql, PostgreSQL. From the last ten years, he worked on distinct types of projects like the database of the largest warehouse logistics in Europe where he designed the data-warehouse and new client/server application. He worked also on an ETL for the electric grid of France or 3D program for a web browser. Now he works on the application of a payment system in Europe where he designs database and API.

www.PacktPub.com

Support files, eBooks, discount offers and more

You might want to visit www.PacktPub.com for support files and downloads related to your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt’s online digital book library. Here, you can access, read and search across Packt’s entire library of books. 

Why Subscribe?

Fully searchable across every book published by PacktCopy and paste, print and bookmark contentOn demand and accessible via web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

Preface

Talend Open Studio is the world’s leading open source data integration solution that enables rapid development of data transformation processes using an intuitive drag-and-drop user interface.

Talend Open Studio Cookbook contains a host of techniques, design patterns, and tips and tricks, based on real-life applications, that will help developers to become more effective in their use of Talend Open Studio.

What this book covers

Chapter 1, Introduction and General Principles, introduces some of the key principles for Talend development and explains how to install the provided code examples.

Chapter 2, Metadata and Schemas, shows how to build and make use of Talend data schemas.

Chapter 3, Validating Data, demonstrates different methods of validating input data and handling invalid data.

Chapter 4, Mapping Data, shows how to map, join, and filter data from input to output in both batch and real-time modes.

Chapter 5, Using Java in Talend, introduces the different methods for extending Talend functionality using Java.

Chapter 6, Managing Context Variables, illustrates the different methods for handling context variables and context groups within Talend projects and jobs.

Chapter 7, Working with Databases, provides insight into reading from and writing to a database, generating and managing surrogate keys, and managing database objects.

Chapter 8, Managing Files, covers a mix of techniques for reading and writing different file types including header and trailer processing. It also includes methods for managing files.

Chapter 9, Working with XML, Queues, and Web Services, covers tools and techniques for real-time/web service processing including XML, and reading and writing to services and queues.

Chapter 10, Debugging, Logging, and Testing, demonstrates the different methods for finding problems within Talend code, and how to log status and issues and techniques for generating test data.

Chapter 11, Deployment and Scheduling Talend Code, introduces the Talend executable and parameters, as well as managing job dependencies.

Chapter 12, Common Mistakes and Other Useful Hints and Tips, contains valuable tools and techniques that don’t quite fit into any of the other chapters.

Appendix A, Common Type Conversions, is a useful table containing the methods for converting between Talend data types.

Appendix B, Management of Contexts, is a in-depth discussion as to the pros and cons of the various methods for managing project parameters, and what types of projects the different methods are suited to.

What you need for this book

To attempt the exercises in this book, you will need the following software

The latest version of Talend Studio for ESB. At the time of writing, this was 5.3The latest version of MySQLMicrosoft Office Word & Excel or other compatible office software.

It is also recommended that you find a good text editor, such as Notepad++.

Who this book is for

This book is intended for beginners and intermediate Talend users who have a basic working knowledge of the Talend Open Studio software, but wish to know more.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.

If there is a topic that you have expertise and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the erratasubmissionform link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. Introduction and General Principles

The aim of this book is to provide you, the Talend developer, with a set of common (and sometimes not so common) tasks and examples that, we hope, will help you in:

Developing Talend jobs more rapidlySolving Talend issues more quicklyGaining a wider knowledge of the Talend productGaining a better understanding of the capabilities of Talend

This cookbook is primarily intended as a reference guide, however, the chapters have been organized in such a way that it can also be used as a means of rapidly developing your Talend skills by working through the exercises in sequence from front to back.

For the more experienced developers, some of the recipes in this book may seem very simple, because they describe a feature of Talend that you may already know, but we are hoping that this isn't the case for everyone, and that there will be something in the book for developers of all levels of experience.

Many of the recipes in the book require you to complete sections of a partially built job, so it is assumed that in the real world you would be able to get to the starting point independently. Our thinking behind this is that we wanted to squeeze in as many recipes in the book as possible, so only the relevant steps that need to be performed and understood for a particular point to be made, are described in detail within each recipe.

Many any of the examples will write their output to the Talend log/console window when we could easily have written the data out to files or tables. However, the decision was made to provide an easy means (in most cases) of viewing the results of an exercise without having to leave the studio.

Before you begin

Before you begin the exercises in the book, it is worth becoming familiar with some of the key concepts and best practices.

Keep code changes small and test often

When developing using Talend, as with any other development tool, it is recommended to code in short bursts and test (run) frequently.

By keeping each change small, it is much easier to find where and what has caused problems during compilation and execution.

Chapter 10, Debugging, Logging, and Testing, is dedicated to debugging and logging; however, observing the preceding method will save time having to perform debugging steps that can sometimes take a long time.

Document your code

Talend sub-jobs have the ability to add titles, and every component in Talend has the option to add documentation for the component. Where you use Java, you should use the Java comment structures to document the code. Remember to use all these methods as you go along to ensure that your code is well documented.

Contexts and globalMap

context and globalMap are global areas used to store data that can be used by all components within a Talend job.

context variables are predefined prior to job execution in a context group, whereas globalMap variables are created on the fly at any point within a job.

Context variables

Context variables are used by Talend to store parameter information, and can be used:

To pass information into a job from the command line and/or a parent jobTo manage values of parameters between environmentsTo store values within a job or set of jobs

Chapter 6, Managing Context Variables, is dedicated to the use and management of context variables within Talend

globalMap

globalMap is a very important construct within Talend, in that:

Almost every component will write information to globalMap once it completes execution (for example NB_LINE is the number of rows processed in a component).Certain components, such as tFlowToIterate or tFileList, will store data in globalMap variables for use by downstream components.Developers can read and write to globalMap to create global variables in an ad hoc fashion. The use of global variables can often be the best way to ensure code is simple and efficient.

Java

Talend is a Java code generator, so having a little Java knowledge can help when using Talend. There are many Java tutorials for beginners online, and a little time spent learning the basics will help speed up your understanding of Talend.

Other background knowledge

As a data integrator, you will be expected to understand many technologies and how to interface with them, and this book assumes a basic knowledge of many of the most frequent data sources and targets.

Chapter 7, Working with Databases, relates to using Talend with databases. We have chosen to use MySQL, because it is quick to install, simple to use, and readily available. Basic knowledge of SQL and MySQL will therefore be required to perform the exercises in this chapter.

Other chapters will also assume knowledge of csv files, MS Excel, XML, and web services.

Installing the software

This cookbook comes with a package of jobs and scripts that you will need to complete the recipes. The instructions for installing the code and scripts are detailed in the following section:

How to do it…

All templates, completed code, and data are in the cookbook.zip file.Unzip cookbook.zip into a folder on your machine.Copy the directory cookbookData to a directory on your machine (we recommend C:\cookbookData or the linux/MacOS equivalent)Download and install the latest version of Talend Open Studio for enterprise service bus (ESB) from www.talend.com.Open Talend Open Studio, and you will be prompted to create a new project.Name the new project cookbook.Open the project.Right mouse click on the Job Designs folder in the Repository panel, and select the option Import Items.This opens the import wizard. Click the Select archive file option, and then navigate to your unzipped cookbook directory and select the zip file named cookbookTalendJobs.zip.Click on Finish to import all the Talend artifacts.If you copied your data to C:\cookbookData, then you can ignore the next steps, and you have completed the installation of the cookbook software.Open the cookbook context, as shown in the following screenshot, and click Next at the first window.Open the Values as a table panel and change the value of cookbookData to your chosen directory, as shown in the following screenshot:Click Finish to complete the installation process.

Enabling tHashInput and tHashOutput

Many of the exercises rely on the use of tHashInput and tHashOutput components. Talend 5.2.3 does not automatically enable these components for use in jobs. To enable these components perform the instructions in the following section:

How to do it…

On the main menu bar navigate to File | Edit Project properties to open the properties dialogue.Select Designer then Palette Settings.Click on the Technical folder and then click on the button shown in the following screenshot to add this folder to the Show panel.Click on OK to exit the project settings.

Chapter 2. Metadata and Schemas

This chapter contains a detailed discussion about metadata and Talend schemas and recipes that highlight some of the less used / less known features associated with schemas, along with more commonly used features, such as generic and fixed schemas:

Hand-cranking a built-in schemaPropagating schema changesCreating a generic schema from existing metadataCutting and pasting schema informationDropping schemas to empty componentsCreating schemas from lists

Introduction

Managing metadata is one of the most important aspects of developing Talend jobs, and the most common form of metadata used within Talend jobs is the schema.

Schema metadata

For successful development of jobs, it is essential that the metadata defined for a data source accurately describes the format of its underlying data. Failure to correctly define the data will result in numerous errors and waste of time tracking down problems with data formats that could otherwise be avoided.

Talend provides a host of wizards for capturing metadata from a variety of data sources such as database tables, delimited files, and Excel worksheets and stores them within its built-in metadata repository.

Schemas

Talend stores metadata definitions in schemas, which may be built in to individual components or stored in its metadata repository, as shown in the following screenshot: