From: <jer...@us...> - 2013-10-08 23:56:06
|
Revision: 7440 http://bigdata.svn.sourceforge.net/bigdata/?rev=7440&view=rev Author: jeremy_carroll Date: 2013-10-08 23:55:58 +0000 (Tue, 08 Oct 2013) Log Message: ----------- Fixed up tests for trac747 - core problem is that FILTER( foo && TRUE ) is not handled correctly when foo includes unboundvar. Fixed this issue in ASTBottomUpOptimizer Added comments concerning my various misunderstandings of the spec, for the next person who has to struggle with the bottom up semantics Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/StaticAnalysis.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTBottomUpOptimizer.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTickets.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747-bound.srx branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747A-bound.rq Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747A-bound.srx branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747C-bound.rq branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747D-bound.rq Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/StaticAnalysis.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/StaticAnalysis.java 2013-10-07 20:58:21 UTC (rev 7439) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/StaticAnalysis.java 2013-10-08 23:55:58 UTC (rev 7440) @@ -124,7 +124,7 @@ * <dt>{@link UnionNode}</dt> * <dd>The definitely bound variables is the intersection of the definitely * bound variables in the child join groups. The maybe bound variables is the - * union of the definitely bound variables in the child join groups.</dd> + * union of the maybe bound variables in the child join groups.</dd> * * <dt>{@link AssignmentNode}</dt> * <dd>BIND(expr AS var) in a group will not bind the variable if there is an @@ -1379,7 +1379,7 @@ * * 6. Projection of an exogenously bound variable which is in scope. * - * TODO (5) is not yet handled! We need to know what variables are in + * TODO (6) is not yet handled! We need to know what variables are in * scope at each level as we descend into subqueries. Even if we know * the set of exogenous variables, the in scope exogenous varaibles are * not available in the typical invocation context. @@ -1485,7 +1485,14 @@ */ tmp.add(bind.getVar()); + } else { + /* 5. Projection of a select expression which is an aggregate. + * We do nothing + */ } + /* 6. Projection of an exogenously bound variable which is in scope. + * We incorrectly do nothing + */ } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTBottomUpOptimizer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTBottomUpOptimizer.java 2013-10-07 20:58:21 UTC (rev 7439) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTBottomUpOptimizer.java 2013-10-08 23:55:58 UTC (rev 7440) @@ -27,6 +27,7 @@ package com.bigdata.rdf.sparql.ast.optimizers; +import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; @@ -44,6 +45,7 @@ import com.bigdata.rdf.internal.constraints.SparqlTypeErrorBOp; import com.bigdata.rdf.sparql.ast.ASTBase; import com.bigdata.rdf.sparql.ast.FilterNode; +import com.bigdata.rdf.sparql.ast.FunctionNode; import com.bigdata.rdf.sparql.ast.GlobalAnnotations; import com.bigdata.rdf.sparql.ast.GraphPatternGroup; import com.bigdata.rdf.sparql.ast.IBindingProducerNode; @@ -683,6 +685,18 @@ * * Note: This is ONLY true when the [group] is OPTIONAL. * Otherwise the variables in the parent are not visible. + * + * Two fairly difficult test cases articulating the scope rules + * are: + * + * http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/filter-nested-2.rq + * + * and + * + * http://www.w3.org/2001/sw/DataAccess/tests/data-r2/optional-filter/manifest#dawg-optional-filter-005-not-simplified + * (see + * http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#convertGraphPattern) + * */ // The "required" part of the optional is the parent group. @@ -718,9 +732,23 @@ * Re-generate the IVE for this filter. */ - // clear the old value expression. - filter.getValueExpressionNode().setValueExpression(null); + // Recursively clear the old value expression. + + + // gather subexpression (avoiding CCME) + List<FunctionNode> subexpr = new ArrayList<FunctionNode>(); + final Iterator<FunctionNode> veitr = BOpUtility.visitAll(filter, FunctionNode.class); + while (veitr.hasNext()) { + subexpr.add(veitr.next()); + } + + // clear + for (FunctionNode ive:subexpr) { + ive.setValueExpression(null); + } + + final GlobalAnnotations globals = new GlobalAnnotations( context.getLexiconNamespace(), context.getTimestamp() @@ -792,7 +820,7 @@ final IValueExpressionNode child = (IValueExpressionNode) tmp; - modified |= rewriteUnboundVariablesInFilter(context, + modified |= rewriteUnboundVariablesInFilter(context, maybeBound, map, node, child); } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTickets.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTickets.java 2013-10-07 20:58:21 UTC (rev 7439) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestTickets.java 2013-10-08 23:55:58 UTC (rev 7440) @@ -127,7 +127,7 @@ ).runTest(); } - public void xtest_ticket_747() throws Exception { + public void test_ticket_747() throws Exception { new TestHelper("ticket747-bound",// testURI, "ticket747-bound.rq",// queryFileURL @@ -143,13 +143,13 @@ new TestHelper("ticket747A-bound",// testURI, "ticket747A-bound.rq",// queryFileURL "ticket747-bound.ttl",// dataFileURL - "ticket747-bound.srx"// resultFileURL + "ticket747A-bound.srx"// resultFileURL ).runTest(); } - public void xtest_ticket_747b() throws Exception { + public void test_ticket_747b() throws Exception { new TestHelper("ticket747B-bound",// testURI, "ticket747B-bound.rq",// queryFileURL @@ -158,7 +158,25 @@ ).runTest(); } - + + public void test_ticket_747c() throws Exception { + + new TestHelper("ticket747-bound",// testURI, + "ticket747C-bound.rq",// queryFileURL + "ticket747-bound.ttl",// dataFileURL + "ticket747-bound.srx"// resultFileURL + ).runTest(); + + } + public void test_ticket_747d() throws Exception { + + new TestHelper("ticket747B-bound",// testURI, + "ticket747D-bound.rq",// queryFileURL + "ticket747-bound.ttl",// dataFileURL + "ticket747-bound.srx"// resultFileURL + ).runTest(); + + } public void test_ticket_748() throws Exception { new TestHelper("ticket748-subselect",// testURI, Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747-bound.srx =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747-bound.srx 2013-10-07 20:58:21 UTC (rev 7439) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747-bound.srx 2013-10-08 23:55:58 UTC (rev 7440) @@ -8,13 +8,5 @@ <variable name="Y"/> </head> <results> - <result> - <binding name="X"> - <literal>x</literal> - </binding> - <binding name="Y"> - <literal>y</literal> - </binding> - </result> </results> </sparql> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747A-bound.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747A-bound.rq 2013-10-07 20:58:21 UTC (rev 7439) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747A-bound.rq 2013-10-08 23:55:58 UTC (rev 7440) @@ -1,6 +1,3 @@ -# The query in ticket747 can be addressed by reordering the optimizers -# However, it is a 'false' fix, and this more difficult variant requires fixing -# some other faulty logic SELECT * WHERE { @@ -11,6 +8,6 @@ } BIND ( "x" as $X ) FILTER( BOUND($Y) -# && True + && True ) } Copied: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747A-bound.srx (from rev 7439, branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747-bound.srx) =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747A-bound.srx (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747A-bound.srx 2013-10-08 23:55:58 UTC (rev 7440) @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<sparql + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:xs="http://www.w3.org/2001/XMLSchema#" + xmlns="http://www.w3.org/2005/sparql-results#" > + <head> + <variable name="X"/> + <variable name="Y"/> + </head> + <results> + <result> + <binding name="X"> + <literal>x</literal> + </binding> + <binding name="Y"> + <literal>y</literal> + </binding> + </result> + </results> +</sparql> Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747C-bound.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747C-bound.rq (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747C-bound.rq 2013-10-08 23:55:58 UTC (rev 7440) @@ -0,0 +1,10 @@ +SELECT * +WHERE { + BIND ( "y" as $Y ) . + { + BIND ( "x" as $X ) + FILTER( BOUND($Y) + && True + ) + } +} Added: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747D-bound.rq =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747D-bound.rq (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/ticket747D-bound.rq 2013-10-08 23:55:58 UTC (rev 7440) @@ -0,0 +1,19 @@ +SELECT * +WHERE { + { BIND ( "y" as $Y ) . + } + UNION + { + FILTER (false) + } + { + BIND ( "x" as $X ) + FILTER( BOUND($Y) + && True + ) + } + UNION + { + FILTER (false) + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |