What Is The Need Of SQL Case Statements In ETL Testing ?
Sarah
Posted on : 07-May-2013 | Joined :
09-Feb-2012 | Posts : 10
Suppoe there is table called SOURCE, conatins column NAME and AGE. The requirement is that to poulate records from SOURCE to the target tale TARGET. In TARGET table contain following columns NAME and CATEGORY.
Following is the rule for the category selection Age Group Category --------------- ------------ 0-17 -> A 18-30 -> B 31 - 50 -> C 51-70 -> D 71+ -> E
Once the ETL jobs are done then as a tester we can validate the data with the combination CASE and MINUS we can validate it as following
/* Source - Target */ /* Source*/ SELECT NAME, ( CASE WHEN AGE <18 THEN 'A' WHEN AGE BETWEEN 18 AND 30 THEN 'B' WHEN AGE BETWEEN 31 AND 50 THEN 'C' WHEN AGE BETWEEN 51 AND 70 THEN 'D' ELSE 'E' END ) AS CATEGORY FROM SOURCE MINUS /* Target */ SELECT NAME, CATEGORY FROM TARGET
Like this do a Target minus Source too. Idealy both the scripts (source -Target) & (Targe - Source) should return as values at all. If it returns any value means something wrong in the Code
Note:- Here i didn't include the source filtering part and Target filter part. Say if you want to take some filter condition that need to b applied in both Source part and target part For Eg:- Time stamp.