Skip to content
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
6 changes: 4 additions & 2 deletions examples/json_queries/aggregates.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"sum": "?v$sum",
"min": "?v$min",
"max": "?v$max",
"avg": "?v$avg$var:average"
"avg": "?v$avg$var:average",
"value_sum": "?value$sum"
},
"$where": [
"VALUES (?v) { (10.5) (20.5) }"
"VALUES (?v) { (10.5) (20.5) }",
"?id schema:value ?value"
]
}
3 changes: 2 additions & 1 deletion examples/json_transformed/aggregates.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"count": 2,
"max": 20.5,
"min": 10.5,
"sum": 31
"sum": 31,
"value_sum": 42
}
]
7 changes: 6 additions & 1 deletion examples/sparql_output/aggregates.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"head": {
"link": [],
"vars": ["total", "sum_v", "min_v", "max_v", "average"]
"vars": ["total", "sum_v", "min_v", "max_v", "average", "sum_value"]
},
"results": {
"distinct": false,
Expand Down Expand Up @@ -31,6 +31,11 @@
"type": "typed-literal",
"datatype": "http://www.w3.org/2001/XMLSchema#decimal",
"value": "15.5"
},
"sum_value": {
"type": "typed-literal",
"datatype": "http://www.w3.org/2001/XMLSchema#decimal",
"value": "42"
}
}]
}
Expand Down
5 changes: 3 additions & 2 deletions examples/sparql_queries/aggregates.rq
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SELECT DISTINCT (COUNT(DISTINCT ?v) AS ?total) (SUM(?v) AS ?sum_v) (MIN(?v) AS ?min_v) (MAX(?v) AS ?max_v) (AVG(?v) AS ?average)
SELECT DISTINCT (COUNT(DISTINCT ?v) AS ?total) (SUM(?v) AS ?sum_v) (MIN(?v) AS ?min_v) (MAX(?v) AS ?max_v) (AVG(?v) AS ?average) (SUM(?value) AS ?sum_value)
WHERE {
VALUES (?v) { (10.5) (20.5) }
VALUES (?v) { (10.5) (20.5) }.
?id schema:value ?value
}
2 changes: 1 addition & 1 deletion src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ function manageProtoKey(proto, vars = [], filters = [], wheres = [],

const aggrWhat = is$ ? id : originalId;
if (aggregate && !givenVar) {
id = is$ ? originalId : `?${aggregate}_${originalId.replace('?', '')}`;
id = `?${aggregate}_${aggrWhat.replace('?', '')}`;
}

// assign a clean id to the prototype
Expand Down