Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: adding dbt in score #50

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/org/schemata/app/SchemaScoreApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

public class SchemaScoreApp implements Callable<Integer> {

private List<Schema> schemaList;
private String schemaName;
private final List<Schema> schemaList;
private final String schemaName;

public SchemaScoreApp(List<Schema> schemaList, String schemaName) {
this.schemaList = schemaList;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/schemata/graph/SchemaGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ public Set<Schema> getAllEntityVertex() {
return graph.vertexSet().stream().filter(f -> "ENTITY".equalsIgnoreCase(f.type())).collect(Collectors.toSet());
}

public Set<Schema> getAllFactVertex() {
return graph.vertexSet().stream().filter(f -> "MODEL".equalsIgnoreCase(f.type()) && "FACT".equalsIgnoreCase(f.modelType()) ).collect(Collectors.toSet());
}

public Double getVertexPageRankScore(String vertex) {
return pageRank.getVertexScore(getSchema(vertex));
}
Expand All @@ -112,6 +116,7 @@ public Double getSchemataScore(String vertex) {
double score = switch (schema.type().toUpperCase()) {
case "ENTITY" -> computeEntityScore(vertex);
case "EVENT" -> computeEventScore(vertex, schema.eventType());
case "FACT" -> computeFactScore(vertex);
default -> 0.0;
};
return roundUp(score);
Expand All @@ -136,6 +141,11 @@ private double computeEventScore(String vertex, String eventType) {
return score;
}

public double computeFactScore(String vertex) {
System.out.println(getAllFactVertex());
return 0.0;
}

private double computeNonLifecycleScore(String vertex) {
Set<Schema> referenceVertex =
outgoingEntityVertexOf(vertex).stream().map(v -> outgoingEntityVertexOf(v.name())).flatMap(Collection::stream)
Expand Down
28 changes: 28 additions & 0 deletions src/test/java/org/schemata/graph/DerivedSchemaGraphTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.schemata.graph;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schemata.ResourceLoader;
import org.schemata.provider.dbt.DbtSchemaParser;

import static org.junit.jupiter.api.Assertions.assertEquals;


public class DerivedSchemaGraphTest {

static SchemaGraph graph;

@BeforeAll
static void setUp() {
DbtSchemaParser parser = new DbtSchemaParser();
var schemaList = parser.getSchemaList(ResourceLoader.getDbtBasePath());
graph = new SchemaGraph(schemaList);
}

@Test
public void testGetAllFaceVertex() {
assertEquals(1, graph.getAllFactVertex().size());
System.out.println(graph.getAllFactVertex());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;


public class SchemaGraphTest {
public class EventSchemaGraphTest {

static SchemaGraph graph;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import org.junit.jupiter.api.Test;
import org.schemata.ResourceLoader;

import static org.junit.jupiter.api.Assertions.assertEquals;


public class DbtSchemaParserTest {

@Test
public void testMe() {
public void testSchemataList() {
DbtSchemaParser parser = new DbtSchemaParser();
parser.getSchemaList(ResourceLoader.getDbtBasePath());
var schemaList = parser.getSchemaList(ResourceLoader.getDbtBasePath());
var expectedSize = 7;
assertEquals(expectedSize, schemaList.size());
}
}
2 changes: 2 additions & 0 deletions src/test/resources/dbt/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@
"tags": [],
"meta": {},
"materialized": "incremental",
"domain": "core",
"model_type": "fact",
"persist_docs": {},
"quoting": {},
"column_types": {},
Expand Down