Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bi-report
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data
bi-report
Commits
5be2d05e
Commit
5be2d05e
authored
Apr 24, 2020
by
赵建伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update codes
parent
0922af17
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
6 deletions
+66
-6
demo.zip
jobs/demo/demo.zip
+0
-0
step2.job
jobs/demo/step2.job
+3
-3
hive2csv.sh
lib/shell/hive2csv.sh
+61
-0
hive2hive.sh
lib/shell/hive2hive.sh
+2
-3
No files found.
jobs/demo/demo.zip
0 → 100644
View file @
5be2d05e
File added
jobs/demo/step2.job
View file @
5be2d05e
#step2.job
type=command
dependencies=step1_1,step1_2,step1_3,step1_4,step1_5,step1_6
command=sh /srv/apps/bi-report/lib/shell/hive2hive.sh demo
\ No newline at end of file
dependencies=step1
command=sh /srv/apps/bi-report/lib/shell/hive2csv.sh demo
\ No newline at end of file
lib/shell/hive2csv.sh
0 → 100644
View file @
5be2d05e
#!/bin/bash
source
~/.bashrc
source
/etc/profile
if
[
$#
-lt
1
]
;
then
echo
"Param error, please check again!"
exit
0
fi
#默认取输入的账期
V_DATE
=
$2
partition_date
=
`
date
+
"%Y%m%d"
`
timestamp
=
`
date
+
"%Y%m%d%H%M%S"
`
tmp_file_name
=
"/data/bi-report/tmp/tmp_"
$timestamp
".sql"
result_file_name
=
"/data/bi-report/result/"
$1
"_"
$partition_date
".csv"
#输入的账期为空,则取T+1默认账期
if
[
-z
${
V_DATE
}
]
;
then
V_DATE
=
`
date
--date
=
"-1 day"
+%Y-%m-%d
`
fi
#默认支持的日期函数
V_PARYMD
=
`
date
--date
=
"
$V_DATE
"
+%Y%m%d
`
V_PARY_M_D
=
`
date
--date
=
"
$V_DATE
"
+%Y-%m-%d
`
V_1DAYMD_AGO
=
`
date
--date
=
"
$V_PARYMD
-1 day"
+%Y%m%d
`
V_7DAYMD_AGO
=
`
date
--date
=
"
$V_PARYMD
-7 day"
+%Y%m%d
`
V_1DAY_M_D_AGO
=
`
date
--date
=
"
$V_PARYMD
-1 day"
+%Y-%m-%d
`
V_7DAY_M_D_AGO
=
`
date
--date
=
"
$V_PARYMD
-7 day"
+%Y-%m-%d
`
#获取当前时间对应的年、月、日
V_PARYEAR
=
`
date
--date
=
"
$V_DATE
"
+%Y
`
V_PARMONTH
=
`
date
--date
=
"
$V_DATE
"
+%m
`
V_PARDAY
=
`
date
--date
=
"
$V_DATE
"
+%d
`
#打印账期
echo
""
echo
"************************************"
echo
"V_PARYMD: "
$V_PARYMD
echo
"V_PARY_M_D: "
$V_PARY_M_D
echo
"V_1DAYMD_AGO: "
$V_1DAYMD_AGO
echo
"V_7DAYMD_AGO: "
$V_7DAYMD_AGO
echo
"V_1DAY_M_D_AGO: "
$V_1DAY_M_D_AGO
echo
"V_7DAY_M_D_AGO: "
$V_7DAY_M_D_AGO
echo
"************************************"
echo
""
cp
"/srv/apps/bi-report/sqls/"
$1
".sql"
$tmp_file_name
sed
-i
"s/
\$
V_PARYMD/
$V_PARYMD
/g"
$tmp_file_name
sed
-i
"s/
\$
V_PARY_M_D/
$V_PARY_M_D
/g"
$tmp_file_name
sed
-i
"s/
\$
V_1DAYMD_AGO/
$V_1DAYMD_AGO
/g"
$tmp_file_name
sed
-i
"s/
\$
V_7DAYMD_AGO/
$V_7DAYMD_AGO
/g"
$tmp_file_name
sed
-i
"s/
\$
V_1DAY_M_D_AGO/
$V_1DAY_M_D_AGO
/g"
$tmp_file_name
sed
-i
"s/
\$
V_7DAY_M_D_AGO/
$V_7DAY_M_D_AGO
/g"
$tmp_file_name
# 新标签与新标签对应集合类型 的对应关系
/opt/hive/hive-1.1.0-cdh5.16.1/bin/beeline
-u
jdbc:hive2://bj-gm-prod-cos-datacenter004:10000
-n
data
--outputformat
=
csv2
--showHeader
=
true
-e
"
`
cat
$tmp_file_name
`
"
>
$result_file_name
rm
-rf
$tmp_file_name
exit
0
\ No newline at end of file
lib/shell/hive2hive.sh
View file @
5be2d05e
...
...
@@ -10,10 +10,8 @@ fi
#默认取输入的账期
V_DATE
=
$2
partition_date
=
`
date
+
"%Y%m%d"
`
timestamp
=
`
date
+
"%Y%m%d%H%M%S"
`
tmp_file_name
=
"/data/bi-report/tmp/tmp_"
$timestamp
".sql"
result_file_name
=
"/data/bi-report/result/"
$1
"_"
$partition_date
".csv"
#输入的账期为空,则取T+1默认账期
if
[
-z
${
V_DATE
}
]
;
then
...
...
@@ -54,7 +52,7 @@ sed -i "s/\$V_1DAY_M_D_AGO/$V_1DAY_M_D_AGO/g" $tmp_file_name
sed
-i
"s/
\$
V_7DAY_M_D_AGO/
$V_7DAY_M_D_AGO
/g"
$tmp_file_name
# 新标签与新标签对应集合类型 的对应关系
/opt/hive/hive-1.1.0-cdh5.16.1/bin/beeline
-u
jdbc:hive2://bj-gm-prod-cos-datacenter004:10000
-n
data
-e
"
`
cat
$tmp_file_name
`
"
>
$result_file_name
/opt/hive/hive-1.1.0-cdh5.16.1/bin/beeline
-u
jdbc:hive2://bj-gm-prod-cos-datacenter004:10000
-n
data
-e
"
`
cat
$tmp_file_name
`
"
rm
-rf
$tmp_file_name
exit
0
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment