-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into 1503
# Conflicts: # gradle/libs.versions.toml
- Loading branch information
Showing
84 changed files
with
2,491 additions
and
1,088 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...src/main/java/org/opendatadiscovery/oddplatform/controller/DataQualityRunsController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.opendatadiscovery.oddplatform.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.opendatadiscovery.oddplatform.api.contract.api.DataQualityRunsApi; | ||
import org.opendatadiscovery.oddplatform.api.contract.model.DataQualityResults; | ||
import org.opendatadiscovery.oddplatform.service.DataQualityRunsService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.server.ServerWebExchange; | ||
import reactor.core.publisher.Mono; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class DataQualityRunsController implements DataQualityRunsApi { | ||
private final DataQualityRunsService service; | ||
|
||
@Override | ||
public Mono<ResponseEntity<DataQualityResults>> getDataQualityTestsRuns( | ||
final ServerWebExchange exchange) { | ||
return service.getDataQualityTestsRuns() | ||
.map(ResponseEntity::ok); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...platform-api/src/main/java/org/opendatadiscovery/oddplatform/dto/DataQualityCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.opendatadiscovery.oddplatform.dto; | ||
|
||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import lombok.Getter; | ||
|
||
import static java.util.function.Function.identity; | ||
|
||
@Getter | ||
public enum DataQualityCategory { | ||
ASSERTION("Assertion Tests"), | ||
VOLUME_ANOMALY("Volume Anomalies"), | ||
FRESHNESS_ANOMALY("Freshness Anomalies"), | ||
COLUMN_VALUES_ANOMALY("Column Values Anomalies"), | ||
SCHEMA_CHANGE("Schema Changes"), | ||
UNKNOWN("Unknown category"); | ||
|
||
private final String description; | ||
|
||
DataQualityCategory(final String description) { | ||
this.description = description; | ||
} | ||
|
||
private static final Map<String, DataQualityCategory> DICT = Arrays | ||
.stream(values()) | ||
.collect(Collectors.toMap(DataQualityCategory::name, identity())); | ||
|
||
public static DataQualityCategory resolveByName(final String name) { | ||
return DICT.getOrDefault(name, UNKNOWN); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...api/src/main/java/org/opendatadiscovery/oddplatform/mapper/DataQualityCategoryMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.opendatadiscovery.oddplatform.mapper; | ||
|
||
import java.util.List; | ||
import org.jooq.Record3; | ||
import org.opendatadiscovery.oddplatform.api.contract.model.DataQualityCategoryResults; | ||
|
||
public interface DataQualityCategoryMapper { | ||
String TASK_RUNS_COUNT = "TASK_RUNS_COUNT"; | ||
String TASK_RUN_CATEGORY = "TASK_RUN_CATEGORY"; | ||
|
||
List<DataQualityCategoryResults> mapToDto(List<Record3<String, String, Integer>> items); | ||
} |
62 changes: 62 additions & 0 deletions
62
...src/main/java/org/opendatadiscovery/oddplatform/mapper/DataQualityCategoryMapperImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.opendatadiscovery.oddplatform.mapper; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
import org.jooq.Record3; | ||
import org.opendatadiscovery.oddplatform.api.contract.model.DataEntityRunStatus; | ||
import org.opendatadiscovery.oddplatform.api.contract.model.DataQualityCategoryResults; | ||
import org.opendatadiscovery.oddplatform.api.contract.model.DataQualityRunStatusCount; | ||
import org.opendatadiscovery.oddplatform.dto.DataQualityCategory; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static org.opendatadiscovery.oddplatform.model.tables.DataEntityTaskLastRun.DATA_ENTITY_TASK_LAST_RUN; | ||
|
||
@Component | ||
public class DataQualityCategoryMapperImpl implements DataQualityCategoryMapper { | ||
private static final String TASK_RUNS_COUNT = "TASK_RUNS_COUNT"; | ||
private static final String TASK_RUN_CATEGORY = "TASK_RUN_CATEGORY"; | ||
|
||
@Override | ||
public List<DataQualityCategoryResults> mapToDto(final List<Record3<String, String, Integer>> items) { | ||
final Map<DataQualityCategory, DataQualityCategoryResults> categoryResults = | ||
Arrays.stream(DataQualityCategory.values()) | ||
.collect(Collectors.toMap(Function.identity(), | ||
value -> | ||
new DataQualityCategoryResults() | ||
.category(value.getDescription()) | ||
.results(new ArrayList<>()))); | ||
|
||
items.forEach(row -> categoryResults.get(DataQualityCategory | ||
.resolveByName(row.get(TASK_RUN_CATEGORY, String.class))) | ||
.getResults().add(new DataQualityRunStatusCount() | ||
.status(DataEntityRunStatus | ||
.fromValue(row.getValue(DATA_ENTITY_TASK_LAST_RUN.STATUS))) | ||
.count(Long.valueOf(row.get(TASK_RUNS_COUNT, Integer.class))))); | ||
|
||
return addMissingStatuses(categoryResults.values() | ||
.stream() | ||
.toList()); | ||
} | ||
|
||
private List<DataQualityCategoryResults> addMissingStatuses(final List<DataQualityCategoryResults> resultsList) { | ||
for (final DataQualityCategoryResults dataQualityCategoryResults : resultsList) { | ||
final Set<DataEntityRunStatus> existedElements = dataQualityCategoryResults.getResults() | ||
.stream().map(DataQualityRunStatusCount::getStatus) | ||
.collect(Collectors.toSet()); | ||
|
||
Arrays.stream(DataEntityRunStatus.values()) | ||
.filter(value -> !existedElements.contains(value)) | ||
.forEach(value -> dataQualityCategoryResults.getResults() | ||
.add(new DataQualityRunStatusCount() | ||
.status(value) | ||
.count(0L))); | ||
} | ||
|
||
return resultsList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...orm-api/src/main/java/org/opendatadiscovery/oddplatform/mapper/TablesDashboardMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.opendatadiscovery.oddplatform.mapper; | ||
|
||
import java.util.List; | ||
import org.jooq.Record2; | ||
import org.opendatadiscovery.oddplatform.api.contract.model.TablesDashboard; | ||
|
||
public interface TablesDashboardMapper { | ||
String TABLE_STATUS = "STATUS"; | ||
String GOOD_HEALTH = "GOOD_HEALTH"; | ||
String ERROR_HEALTH = "ERROR"; | ||
String WARNING_HEALTH = "WARNING"; | ||
String MONITORED_TABLES = "MONITORED_TABLES"; | ||
String NOT_MONITORED_TABLES = "NOT_MONITORED_TABLES"; | ||
String COUNT = "COUNT"; | ||
|
||
TablesDashboard mapToDto(final List<Record2<Integer, String>> tableHealth, | ||
final List<Record2<Integer, String>> monitoredTablesStatus); | ||
} |
39 changes: 39 additions & 0 deletions
39
...api/src/main/java/org/opendatadiscovery/oddplatform/mapper/TablesDashboardMapperImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.opendatadiscovery.oddplatform.mapper; | ||
|
||
import java.util.List; | ||
import org.jooq.Record2; | ||
import org.opendatadiscovery.oddplatform.api.contract.model.MonitoredTablesDashboard; | ||
import org.opendatadiscovery.oddplatform.api.contract.model.TablesDashboard; | ||
import org.opendatadiscovery.oddplatform.api.contract.model.TablesHealthDashboard; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class TablesDashboardMapperImpl implements TablesDashboardMapper { | ||
@Override | ||
public TablesDashboard mapToDto(final List<Record2<Integer, String>> tableHealth, | ||
final List<Record2<Integer, String>> monitoredTablesStatus) { | ||
final TablesHealthDashboard tablesHealthDashboard = new TablesHealthDashboard(); | ||
|
||
tableHealth.forEach(row -> { | ||
switch (row.get(TABLE_STATUS, String.class)) { | ||
case GOOD_HEALTH -> tablesHealthDashboard.setHealthyTables(row.get(COUNT, Integer.class)); | ||
case ERROR_HEALTH -> tablesHealthDashboard.setErrorTables(row.get(COUNT, Integer.class)); | ||
case WARNING_HEALTH -> tablesHealthDashboard.setWarningTables(row.get(COUNT, Integer.class)); | ||
} | ||
}); | ||
|
||
final MonitoredTablesDashboard monitoredTablesDashboard = new MonitoredTablesDashboard(); | ||
|
||
monitoredTablesStatus.forEach(row -> { | ||
switch (row.get(TABLE_STATUS, String.class)) { | ||
case MONITORED_TABLES -> monitoredTablesDashboard.setMonitoredTables(row.get(COUNT, Integer.class)); | ||
case NOT_MONITORED_TABLES -> | ||
monitoredTablesDashboard.setNotMonitoredTables(row.get(COUNT, Integer.class)); | ||
} | ||
}); | ||
|
||
return new TablesDashboard() | ||
.tablesHealth(tablesHealthDashboard) | ||
.monitoredTables(monitoredTablesDashboard); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../opendatadiscovery/oddplatform/repository/reactive/ReactiveDataQualityRunsRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.opendatadiscovery.oddplatform.repository.reactive; | ||
|
||
import org.jooq.Record2; | ||
import org.jooq.Record3; | ||
import reactor.core.publisher.Flux; | ||
|
||
public interface ReactiveDataQualityRunsRepository { | ||
|
||
Flux<Record3<String, String, Integer>> getLatestDataQualityRunsResults(); | ||
|
||
Flux<Record2<Integer, String>> getLatestTablesHealth(); | ||
|
||
Flux<Record2<Integer, String>> getMonitoredTables(); | ||
} |
Oops, something went wrong.