-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcodeeeee.txt
141 lines (116 loc) · 3.53 KB
/
codeeeee.txt
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#raw combined
------------------
create external table combined(entry_id INT, state_patient_number INT, date_announced STRING, age INT, gender STRING, city STRING, district STRING, state STRING, state_code STRING, num_cases INT, status STRING, suspect STRING, notes STRING,
source_1 STRING, source_2 STRING, source_3 STRING, nationality STRING, type_of_transmission STRING, status_change_date STRING, patient_number INT)
row format delimited
fields terminated by ','
stored as textfile;
#rawdata
--------
create external table rawdata(
tested_date STRING,
state STRING,
num_cases INT,
status STRING)
row format delimited
fields terminated by ','
stored as textfile;
#final_raw
-------------
create external table finalraw(
tested_date STRING,
state STRING,
confirmed STRING,
recovered STRING,
deceased STRING)
row format delimited
fields terminated by ','
stored as textfile;
@stateraw
----------
create external table state_data1 (
date_announced STRING,
State STRING,
RTPCR_Test STRING,
RAT STRING,
Other_Tests STRING,
Total_Tested INT,
Tag STRING,
Positive STRING,
Negative STRING,
Unconfirmed STRING,
Cumulative STRING,
Total_People_Currently_in_Quarantine STRING,
Tag_People_in_Quarantine STRING,
Total_People_Released_From_Quarantine STRING)
row format delimited
fields terminated by ','
stored as textfile;
#ext state
-------------
create external table state_data2 (
tested_date STRING,
state STRING,
total_tested INT)
row format delimited
fields terminated by ','
stored as textfile;
#previous
-----------
create external table previous(tested_date STRING, state STRING, total_tested INT, previous_day_cumulative_tested INT )
row format delimited
fields terminated by ','
stored as textfile;
#eachday
-----------
create external table each_day (
tested_date STRING,
state STRING,
total_tested INT)
row format delimited
fields terminated by ','
stored as textfile;
#result
---------
create external table result(
tested_date STRING,
state STRING,
confirmed STRING,
recovered STRING,
deceased STRING,
total_tested STRING)
row format delimited
fields terminated by ','
stored as textfile;
# insert raw
---------------
insert overwrite table rawdatashow tables;
select regexp_replace(date_announced,"/","-") as tested_date,state,num_cases,
regexp_replace(status,"Migrated_Other|Migrated_other|Hospitalized","Confirmed") as status from combined
where num_cases is not null and status is not null
order by unix_timestamp(tested_date,'dd-MM-yyyy');
#insert statedata 2
------------------
insert overwrite table state_data2
select regexp_replace(date_announced,"/","-") as tested_date,State,Total_Tested from state_data1
where Total_Tested is not null and date_announced is not null and State is not null;
#ddt table
-----------
create external table roj(
tested_date STRING,
state STRING,
confirmed STRING,
recovered STRING,
deceased STRING,
total_tested STRING)
row format delimited
fields terminated by ','
stored as textfile;
create table temp1 as
select r.tested_date, r.state, r.confirmed, r.recovered, r.deceased, e.total_tested from sputnik.each_day e
right outer join sputnik.finalraw r on e.tested_date=r.tested_date and e.state=r.state order by unix_timestamp(r.tested_date,'dd-MM-yyyy'),r.state;
#nnresult
-----------
create table nnresult as select nvl(tested_date,0),nvl(state,0),nvl(confirmed,0),nvl(recovered,0),nvl(deceased,0),nvl(total_tested,0) from result;
#substringmethod
------------------