-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_migration.sh
74 lines (65 loc) · 5.35 KB
/
data_migration.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!bin/bash
########################################################################################################################################
########################################################################################################################################
############################### Content: Shell Script to create tables on Hive from a HQL file ############################
############################### Author: Jorge Quintana ############################
############################### Date: January, 10th 2017 ############################
############################### Contact: [email protected] ############################
########################################################################################################################################
########################################################################################################################################
############################### It receives some parameter ############################
############################### MY_HQLFILE: The HQL file with the creation table commands ############################
############################### MY_DB: The Data Base where the table is going to be created ############################
############################### MY_TB: The table to be created ############################
############################### MY_HQLPATH: The path where the HQL files are stored ############################
############################### MY_HIVEPORT: The Hive port on Localhost to connect with Beeline ############################
############################### MY_USER: The Hive User to connect with Beeline ############################
############################### MY_PSWD: The Hive Password to connect with Beeline ############################
############################### MY_DATAPATH: The path were are created the data folders ############################
############################### ############################
############################### For the variables MY_HQLFILE and MY_TB they will be assigned accordingly to ############################
############################### the name's files in MY_PATH. So, for the creation of tabla sports the HQL ############################
############################### should have this name (sport.hql) ############################
########################################################################################################################################
########################################################################################################################################
########################################################################################################################################
############################### Defining the input variables: ############################
########################################################################################################################################
MY_DB="$1"
MY_HIVEPORT="$2"
MY_DATAPATH="$3"
echo ""
echo "Starting process with the following parameters: "
echo "Database: ${MY_DB}"
echo "HQL Path: ./hql/"
echo "Hive Port: ${MY_HIVEPORT}"
echo "Data Path: ${MY_DATAPATH}"
echo ""
########################################################################################################################################
############################### With these variables the Beeline connection will be created to check the ############################
############################### results and the hiveconf to run the HQL files on Hive ############################
########################################################################################################################################
########################################################################################################################################
########################################################################################################################################
sanatas="cartera clisus cteyaho das dian endeuda icbcon icbsus regist scohis valores"
for file in ./Maestros/*
do
MY_FILE=${file:11:50}
MY_TB=${MY_FILE%.*}
echo ""
echo "Moving ${MY_FILE}"
hdfs dfs -put ./Maestros/${MY_FILE} /colombia/landing/sanatas/${MY_DB}/${MY_TB}/.
if [ $? == 0 ]; then
{
echo "Succesfully moved to HDFS!"
}
else
{
echo "Something was wrong!"
}
fi
done
echo "Files moved succesfully!"
return 0
########################################################################################################################################
########################################################################################################################################