-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipa_deletion.sh
47 lines (35 loc) · 2.62 KB
/
pipa_deletion.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
echo "##################################################################"
echo "################## PII DELETION PROCESS START ####################"
echo "##################################################################"
today=$(date "+%Y%m%d%H%M%S")
echo "################## right now!! : ${today}"
target_table=( "application_train" "credit_card_balance" "installments_payments" "pos_cash_balance" "previous_application" "bureau")
#target_table=( "credit_card_balance" )
for target_table in ${target_table[@]}; do
echo "################## Target Table Name : ${target_table}"
var1=`hive -e "select count(*) from standardization.${target_table}"`
var2=`hive -e "select count(*) from standardization.${target_table} where sk_id_curr not in (select id from standardization.pii_list)"`
if [ "${var1}" = "${var2}" ]; then
echo "standardization.${target_table} - No deletion target data existed"
else
#var3=`hive -e "select count(*) from standardization.${target_table} where sk_id_curr not in (select id from staging.pii_list)"`
hive -e "delete from standardization.${target_table} where sk_id_curr in (select id from standardization.pii_list)"
var3=`hive -e "select count(*) from standardization.${target_table}"`
echo "################## standardization.${target_table} totoal record : ${var1}"
echo "################## standardization.${target_table} non-target record before deletion : ${var2}"
echo "################## standardization.${target_table} totoal record after deletion : ${var3}"
if [ "${var2}" = "${var3}" ]; then
#echo "################## Truncate and COPY date from standardization.${target_table} to reporting.${target_table} "
#hive -e "truncate table reporting.${target_table}"
#hive -e "insert into reporting.${target_table} select * from standardization.${target_table}"
echo "################## PII deletion count mathced. PII_STATISTICS table update started"
hive -e "insert into standardization.pii_statistics values ('${target_table}','default','${var1}','${var2}','${var3}','OK','${today}')"
else
echo "################## PII deletion count MISMATCHED!!!"
hive -e "insert into standardization.pii_statistics values ('${target_table}','default','${var1}','${var2}','${var3}','Failed','${today}')"
fi
fi
done
echo "##################################################################"
echo "################## PII DELETION PROCESS END ######################"
echo "##################################################################"