Deepening data quality techniques in PDI: validation and cleansing, lookup and data normalization, string manipulation with regex, handling missing values, deduplication, aggregation, and transformation patterns that keep pipelines healthy in production.

Real-world data is never clean. Columns are empty, date formats are mixed up, customer names are written inconsistently, and duplicates appear endlessly. This episode covers data quality — the skill that separates amateur pipelines from professional ones.
You'll learn transformation patterns to clean, validate, normalize, and deduplicate data. This isn't just a list of steps; it's a way of thinking about the truthfulness of data before it's trusted for decision-making.
Validation is the first gate. Before data enters the warehouse, make sure it's fit for purpose. The two most used steps:
jumlah <= 0.The classic pattern: valid rows continue the flow to the next process, failed rows go to a special log file or a Write to log step so they can be investigated. Never let bad data silently make its way into the warehouse.
Danger
An important decision you must make early in the design: are failing rows rejected, repaired, or flagged? Don't leave this decision implicit. A good pipeline documents this decision explicitly in its design.
Cleansing removes dirt from data; normalization makes its values consistent. Several techniques you must master:
trim, changing letter case, and cleaning unwanted characters.An example of using String operations to normalize names: apply trim then convert to title case. Or use the Replace in string step to replace all occurrences of certain characters:
pola: [^a-zA-Z0-9 ]
tujuan: remove all characters other than letters, numbers, and spacesRegex is one of the most valuable skills in the ETL world. Take time to practice the basics — you'll use it almost every day.
Besides regex, String operations offers common transformations in one dialog: trim, lower, upper, initCap, pad, and substr. The most common combination is trim then initCap for person names, or upper for codes compared case-insensitively. The rule is simple: make values consistent before the data is used for joins or deduplication, not after.
A real normalization example: the no_hp column holds various formats like 0812-3456-7890, +62 812 3456 7890, and 62812.3456.7890. With chained Replace in string steps — remove spaces, strip punctuation, then normalize the prefix — you convert all variants into one standard format that can be matched and checked for duplicates. Before copying patterns into Spoon, get used to testing them first in the terminal with grep -E "pola" contoh.txt — instant feedback from the command line is far faster than trial-and-error in the step dialog.
Empty data doesn't mean lost. What matters is how you handle it deliberately. Several strategies:
UNKNOWN or the number 0.The If field value is null step separates rows that have empty values so you can handle the two groups differently. Don't let nulls flow all the way to the database without a clear decision.
Duplicates are the enemy of data quality. Two main approaches:
For more complex data — for example determining the single best representation per customer from several sources — use Group by with aggregations like MIN, MAX, or picking the first valid value. This technique is called deduplication and is crucial when combining data from many systems.
Lookup is the way to add information from reference tables. The three most useful steps:
PRIORITY=1 becomes URGENT.Combining lookup with caching — enabling Enable caching on Database lookup or loading a small reference table into memory — is one of the easiest and most effective performance optimizations.
Info
Lookup rule of thumb: if the reference table is small and rarely changes, load it once into memory then do a stream lookup. If the table is large or always up to date, use a database lookup with caching and limit the number of columns fetched. These optimization details will be revisited in episodes 8 and 15.
Finally, master aggregation. The Group by step groups data by one or more fields then computes aggregates like SUM, COUNT, AVG, MIN, and MAX. Example: calculate total sales per customer per month from a transaction table.
Here's the query equivalent to a Group by result in PDI — understanding both makes you freer in choosing where to do the aggregation:
SELECT id_pelanggan,
DATE_TRUNC('month', tanggal) AS bulan,
SUM(jumlah) AS total,
COUNT(*) AS jumlah_transaksi
FROM orders
GROUP BY id_pelanggan, DATE_TRUNC('month', tanggal)Which one to choose — the Group by step or an SQL query — depends on whether the aggregation must be visibly readable in the pipeline or can be left to the database. Both are valid, as long as the results are measured and consistent.
Beyond techniques, there are healthy transformation patterns to make a habit:
These patterns aren't just tidiness — they're what make a pipeline easy to debug and hand over to other teams, a topic that will be revisited in episode 22.
In episode 6 you mastered data quality techniques in PDI: validation with Validator and Filter rows, cleansing and string normalization with regex and type conversion, handling missing values, deduplication, lookup for enrichment, and aggregation with Group by.
The key takeaways:
In episode 7, we discuss the tense moments: error handling & debugging — handling errors in transformations and jobs, using preview rows and breakpoints, reading step logs and performance metrics, and recovery strategies for failed transformations.