Skip to content

Commit

Permalink
[Feature][UI] Add dataquality dashboard (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
zixi0825 authored Oct 6, 2023
1 parent 89ba78e commit 440e16b
Show file tree
Hide file tree
Showing 39 changed files with 1,557 additions and 422 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,22 @@ public enum JobType {
* 1 DATA_PROFILE
* 2 DATA_RECONCILIATION
*/
DATA_QUALITY(0, "DATA_QUALITY"),
DATA_PROFILE(1, "DATA_PROFILE"),
DATA_RECONCILIATION(2, "DATA_RECONCILIATION");
DATA_QUALITY(0, "DATA_QUALITY", "数据质量检查"),
DATA_PROFILE(1, "DATA_PROFILE","数据概览检查"),
DATA_RECONCILIATION(2, "DATA_RECONCILIATION","数据比对检查");

JobType(int code, String description) {
JobType(int code, String description, String zhDescription) {
this.code = code;
this.description = description;
this.zhDescription = zhDescription;
}

@EnumValue
private final int code;
private final String description;

private final String zhDescription;

public int getCode() {
return code;
}
Expand All @@ -50,6 +53,10 @@ public String getDescription() {
return description;
}

public String getZhDescription() {
return zhDescription;
}

private static final HashMap<String, JobType> JOB_TYPE_MAP = new HashMap<>();

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ public static long diffHours(Date d1, Date d2) {
return (long) Math.ceil(diffMin(d1, d2) / 60.0);
}

public static long diffDays(Date d1, Date d2) {
return (long) Math.ceil(diffMin(d1, d2) / 60.0/24);
}

/**
* get minutes between two dates
*
Expand Down
132 changes: 66 additions & 66 deletions ...xpected-last30day-avg/src/main/java/io/datavines/metric/expected/plugin/Last30DayAvg.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.datavines.metric.expected.plugin;

import io.datavines.metric.api.ExpectedValue;

import java.util.Map;

import static io.datavines.common.ConfigConstants.METRIC_UNIQUE_KEY;

public class Last30DayAvg implements ExpectedValue {

@Override
public String getName() {
return "last_30d_avg";
}

@Override
public String getZhName() {
return "最近30天均值";
}

@Override
public String getKey(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "expected_value_" + uniqueKey;
}

@Override
public String getExecuteSql(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "select round(avg(actual_value),2) as last_30d_avg" + "expected_value_" + uniqueKey +
" from dv_actual_values where data_time >= date_sub(date_format(${data_time},'%Y-%m-%d'),interval 30 DAY)" +
" and data_time < date_add(date_format(${data_time},'%Y-%m-%d'),interval 1 DAY) and unique_code = ${unique_code}";
}

@Override
public String getOutputTable(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "last_30d_" + uniqueKey;
}

@Override
public boolean isNeedDefaultDatasource() {
return true;
}

@Override
public void prepare(Map<String, String> config) {

}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.datavines.metric.expected.plugin;

import io.datavines.metric.api.ExpectedValue;

import java.util.Map;

import static io.datavines.common.ConfigConstants.METRIC_UNIQUE_KEY;

public class Last30DayAvg implements ExpectedValue {

@Override
public String getName() {
return "last_30d_avg";
}

@Override
public String getZhName() {
return "最近30天均值";
}

@Override
public String getKey(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "expected_value_" + uniqueKey;
}

@Override
public String getExecuteSql(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "select round(avg(actual_value),2) as expected_value_" + uniqueKey +
" from dv_actual_values where data_time >= date_sub(date_format(${data_time},'%Y-%m-%d'),interval 30 DAY)" +
" and data_time < date_add(date_format(${data_time},'%Y-%m-%d'),interval 1 DAY) and unique_code = ${unique_code}";
}

@Override
public String getOutputTable(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "last_30d_" + uniqueKey;
}

@Override
public boolean isNeedDefaultDatasource() {
return true;
}

@Override
public void prepare(Map<String, String> config) {

}
}
132 changes: 66 additions & 66 deletions ...tric-expected-weekly-avg/src/main/java/io/datavines/metric/expected/plugin/WeeklyAvg.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.datavines.metric.expected.plugin;

import io.datavines.metric.api.ExpectedValue;

import java.util.Map;

import static io.datavines.common.ConfigConstants.METRIC_UNIQUE_KEY;

public class WeeklyAvg implements ExpectedValue {

@Override
public String getName() {
return "weekly_avg";
}

@Override
public String getKey(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "expected_value_" + uniqueKey;
}

@Override
public String getZhName() {
return "周均值";
}

@Override
public String getExecuteSql(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "select round(avg(actual_value),2) as weekly_avg" + "expected_value_" + uniqueKey +
" from dv_actual_values where data_time >= date_sub(${data_time},interval weekday(${data_time}) + 0 day)" +
" and data_time < date_add(date_format(${data_time},'%Y-%m-%d'),interval 1 DAY) and unique_code = ${unique_code}";
}

@Override
public String getOutputTable(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "weekly_range_" + uniqueKey;
}

@Override
public boolean isNeedDefaultDatasource() {
return true;
}

@Override
public void prepare(Map<String, String> config) {

}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.datavines.metric.expected.plugin;

import io.datavines.metric.api.ExpectedValue;

import java.util.Map;

import static io.datavines.common.ConfigConstants.METRIC_UNIQUE_KEY;

public class WeeklyAvg implements ExpectedValue {

@Override
public String getName() {
return "weekly_avg";
}

@Override
public String getKey(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "expected_value_" + uniqueKey;
}

@Override
public String getZhName() {
return "周均值";
}

@Override
public String getExecuteSql(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "select round(avg(actual_value),2) as expected_value_" + uniqueKey +
" from dv_actual_values where data_time >= date_sub(${data_time},interval weekday(${data_time}) + 0 day)" +
" and data_time < date_add(date_format(${data_time},'%Y-%m-%d'),interval 1 DAY) and unique_code = ${unique_code}";
}

@Override
public String getOutputTable(Map<String,String> inputParameter) {
String uniqueKey = inputParameter.get(METRIC_UNIQUE_KEY);
return "weekly_range_" + uniqueKey;
}

@Override
public boolean isNeedDefaultDatasource() {
return true;
}

@Override
public void prepare(Map<String, String> config) {

}
}
Loading

0 comments on commit 440e16b

Please sign in to comment.