kasei / attean

A Perl Semantic Web Framework
19 stars 10 forks source link

Fix in-scope variables in aggregating sub-select #78

Closed kasei closed 8 years ago

kasei commented 8 years ago
SELECT * WHERE {
    {
        SELECT ?o (AVG(?v) AS ?mean) WHERE
        {
            ?s <subject> ?o ;
                <value> ?v .
        }
        GROUP BY ?o
    }
}

results in the algebra:

- Query
-   Project { ?mean }
-     SubQuery
-       Project { ?o ?mean }
-         Extend { ?mean ← ?.AVG(?v) }
-           Group { ?o } aggregate { ?.AVG(?v) ← AVG(?v) }
-             BGP { ?s <subject> ?o ., ?s <value> ?v . }

where the top-level projection has lost the grouping variable.