#!/bin/bash

# Add schema for refresh data sets
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  ddl.sql  > ../logs/mt_ddl_${1}.out 2>&1

# Delete
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  DF_CS.sql > ../logs/DF_CS_${1}.out 2>&1 &
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  DF_SS.sql > ../logs/DF_SS_${1}.out 2>&1 &
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  DF_WS.sql > ../logs/DF_WS_${1}.out 2>&1 &
   sleep 15
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  DF_I.sql > ../logs/DF_I_${1}.out 2>&1   &

# Wait untill all deletes complete
wait

# Insert
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  LF_CS.sql > ../logs/LF_CS_${1}.out 2>&1 &
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  LF_SS.sql > ../logs/LF_SS_${1}.out 2>&1 &
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  LF_WS.sql > ../logs/LF_WS_${1}.out 2>&1 &
   sleep 10
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  LF_SR.sql > ../logs/LF_SR_${1}.out 2>&1 &
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  LF_CR.sql > ../logs/LF_CR_${1}.out 2>&1 &
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  LF_WR.sql > ../logs/LF_WR_${1}.out 2>&1 &
   beeline -u jdbc:hive2://localhost:10000  --maxWidth=1000 -f  LF_I.sql > ../logs/LF_I_${1}.out 2>&1   &

# Wait untill all inserts complete
wait

