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
Expand Up @@ -506,7 +506,8 @@ protected Op compileModifiers(Query query, Op pattern) {
op = OpGroup.create(op, query.getGroupBy(), query.getAggregators());
}

// ---- Assignments from SELECT and other places (so available to ORDER and
// ---- Assignments from SELECT and other places
// (so available to ORDER and
// HAVING)
// Now do assignments from expressions
// Must be after "group by" has introduced it's variables.
Expand All @@ -529,8 +530,17 @@ protected Op compileModifiers(Query query, Op pattern) {
}
}

// ---- Assignments from SELECT and other places (so available to ORDER and
// HAVING)
// ---- VALUES
if ( query.hasValues() ) {
Table table = TableFactory.create(query.getValuesVariables());
for ( Binding binding : query.getValuesData() )
table.addBinding(binding);
OpTable opTable = OpTable.create(table);
op = OpJoin.create(op, opTable);
}

// ---- Assignments from SELECT and other places
// (so available to ORDER and HAVING)
for ( Var v : exprs.getVars() ) {
Expr e = exprs.getExpr(v);
op = OpExtend.create(op, v, e);
Expand All @@ -544,15 +554,6 @@ protected Op compileModifiers(Query query, Op pattern) {
op = OpFilter.filter(expr2, op);
}
}
// ---- VALUES
if ( query.hasValues() ) {
Table table = TableFactory.create(query.getValuesVariables());
for ( Binding binding : query.getValuesData() )
table.addBinding(binding);
OpTable opTable = OpTable.create(table);
op = OpJoin.create(op, opTable);
}

// ---- ToList
if ( context.isTrue(ARQ.generateToList) )
// Listify it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void check(Query query) {
// - not legal in SPARQL 1.2, unclear in SPARQL 1.1
// Legal in ARQ
// Query.hasGroupBy() includes a check of aggregators
if ( !Syntax.syntaxARQ.equals(query.getSyntax()) ) {
if ( !Syntax.syntaxARQ.equals(query.getSyntax()) && query.isSelectType() ) {
if ( query.isQueryResultStar() && query.hasGroupBy() )
throw new QueryParseException("SELECT * not legal with GROUP BY", -1, -1);
}
Expand Down Expand Up @@ -147,6 +147,12 @@ private static void checkExprVarGroupBy(Query query) {
VarExprList groupKey = query.getGroupBy();
// Mutated so copy.
List<Var> inScopeVars = new ArrayList<>(groupKey.getVars());
// and trailing VALUES
if ( query.hasValues() ) {
List<Var> x = query.getValuesVariables();
inScopeVars.addAll(x);
}

VarExprList exprList = query.getProject();

// Look in the SELECT expressions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void scope_65() {
@Test
public void scope_66() {
assertThrows(QueryException.class,
()-> scope("SELECT ( (?x+1) AS ?y) (2 AS ?x) {}"));
()->scope("SELECT ( (?x+1) AS ?y) (2 AS ?x) {}"));
}

// GH-3164
Expand All @@ -165,10 +165,12 @@ public void scope_66() {
GROUP BY ?s
VALUES ?min { 2 5 }
""";
scope(qsVarScope);
assertThrows(QueryException.class,
()->scope(qsVarScope));
}

@Test public void scope_71() {
scope("SELECT (MIN(?v) as ?min) WHERE {} VALUES ?min { 2 5 }");
assertThrows(QueryException.class,
()->scope("SELECT (MIN(?v) as ?min) WHERE {} VALUES ?min { 2 5 }"));
}
}
Loading