forked from yaooqinn/tpcds-for-spark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spark-query-tpcds-beeline.sh
executable file
·81 lines (66 loc) · 1.85 KB
/
spark-query-tpcds-beeline.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
75
76
77
78
79
80
81
#!/bin/bash
source tpcds-env.sh
if [ ! -d ${QUERY_SQL_DIR} ];then
echo "query sql is not exist,exit.."
exit 1
fi
#QUERY_RESULT_BEELINE_DIR=${QUERY_RESULT_DIR}_ne_beeline
QUERY_RESULT_BEELINE_DIR=${QUERY_RESULT_DIR}_apache_beeline
if [ -d $QUERY_RESULT_BEELINE_DIR ];then
rm -rf $QUERY_RESULT_BEELINE_DIR
fi
mkdir -p $QUERY_RESULT_BEELINE_DIR
#unsupported sql ids
#ids=(5 8 9 10 13 14 18 22 23 24 27 35 36 38 41 44 45 66 67 70 77 80 84 86 87)
ids=()
#skip ids
#ids2=(1 2 3 4 5 6 7 8 9 10 11 12 13 14)
ids2=()
echo "-----------开始查询-----------"
echo "-----------数据库为$TPCDS_DBNAME------------"
#exec sql
for (( i=1;i<100;++i ))
do
yes=1
for j in ${ids[@]}
do
if [ $i -eq $j ]; then
yes=0
break;
fi
done
if [ $yes -eq 0 ]; then
continue
fi
for k in ${ids2[@]}
do
if [ $i -eq $k ]; then
yes=0
break;
fi
done
if [ $yes -eq 0 ]; then
continue
fi
file="$QUERY_SQL_DIR/query$i.sql"
if [ ! -f $file ]; then
echo "$file is not exist!"
exit 1
fi
echo $file 查询中,每个查询进行三次,并取平均值作为最终测试结果
result="${QUERY_RESULT_BEELINE_DIR}/query.result"
echo -n "query$i.sql," >> $result
for(( times=1;times<=3;times++))
do
echo ${file}_$times 查询中
sysout="${QUERY_RESULT_BEELINE_DIR}/query${i}_$times.out"
${SPARK_HOME}/bin/beeline -u 'jdbc:hive2://hadoop712.lt.163.org:10010/tpcds;principal=hive/[email protected];hive.server2.proxy.user=hzyaoqin' -f "$file" >$sysout 2>&1
time=`cat $sysout | grep "seconds)" | cut -d "(" -f 2 | cut -d ")" -f 1 | cut -d " " -f 1`
if [ "$time" = "" ];then
echo -n "0," >> $result
else
echo -n "${time}," >> $result
fi
done
echo "" >> $result
done