Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Queries with inverse property path expression throw AssertionError in Var because parent is already set #4189

Closed
jetztgradnet opened this issue Sep 14, 2022 · 1 comment · Fixed by #4190
Labels
🐞 bug issue is a bug
Milestone

Comments

@jetztgradnet
Copy link

Current Behavior

Current Behavior

When parsing the following query with RDF4J 4.1.2 (worked with 4.1.0 and 4.0.0) I get an AssertionError:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT *
{
  ?x foaf:knows/^foaf:knows ?y .  
  FILTER(?x != ?y)
}

This might be related to recent optimizations (also the follow-ups for #4157) and is likely missing one of the Expr.clone() calls or so?

Stacktrace:

java.lang.AssertionError: Unexpected assertion
	at com.metaphacts.rdf4j.RDF4JTest.testVar(RDF4JTest.java:20)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: java.lang.AssertionError
	at org.eclipse.rdf4j.query.algebra.Var.setParentNode(Var.java:112)
	at org.eclipse.rdf4j.query.algebra.StatementPattern.<init>(StatementPattern.java:101)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:1486)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:237)
	at org.eclipse.rdf4j.query.parser.sparql.ast.ASTPathElt.jjtAccept(ASTPathElt.java:32)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:1411)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:237)
	at org.eclipse.rdf4j.query.parser.sparql.ast.ASTPathSequence.jjtAccept(ASTPathSequence.java:30)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:1358)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:237)
	at org.eclipse.rdf4j.query.parser.sparql.ast.ASTPathAlternative.jjtAccept(ASTPathAlternative.java:28)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:1663)
	at org.eclipse.rdf4j.query.parser.sparql.ast.ASTPropertyListPath.jjtAccept(ASTPropertyListPath.java:28)
	at org.eclipse.rdf4j.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:102)
	at org.eclipse.rdf4j.query.parser.sparql.AbstractASTVisitor.visit(AbstractASTVisitor.java:846)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:2633)
	at org.eclipse.rdf4j.query.parser.sparql.ast.ASTTriplesSameSubjectPath.jjtAccept(ASTTriplesSameSubjectPath.java:28)
	at org.eclipse.rdf4j.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:102)
	at org.eclipse.rdf4j.query.parser.sparql.AbstractASTVisitor.visit(AbstractASTVisitor.java:381)
	at org.eclipse.rdf4j.query.parser.sparql.ast.ASTBasicGraphPattern.jjtAccept(ASTBasicGraphPattern.java:27)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:1197)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:237)
	at org.eclipse.rdf4j.query.parser.sparql.ast.ASTGraphPatternGroup.jjtAccept(ASTGraphPatternGroup.java:27)
	at org.eclipse.rdf4j.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:102)
	at org.eclipse.rdf4j.query.parser.sparql.AbstractASTVisitor.visit(AbstractASTVisitor.java:880)
	at org.eclipse.rdf4j.query.parser.sparql.ast.ASTWhereClause.jjtAccept(ASTWhereClause.java:27)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:355)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:237)
	at org.eclipse.rdf4j.query.parser.sparql.ast.ASTSelectQuery.jjtAccept(ASTSelectQuery.java:27)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:346)
	at org.eclipse.rdf4j.query.parser.sparql.TupleExprBuilder.visit(TupleExprBuilder.java:237)
	at org.eclipse.rdf4j.query.parser.sparql.ast.ASTQueryContainer.jjtAccept(ASTQueryContainer.java:29)
	at org.eclipse.rdf4j.query.parser.sparql.SPARQLParser.buildQueryModel(SPARQLParser.java:246)
	at org.eclipse.rdf4j.query.parser.sparql.SPARQLParser.parseQuery(SPARQLParser.java:206)
	at com.metaphacts.rdf4j.RDF4JTest.testVar(RDF4JTest.java:17)
	... 26 more

Expected Behavior

The query can be parsed without errors.

Steps To Reproduce

This unit test reproduces the behavior:

Removing the inverse operator in the property path (foaf:knows/^foaf:knows -> foaf:knows/foaf:knows) makes it pass, so the issue must be somewhere in there.

package com.metaphacts.rdf4j;

import org.eclipse.rdf4j.query.parser.sparql.SPARQLParser;
import org.junit.Test;

public class RDF4JTest {
	@Test
	public void testVar() throws Exception {
		String queryString = "PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n"
				+ "  SELECT *\n"
				+ "  {\n"
				+ "    ?x foaf:knows/^foaf:knows ?y .  \n"
				+ "    FILTER(?x != ?y)\n"
				+ "  }\n";
		SPARQLParser parser = new SPARQLParser();
		try {
			parser.parseQuery(queryString, null);
		}
		catch (AssertionError e) {
			throw new AssertionError("Unexpected assertion", e);
		}
	}
}

Version

4.1.2

Are you interested in contributing a solution yourself?

No response

Anything else?

No response

@jetztgradnet jetztgradnet added the 🐞 bug issue is a bug label Sep 14, 2022
@jetztgradnet
Copy link
Author

jetztgradnet commented Sep 14, 2022

@hmottestad I think this relates to/is a follow-up of #4157.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug issue is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants