Posted in

How to perform a right join in Kettle?

If you’ve spent any time working with data integration, you know that combining datasets without ending up with messy, incomplete results is one of the biggest headaches in ETL (Extract, Transform, Load) workflows. That’s where Kettle (officially part of Pentaho Data Integration, PDI) comes in—an open-source, widely used tool for building data pipelines quickly, even if you’re not a SQL expert. One of the most common join types people struggle to master is the RIGHT JOIN, so today I’m walking through exactly how to perform it in Kettle, as someone who’s spent the last 8 years supporting businesses like yours to get the most out of their Kettle deployments. Kettle

First, let’s start with what a RIGHT JOIN actually is, because too many people mix it up with INNER JOIN or LEFT JOIN and end up with bad data. A RIGHT JOIN returns all records from the right table (the second table you specify in your join) and matches them to corresponding records in the left table (the first table). If there’s no matching record in the left table, the left table’s columns will be filled with NULL values. For example, if you have a table of “Orders” and a table of “Customers”, a RIGHT JOIN would pull every customer, even if they’ve never placed an order. That’s a critical distinction—so many teams I work with accidentally flip their tables in the Kettle steps and get the opposite of what they intended, leading to missing customer data or inflated order counts.

Now, let’s get into the step-by-step process for building a RIGHT JOIN in Kettle. I’m going to use a real example most of my clients relate to: a retail team that wants a full list of products, even if some haven’t been assigned to a department yet, paired with their department details. The right table here will be “Products” (we want all products, even unmatched ones) and the left table will be “Departments”. Wait, no—let me make that clear: in the Kettle Join step, the order you drag your hops matters a lot. Let’s confirm: for a RIGHT JOIN between Table A (Departments) and Table B (Products), we want all Products, so Table B is the right table, Table A is the left. Got that? Keep that order front and center, I can’t tell you how many support tickets I’ve had where someone swapped these two and ended up with all departments and only products linked to departments, which is the exact opposite of what they needed.

First, you’ll need a new Transformation in Kettle—open Spoon, the Kettle GUI, right-click in the Transformation pane, select “New Transformation”, and save it somewhere logical. Next, add your two input tables. Most clients use databases like PostgreSQL, MySQL, or Snowflake, so drag two “Table Input” steps onto the canvas. For the first Table Input step (this is your left table in the join), name it something specific like “Left Table: Departments”. Double-click it, enter your database connection details (if you haven’t set one up yet, Kettle lets you create a new connection here by entering your host, port, database name, and credentials), then run a SQL query to pull your department data—something like SELECT department_id, department_name FROM departments;. Test this query to make sure it returns the right rows, then click OK.

Now add your second Table Input step, which will be your right table—name it “Right Table: Products”. Again, double-click to configure it, use the same database connection, and run your product query: SELECT product_id, product_name, department_id, price FROM products;. Test that too, to confirm it’s pulling all products, including those with a NULL department_id. Good.

Next, you need the step that will handle the join. Kettle has two main join steps: “Join Rows (Cartesian Product)” and “Merge Rows (diff)”, but for relational joins like RIGHT JOIN, the step you want is actually “Database Join” or—wait, no, for in-memory joins that work well for medium-to-large datasets, the “Join” step (sometimes called “Hash Join” in Kettle) is your go-to. Wait, let me correct that: if you’re joining two tables from the same database, using a “Database Join” step is more efficient because it pushes the join logic down to the database, which is faster than doing it in Kettle. If you’re joining files, CSV, or tables from different sources, use the “Join Rows” step. I’ll cover both, but let’s start with the database version since that’s what 70% of my clients use.

Drag a hop from your left “Departments” Table Input step to the “Database Join” step. Then drag another hop from your right “Products” Table Input step to the same “Database Join” step. Double-click the “Database Join” step to configure it. Here’s where the RIGHT JOIN setting lives. In the “Join Type” dropdown, you’ll see options: Inner Join, Left Outer Join, Right Outer Join, Full Outer Join. That’s exactly what we need! Select “Right Outer Join” here. Now, the join condition: we’re linking departments and products on department_id, so in the “Join fields” section, map the left table’s department_id to the right table’s department_id. Make sure you don’t mix up left and right here—Kettle will show you previews of the fields, so double-check: left table is Departments, right is Products, so left’s department_id matches right’s department_id.

