Member since
08-22-2016
9
Posts
2
Kudos Received
1
Solution
My Accepted Solutions
Title | Views | Posted |
---|---|---|
8320 | 03-01-2017 04:41 PM |
03-16-2017
02:58 PM
Just to elaborate the answer from @Deepesh, here is an example, how you can accomplish your goal. 1) save a list of tables you want to drop into a file echo "show tables like 'test_*';" > tables.sql
beeline -u 'jdbc:hive2://localhost:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2' -f tables.sql > tables.txt 2) from this list, generate a list of drop tables commands; for example, you can use the following python script, generate_droptables.py: f = 'tables.txt'
f = open(f)
lines = f.readlines()
def process_line(line):
if line.startswith('|') and 'test_' in line:
return line[1:].strip()[:-1].strip()
names = list(map(process_line, lines))
names = list(filter(lambda x : x, names))
out = open('droptables.sql', 'w')
for item in names:
out.write("drop table %s;\n" % item) 3) run the list drop tables command python generate_droptables.py
beeline -u 'jdbc:hive2://localhost:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2' -f droptables.sql
... View more
03-01-2017
04:41 PM
you can use left join to get this Step5 can be replace with create table z_test2 as select a.LastName, case when b.FirstName is null then a.FirstName else b.FirstName end as firstname, a.address, a.city from z_test1 a left outer join z_test b on a.LastName = b.LastName
... View more