public class VerifyAggregates extends Object
Note: This is a port of
does not depend on the blazegraph operator model. It was developed as part of
BLZG-1176 to decouple the SPARQL parser from the database.
|Constructor and Description|
|Modifier and Type||Method and Description|
Verify the various conditions that must be met when a query uses GROUP BY or when a query uses aggregates in a PROJECTION.
protected boolean isAggregate(BOp op, boolean isSelectClause, AtomicBoolean isSelectDependency, AtomicBoolean isNestedAggregates, AtomicBoolean isAnyDistinct)
trueiff the expression is an aggregate.
Aggregates may be built out of constants, references to
s which are already defined and which are themselves aggregates, and
IAggregate functions. An
IVariable will be an aggregate
if it appears as a bare variable in a GROUP_BY clause or if it declared
by a prior value expression in a GROUP_BY or SELECT clause. Testing
whether or not an
IValueExpression is an aggregate therefore
depends on access to the set of known aggregates. The value expressions
in the GROUP_BY clause must be processed first (in order) followed by the
value expressions in the SELECT clause (in order).
An aggregate may use a non-aggregate variable only allowed within an
IAggregate function. For example, given:
SUM(?x) as ?y,
?x must be a non-aggregate
?y will be an aggregate variable.
Aggregate variables may be used both inside and outside of an
IAggregate function as long as the variable was declared before
it was used. For example, the following are legal:
SELECT SUM(?x) as ?y, SUM(?x + ?y) as ?z, SUM(?x)+AVG(?x) as ?z2 SELECT SUM(?x) as ?y, SUM(?x + COUNT(?y)) as ?zPatterns where an aggregate depends on a prior aggregate prevent certain optimizations, notably you have to evaluate each aggregate in turn rather than evaluating them in parallel over the solutions is a group. If any such patterns are observed in the SELECT clause then this method will set
isSelectDependency := trueas a side-effect.
trueif the op appears a SELECT clause.
isSelectDependency- Set as a side-effect when an
IValueExpressionappearing in a SELECT clause has a dependency on an
IVariabledeclared in the GROUP_BY clause or earlier in the SELECT clause. This argument is optional unless isSelectClause is
isNestedAggregates- Set as a side-effect when an
isAnyDistinct- Set as a side-effect if an
IAggregatefunction is encountered which reports
trueiff the operator is an aggregate.
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.