Wait, another common mistake: if your join has multiple conditions, don’t try to add extra ones manually unless you’re sure. For example, if you want to join products to departments only where the product is active, you can either add that filter in the right table’s Table Input query (WHERE status = 'active') or add an additional condition in the Join step—just make sure it’s applied to the right table, not the left. I’ve seen teams add a status filter to the left table and wonder why they’re getting no matches, so always test with a simple join first before adding extra filters.

Once you’ve set the join type and conditions, go to the “Output” tab of the Database Join step. Here, you can choose which fields to include—don’t just hit “Select All” unless you’re sure, because it’s easy to get duplicate ID fields. For our example, we want product_id, product_name, department_id (from products, since that’s the right table), department_name (from departments). Uncheck the duplicate department_id from the left table (Departments) so you don’t end up with two identical columns named department_id in your output. Click OK to save the step.

Now, to test if this is working correctly, add a “Text File Output” step or a “Select Values” step to preview the data. Drag a hop from the Database Join step to the “Preview” step (you can add this from the “Transform” tab in the steps pane). Then right-click the Database Join step and select “Preview”. Run the transformation, and you should see all products, even those with a NULL department_id—for those rows, the department_name column will be NULL, which is exactly what a RIGHT JOIN should return. If you instead only see products that have a matching department, you forgot to set the join type to Right Outer, or you swapped your left and right tables in the hop.

What if you’re joining non-database tables, like CSVs or Excel files? Let’s say you have a products CSV and a departments CSV stored locally. In that case, the Database Join step won’t work, so use the “Join Rows (Hash Join)” step. The process is almost the same, except when you configure the Join Rows step, you’ll see a “Join type” dropdown with the same options (including Right Outer Join) and a section to map the key fields, just like the database version. The only difference is that this step loads both tables into memory in Kettle, so it’s best for datasets under 1 million rows—if you’re working with larger data, use the Database Join step to keep processing on the database server.

Now, let’s talk about common pitfalls I see clients run into all the time, because fixing these is what makes the difference between a working pipeline and one that’s causing bad business decisions. First, table order. I can’t stress this enough: when you drag your input steps to the Join step, the first hop you drag is the left table, the second is the right table. If you drag the Products table first and Departments second, Kettle will treat Products as the left table, so your Right Join will flip to a Left Join, and you’ll end up with all departments instead of all products. That’s a 10-minute mistake that wastes hours because you don’t check the preview. Second, key matching: if your join keys have different names (e.g., the left table has “dept_id” and the right has “department_id”), don’t try to use string manipulation in the Join step to fix this—standardize the names in your Table Input queries or use the “Select Values” step to rename one key before joining. Third, duplicate rows: RIGHT JOIN can bring in duplicate rows if your key isn’t unique. For example, if a product is listed in two departments in the Products table, you’ll get two rows for that product. Always make sure your right table’s join key is unique, or add a “Group By” step after the join to deduplicate.

Once your RIGHT JOIN is working correctly, you can add it to a larger Kettle pipeline—maybe adding a “Filter Rows” step to remove products you don’t need, or a “Calculator” step to compute revenue per department. Kettle is flexible, so the RIGHT JOIN you built can be part of a daily data load, a weekly report, or a customer analytics pipeline.

At this point, if you’re looking to scale your ETL workflows, avoid these common mistakes, or get tailored support for your specific Kettle deployments, our team has been helping businesses optimize their data pipelines for over a decade. We offer flexible support packages, training, and custom pipeline development to make sure you’re getting the most out of Kettle, no matter your team’s size or technical skill level. Whether you’re building a simple RIGHT JOIN for a monthly report or a complex enterprise data lake pipeline, we can help you do it right the first time, saving you hours of debugging and preventing bad data from impacting your business decisions.

References

Toaster Pentaho Data Integration Documentation, “Join Types”, 2024.
Kettle Community Forums, “Common Join Mistakes”, 2023.
Pentaho ETL Best Practices Guide, “Optimizing Database Joins”, 2024.


Ningbo Lanka International Trading Co., Ltd.
As one of the most professional kettle manufacturers and suppliers in China, we’re featured by quality products and low price. Please rest assured to wholesale high-grade kettle for sale here from our factory. Also, custom service is available.
Address: No.11 Dongqian Lake Area, Yinxian Avenue, Ningbo, China
E-mail: messi@lanka10.com
WebSite: https://www.lanka-10.com/