Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { createEdgeType } from "@/core";
import { query } from "@/utils";

import edgeConnectionsTemplate from "./edgeConnectionsTemplate";

describe("edgeConnectionsTemplate", () => {
it("should produce a subquery with LIMIT inside and DISTINCT outside", () => {
const predicate = createEdgeType("http://example.org/knows");

const result = edgeConnectionsTemplate(predicate);

expect(result).toBe(query`
SELECT DISTINCT ?sourceType ?targetType
WHERE {
SELECT ?sourceType ?targetType
WHERE {
?s <http://example.org/knows> ?o .
FILTER(!isLiteral(?o))
?s a ?sourceType .
?o a ?targetType .
}
LIMIT 10000
}
`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { EdgeType } from "@/core";

import { DEFAULT_SAMPLE_SIZE, query } from "@/utils";

import { idParam } from "../idParam";

/**
* Returns a SPARQL query to discover distinct edge connection patterns for a specific predicate.
* Uses sampling to efficiently discover patterns in large databases.
Expand All @@ -13,11 +15,14 @@ export default function edgeConnectionsTemplate(predicate: EdgeType) {
return query`
SELECT DISTINCT ?sourceType ?targetType
WHERE {
?s <${predicate}> ?o .
FILTER(!isLiteral(?o))
?s a ?sourceType .
?o a ?targetType .
SELECT ?sourceType ?targetType
WHERE {
?s ${idParam(predicate)} ?o .
FILTER(!isLiteral(?o))
?s a ?sourceType .
?o a ?targetType .
}
LIMIT ${DEFAULT_SAMPLE_SIZE}
}
LIMIT ${DEFAULT_SAMPLE_SIZE}
`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { VertexType } from "@/core";

import { query } from "@/utils";

import { idParam } from "../idParam";

// Return all predicates which are connected from the given class
export default function predicatesByClassTemplate(props: {
class: VertexType;
Expand All @@ -13,7 +15,7 @@ export default function predicatesByClassTemplate(props: {
{
SELECT ?subject
WHERE {
?subject a <${props.class}>.
?subject a ${idParam(props.class)}.
}
LIMIT 1
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { query } from "@/utils";

import { idParam } from "../idParam";

// It returns the number of instances of the given class
export default function classWithCountsTemplates(className: string) {
return query`
# Fetch the number of instances of the given class
SELECT (COUNT(?start) AS ?instancesCount) {
?start a <${className}>
?start a ${idParam(className)}
}
`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
"title": "Predicate Styling"
},
"keyword-search": {
"node-type-placeholder": "Select a resource class",
"node-type-placeholder": "Select a class",
"node-attribute-placeholder": "Select a predicate"
},
"connection-detail": {
"search-placeholder": "Search for resource classes",
"no-search-title": "No Resource Classes",
"no-search-subtitle": "No resource classes found with searched criteria",
"search-placeholder": "Search for classes",
"no-search-title": "No Classes",
"no-search-subtitle": "No classes found with searched criteria",
"no-elements-title": "No Resources",
"no-elements-subtitle": "No resources found to be shown in this list"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { RefreshCcwIcon } from "lucide-react";

import {
Button,
InfoTooltip,
PanelHeader,
PanelHeaderActions,
PanelHeaderDivider,
Expand All @@ -25,7 +26,13 @@ import { schemaGraphLayoutAtom } from "./SchemaGraph";
export function SchemaGraphToolbar() {
return (
<PanelHeader>
<PanelTitle>Schema Graph</PanelTitle>
<PanelTitle>
Schema Graph{" "}
<InfoTooltip>
This schema was implicitly discovered by sampling the structure of the
data and may not represent the complete schema.
</InfoTooltip>
</PanelTitle>
<PanelHeaderActions className="gap-1.5">
<SelectLayout
className="max-w-64 min-w-auto"
Expand Down