Skip to content

Commit 1cefb3f

Browse files
committed
Fixed mysql partition cleanup scripts. #52
1 parent b4b7b0b commit 1cefb3f

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

bin/deploy.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@
4141
dest: /usr/local/hive-sre/bin
4242
mode: 0755
4343

44+
- name: Copy parts
45+
copy:
46+
src: ../src/main/bash/get_part_ids.sh
47+
dest: /usr/local/hive-sre/bin
48+
mode: 0755
49+
50+
- name: Copy missing parts
51+
copy:
52+
src: ../src/main/bash/mysql_missing_parts.sh
53+
dest: /usr/local/hive-sre/bin
54+
mode: 0755
55+
4456
- name: Copy lib
4557
copy:
4658
src: ../target/hive-sre-shaded.jar
@@ -66,3 +78,17 @@
6678
dest: /usr/local/bin/hive-sre-cli
6779
mode: 0755
6880
state: link
81+
82+
- name: Link Parts
83+
file:
84+
src: /usr/local/hive-sre/bin/get_part_ids.sh
85+
dest: /usr/local/bin/get_part_ids.sh
86+
mode: 0755
87+
state: link
88+
89+
- name: Link Missing Parts
90+
file:
91+
src: /usr/local/hive-sre/bin/mysql_missing_parts.sh
92+
dest: /usr/local/bin/mysql_missing_parts.sh
93+
mode: 0755
94+
state: link

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<groupId>com.cloudera.utils.hive</groupId>
2424
<artifactId>hive-sre</artifactId>
25-
<version>3.0.1.3</version>
25+
<version>3.0.1.4</version>
2626

2727
<name>hive-sre</name>
2828

src/main/bash/get_part_ids.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ PARTIDS=()
55
# Build a list of id's that can be added to an 'in' clause
66
# in SQL to modify the need tables.
77

8-
while IFS="|" read -r one two three four five six
8+
awk 'match($0, /\| [0-9]+ \|/) {
9+
print substr($0, RSTART, RLENGTH)
10+
}' $1 > $1.part
11+
12+
while IFS=" " read -r one two three
913
do
10-
nospaces=${six// } # remove leading spaces
14+
nospaces=${two// } # remove leading spaces
1115

1216
re='^[0-9]+$'
1317
if [[ $nospaces =~ $re ]] ; then
1418
# echo "$nospaces"
1519
PARTIDS+=("$nospaces")
1620
fi
17-
done < <(grep ^\| $1)
21+
done < $1.part
1822

1923
arraylength=${#PARTIDS[@]}
2024
#echo "Total Partition Ids: $arraylength"

src/main/bash/mysql_missing_parts.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ echo "Temp Dir: $TMPDIR"
88

99
$(dirname $0)/get_part_ids.sh $1 $TMPDIR/part_ids.txt
1010

11-
while IFS="|" read -r line
11+
for line in `cat $TMPDIR/part_ids.txt`
1212
do
1313
echo "Line: $line"
1414
# PART_COL_PRIVS
@@ -23,4 +23,4 @@ do
2323
echo "DELETE FROM PARTITION_PARAMS WHERE PART_ID IN ($line);" >> mysql_missing_parts.sql
2424
# PARTITIONS
2525
echo "DELETE FROM PARTITIONS WHERE PART_ID IN ($line);" >> mysql_missing_parts.sql
26-
done <$TMPDIR/part_ids.txt
26+
done

0 commit comments

Comments
 (0)