forked from yaooqinn/tpcds-for-spark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spark-query-tpcds.sh
executable file
·82 lines (66 loc) · 1.59 KB
/
spark-query-tpcds.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
82
#!/bin/bash
bin=`dirname $0`
bin=`cd $bin;pwd`
source tpcds-env.sh
if [ ! -d $QUERY_SQL_DIR ];then
echo "query sql is not exist,exit.."
exit;
fi
if [ -d $QUERY_RESULT_DIR ];then
rm -rf $QUERY_RESULT_DIR
fi
mkdir $QUERY_RESULT_DIR
#unsupported sql ids
#ids=(28 61 77 88 90)
ids=()
#skip ids
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_DIR/query.result"
echo -n "query$i.sql," >> $result
for(( times=1;times<=1;times++))
do
echo ${file}_$times 查询中
sysout="$QUERY_RESULT_DIR/query${i}_$times.out"
$SPARK_HOME/bin/spark-sql --database $TPCDS_DBNAME --name ${file}_$times -f "$file" --silent > $sysout 2>&1
time=`cat $sysout | grep "Time taken:" | grep "Driver" | awk -F 'Time taken:' '{print $2}' | awk -F ' ' '{print $1}'`
if [ "$time" = "" ];then
echo -n "0," >> $result
else
echo -n "$time," >> $result
fi
done
echo "" >> $result
done
exit 0