From 37687bf8c3b0c77200816fabb5e23e8fc491b4e2 Mon Sep 17 00:00:00 2001 From: Luigi Asprino Date: Mon, 13 Nov 2023 12:46:29 +0100 Subject: [PATCH] Fix #421 --- .../engine/FacadeXOpExecutor.java | 5 ++--- .../github/sparqlanything/it/IssuesTest.java | 22 +++++++++++++++++++ .../src/test/resources/issues/issue421.sparql | 12 ++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 sparql-anything-it/src/test/resources/issues/issue421.sparql diff --git a/sparql-anything-engine/src/main/java/io/github/sparqlanything/engine/FacadeXOpExecutor.java b/sparql-anything-engine/src/main/java/io/github/sparqlanything/engine/FacadeXOpExecutor.java index 6df29630..5e254896 100644 --- a/sparql-anything-engine/src/main/java/io/github/sparqlanything/engine/FacadeXOpExecutor.java +++ b/sparql-anything-engine/src/main/java/io/github/sparqlanything/engine/FacadeXOpExecutor.java @@ -56,8 +56,7 @@ public FacadeXOpExecutor(ExecutionContext execCxt) { protected QueryIterator execute(final OpPropFunc opPropFunc, QueryIterator input){ logger.trace("OpProp {}", opPropFunc); - if (this.execCxt.getClass() == FacadeXExecutionContext.class) { - + if(!Utils.isFacadeXMagicPropertyNode(opPropFunc.getProperty())||this.execCxt.getClass() == FacadeXExecutionContext.class){ return super.execute(opPropFunc, input); }else { try { @@ -82,7 +81,7 @@ protected QueryIterator execute(final OpBGP opBGP, QueryIterator input) { throw new RuntimeException(e); } } - + // check that the BGP is within a FacadeX-SERVICE clause if (this.execCxt.getClass() == FacadeXExecutionContext.class) { // check that the BGP contains FacadeX Magic properties diff --git a/sparql-anything-it/src/test/java/io/github/sparqlanything/it/IssuesTest.java b/sparql-anything-it/src/test/java/io/github/sparqlanything/it/IssuesTest.java index 918ed5c3..631d97ef 100644 --- a/sparql-anything-it/src/test/java/io/github/sparqlanything/it/IssuesTest.java +++ b/sparql-anything-it/src/test/java/io/github/sparqlanything/it/IssuesTest.java @@ -860,6 +860,28 @@ public void testIssue371() throws URISyntaxException, IOException { // Assert.assertFalse(m1.isIsomorphicWith(m2)); // Assert.assertTrue(qExec.execSelect().hasNext()); + } + + + @Test + public void testIssue421() throws URISyntaxException, IOException { + Dataset ds = DatasetFactory.createGeneral(); + QC.setFactory(ARQ.getContext(), FacadeX.ExecutorFactory); + Query query; + String queryStr = IOUtils.toString(Objects.requireNonNull(getClass().getClassLoader().getResource("issues/issue421.sparql")).toURI(), StandardCharsets.UTF_8); + query = QueryFactory.create(queryStr); + +// System.out.println(Algebra.compile(query)); +// System.out.println(query.toString(Syntax.defaultSyntax)); + + QueryExecution qExec1 = QueryExecutionFactory.create(query, ds); +// System.out.println(ResultSetFormatter.asText(qExec1.execSelect())); + Set result = new HashSet<>(); + ResultSet rs = qExec1.execSelect(); + while (rs.hasNext()){ + result.add(rs.next().get("a").asLiteral().toString()); + } + assertEquals(Sets.newHashSet("abc", "cde"), result); } diff --git a/sparql-anything-it/src/test/resources/issues/issue421.sparql b/sparql-anything-it/src/test/resources/issues/issue421.sparql new file mode 100644 index 00000000..2bd4a459 --- /dev/null +++ b/sparql-anything-it/src/test/resources/issues/issue421.sparql @@ -0,0 +1,12 @@ +PREFIX fx: +PREFIX xyz: +PREFIX rdf: +PREFIX rdfs: +PREFIX apf: +SELECT ?a WHERE { + SERVICE { + fx:properties fx:content "abc;cde" . + ?s rdf:_1 ?o + } + ?a apf:strSplit(?o ";") . +} \ No newline at end of file