Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
data-dqmonitor
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-dqmonitor
Commits
404ad9fa
Commit
404ad9fa
authored
Jun 26, 2019
by
Pengfei Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add chain rate
parent
31f13811
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
9 deletions
+56
-9
misc.xml
.idea/misc.xml
+2
-8
workspace.xml
.idea/workspace.xml
+0
-0
Main.scala
src/main/scala/com/gmei/data/dq/Main.scala
+2
-1
actionCheck.scala
src/main/scala/com/gmei/data/dq/actionCheck.scala
+52
-0
No files found.
.idea/misc.xml
View file @
404ad9fa
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"MavenProjectsManager"
>
<option
name=
"originalFiles"
>
<list>
<option
value=
"$PROJECT_DIR$/pom.xml"
/>
</list>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_8"
project-jdk-name=
"1.8.0_212"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_8"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/classes"
/>
</component>
</project>
\ No newline at end of file
.idea/workspace.xml
View file @
404ad9fa
This diff is collapsed.
Click to expand it.
src/main/scala/com/gmei/data/dq/Main.scala
View file @
404ad9fa
...
...
@@ -30,7 +30,8 @@ object Main {
}
// check pv
pvReferCheker
.
check
(
spark
,
partition_date
)
// pvReferCheker.check(spark, partition_date)
actionCheck
.
check
(
spark
,
partition_date
)
spark
.
stop
()
}
...
...
src/main/scala/com/gmei/data/dq/actionCheck.scala
0 → 100644
View file @
404ad9fa
package
com.gmei.data.dq
import
java.text.SimpleDateFormat
import
java.util.Date
import
org.apache.spark.sql.SparkSession
object
actionCheck
{
import
java.util.Calendar
private
def
getYesterday
(
date
:
Date
)
=
{
val
cal
=
Calendar
.
getInstance
cal
.
setTime
(
date
)
cal
.
add
(
Calendar
.
DATE
,
-
1
)
cal
.
getTime
}
def
check
(
sc
:
SparkSession
,
partition_date
:
String
)
=
{
import
sc.implicits._
val
dateFormat
=
new
SimpleDateFormat
(
"yyyyMMdd"
)
val
time_date
=
dateFormat
.
parse
(
partition_date
)
val
yesterday
=
getYesterday
(
time_date
)
val
df
=
sc
.
sql
(
s
"""
|select
| a.partition_date as today,
| b.partition_date as yesterday,
| a.cl_type,
| a.app_version,
| a.c as todayCount,
| b.c as yesterdayCount,
| case when b.c = 0 then 1.0 else (a.c - b.c) * 1.0 / b.c end as chainRate
|(
| select partition_date, cl_type, app_version, count(1) as c
| from online.bl_hdfs_maidian_updates
| where partition_date = '${partition_date}'
| group by partition_date, cl_type, app_version
|) a left join (
| select
| select partition_date, cl_type, app_version, count(1) as c
| from online.bl_hdfs_maidian_updates
| where partition_date = '${yesterday}'
| group by partition_date, cl_type, app_version
|) b on a.cl_type = b.cl_type and a.app_version = b.app_version
"""
.
stripMargin
)
df
.
show
}
}
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