From 5273e399ea7b7af9548be1fef301ff1ea01ed10e Mon Sep 17 00:00:00 2001 From: Satia Herfert Date: Mon, 10 Sep 2018 12:33:22 +0200 Subject: [PATCH] Update frontend dependency Adapt test expectations after removed rewriter --- ...RequiredOrderStatementConvertersTest.scala | 145 +++-------- .../StatementConvertersTest.scala | 17 +- ...ProvidedOrderPlanningIntegrationTest.scala | 245 ++++++++---------- ...dexWithValuesPlanningIntegrationTest.scala | 30 +-- .../planner/logical/QueryGraphProducer.scala | 17 +- ...lacePropertyLookupsWithVariablesTest.scala | 7 - ...IndexWithProvidedOrderAcceptanceTest.scala | 2 +- .../IndexWithValuesAcceptanceTest.scala | 12 +- .../acceptance/OrderAcceptanceTest.scala | 16 +- pom.xml | 2 +- 10 files changed, 204 insertions(+), 289 deletions(-) diff --git a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/ast/convert/plannerQuery/RequiredOrderStatementConvertersTest.scala b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/ast/convert/plannerQuery/RequiredOrderStatementConvertersTest.scala index 830ae8417fd2..630cb55f253d 100644 --- a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/ast/convert/plannerQuery/RequiredOrderStatementConvertersTest.scala +++ b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/ast/convert/plannerQuery/RequiredOrderStatementConvertersTest.scala @@ -22,7 +22,8 @@ package org.neo4j.cypher.internal.compiler.v3_5.ast.convert.plannerQuery import org.neo4j.cypher.internal.compiler.v3_5.planner.LogicalPlanningTestSupport import org.neo4j.cypher.internal.ir.v3_5._ import org.neo4j.cypher.internal.v3_5.logical.plans._ -import org.opencypher.v9_0.ast.{AscSortItem, DescSortItem} +import org.opencypher.v9_0.ast.AscSortItem +import org.opencypher.v9_0.ast.DescSortItem import org.opencypher.v9_0.expressions._ import org.opencypher.v9_0.util.test_helpers.CypherFunSuite @@ -34,11 +35,7 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val expectation = RegularPlannerQuery( queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.asc("n.prop"), - horizon = RegularQueryProjection(Map(" FRESHID19" -> prop("n", "prop")), QueryShuffle(Seq(AscSortItem(varFor(" FRESHID19"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID19")), - horizon = RegularQueryProjection(Map("n.prop" -> varFor(" FRESHID19"))) - )) + horizon = RegularQueryProjection(Map("n.prop" -> prop("n", "prop")), QueryShuffle(Seq(AscSortItem(varFor("n.prop"))(pos)))) ) result should equal(expectation) @@ -50,11 +47,7 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val expectation = RegularPlannerQuery( queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.asc("n.prop"), - horizon = DistinctQueryProjection(Map(" FRESHID28" -> prop("n", "prop")), QueryShuffle(Seq(AscSortItem(varFor(" FRESHID28"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID28")), - horizon = RegularQueryProjection(Map("n.prop" -> varFor(" FRESHID28"))) - )) + horizon = DistinctQueryProjection(Map("n.prop" -> prop("n", "prop")), QueryShuffle(Seq(AscSortItem(varFor("n.prop"))(pos)))) ) result should equal(expectation) @@ -66,11 +59,7 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val expectation = RegularPlannerQuery( queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.asc("n.prop"), - horizon = AggregatingQueryProjection(Map(" FRESHID19" -> prop("n", "prop")), Map(" FRESHID25" -> CountStar()(pos)), QueryShuffle(Seq(AscSortItem(varFor(" FRESHID19"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID19", " FRESHID25")), - horizon = RegularQueryProjection(Map("n.prop" -> varFor(" FRESHID19"), "count(*)" -> varFor(" FRESHID25"))) - )) + horizon = AggregatingQueryProjection(Map("n.prop" -> prop("n", "prop")), Map("count(*)" -> CountStar()(pos)), QueryShuffle(Seq(AscSortItem(varFor("n.prop"))(pos)))) ) result should equal(expectation) @@ -82,11 +71,7 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val expectation = RegularPlannerQuery( queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.asc("n.prop"), - horizon = RegularQueryProjection(Map(" FRESHID19" -> prop("n", "prop2")), QueryShuffle(Seq(AscSortItem(prop("n", "prop"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID19")), - horizon = RegularQueryProjection(Map("n.prop2" -> varFor(" FRESHID19"))) - )) + horizon = RegularQueryProjection(Map("n.prop2" -> prop("n", "prop2")), QueryShuffle(Seq(AscSortItem(prop("n", "prop"))(pos)))) ) result should equal(expectation) @@ -98,11 +83,9 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val expectation = RegularPlannerQuery( queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.desc("n.prop2"), - horizon = RegularQueryProjection(projections = Map(" FRESHID19" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos)), - shuffle = QueryShuffle(List(DescSortItem(Property(Variable("n")(pos), PropertyKeyName("prop2")(pos))(pos))(pos)), None, None)), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID19")), - horizon = RegularQueryProjection(Map("n.prop" -> Variable(" FRESHID19")(pos)))))) + horizon = RegularQueryProjection(projections = Map("n.prop" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos)), + shuffle = QueryShuffle(List(DescSortItem(Property(Variable("n")(pos), PropertyKeyName("prop2")(pos))(pos))(pos)), None, None)) + ) result should equal(expectation) } @@ -113,11 +96,7 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val expectation = RegularPlannerQuery( queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.desc("n.prop"), - horizon = RegularQueryProjection(Map(" FRESHID19" -> prop("n", "prop")), QueryShuffle(Seq(DescSortItem(varFor(" FRESHID19"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID19")), - horizon = RegularQueryProjection(Map("n.prop" -> varFor(" FRESHID19"))) - )) + horizon = RegularQueryProjection(Map("n.prop" -> prop("n", "prop")), QueryShuffle(Seq(DescSortItem(varFor("n.prop"))(pos)))) ) result should equal(expectation) @@ -127,13 +106,9 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val result = buildPlannerQuery("MATCH (n) RETURN n ORDER BY n.prop") val expectation = RegularPlannerQuery( - queryGraph = QueryGraph(patternNodes = Set(" n@7")), - interestingOrder = InterestingOrder.asc(" n@7.prop"), - horizon = RegularQueryProjection(Map(" FRESHID17" -> varFor(" n@7")), QueryShuffle(Seq(AscSortItem(prop(" FRESHID17", "prop"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID17")), - horizon = RegularQueryProjection(Map("n" -> varFor(" FRESHID17"))) - )) + queryGraph = QueryGraph(patternNodes = Set("n")), + interestingOrder = InterestingOrder.asc("n.prop"), + horizon = RegularQueryProjection(Map("n" -> varFor("n")), QueryShuffle(Seq(AscSortItem(prop("n", "prop"))(pos)))) ) result should equal(expectation) @@ -144,7 +119,7 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl interestingOrders(result).take(2) should be(List( InterestingOrder.ascInteresting("n.prop"), - InterestingOrder.asc(" secretN@20.prop") + InterestingOrder.asc("secretN.prop") )) } @@ -153,7 +128,7 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl interestingOrders(result).take(2) should be(List( InterestingOrder.empty, - InterestingOrder.asc(" m@35.prop") + InterestingOrder.asc("m.prop") )) } @@ -166,9 +141,9 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl interestingOrders(result).take(4) should be(List( InterestingOrder.ascInteresting("a.prop"), - InterestingOrder.asc(" a2@20.prop"), + InterestingOrder.asc("a2.prop"), InterestingOrder.ascInteresting("c.prop"), - InterestingOrder.asc(" c2@87.prop") + InterestingOrder.asc("c2.prop") )) } @@ -193,12 +168,8 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val expectation = RegularPlannerQuery( queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.asc("n.foo").desc("n.prop"), - horizon = RegularQueryProjection(Map(" FRESHID19" -> prop("n", "prop"), " FRESHID27" -> prop("n", "foo")), - QueryShuffle(Seq(AscSortItem(varFor(" FRESHID27"))(pos), DescSortItem(varFor(" FRESHID19"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID19", " FRESHID27")), - horizon = RegularQueryProjection(Map("n.prop" -> varFor(" FRESHID19"), "n.foo" -> varFor(" FRESHID27"))) - )) + horizon = RegularQueryProjection(Map("n.prop" -> prop("n", "prop"), "n.foo" -> prop("n", "foo")), + QueryShuffle(Seq(AscSortItem(varFor("n.foo"))(pos), DescSortItem(varFor("n.prop"))(pos)))) ) result should equal(expectation) @@ -208,14 +179,10 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val result = buildPlannerQuery("MATCH (n) RETURN n ORDER BY n.foo, n.prop DESC") val expectation = RegularPlannerQuery( - queryGraph = QueryGraph(patternNodes = Set(" n@7")), - interestingOrder = InterestingOrder.asc(" n@7.foo").desc(" n@7.prop"), - horizon = RegularQueryProjection(Map(" FRESHID17" -> varFor(" n@7")), - QueryShuffle(Seq(AscSortItem(prop(" FRESHID17", "foo"))(pos), DescSortItem(prop(" FRESHID17", "prop"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID17")), - horizon = RegularQueryProjection(Map("n" -> varFor(" FRESHID17"))) - )) + queryGraph = QueryGraph(patternNodes = Set("n")), + interestingOrder = InterestingOrder.asc("n.foo").desc("n.prop"), + horizon = RegularQueryProjection(Map("n" -> varFor("n")), + QueryShuffle(Seq(AscSortItem(prop("n", "foo"))(pos), DescSortItem(prop("n", "prop"))(pos)))) ) result should equal(expectation) @@ -225,14 +192,10 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val result = buildPlannerQuery("MATCH (n) RETURN n, n.prop ORDER BY n.foo, n.prop DESC") val expectation = RegularPlannerQuery( - queryGraph = QueryGraph(patternNodes = Set(" n@7")), - interestingOrder = InterestingOrder.asc(" n@7.foo").desc(" n@7.prop"), - horizon = RegularQueryProjection(Map(" FRESHID17" -> varFor(" n@7"), " FRESHID22" -> prop(" n@7", "prop")), - QueryShuffle(Seq(AscSortItem(prop(" FRESHID17", "foo"))(pos), DescSortItem(varFor(" FRESHID22"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID17", " FRESHID22")), - horizon = RegularQueryProjection(Map("n" -> varFor(" FRESHID17"), "n.prop" -> varFor(" FRESHID22"))) - )) + queryGraph = QueryGraph(patternNodes = Set("n")), + interestingOrder = InterestingOrder.asc("n.foo").desc("n.prop"), + horizon = RegularQueryProjection(Map("n" -> varFor("n"), "n.prop" -> prop("n", "prop")), + QueryShuffle(Seq(AscSortItem(prop("n", "foo"))(pos), DescSortItem(varFor("n.prop"))(pos)))) ) result should equal(expectation) @@ -248,11 +211,7 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl tail = Some(RegularPlannerQuery( queryGraph = QueryGraph(argumentIds = Set("foo")), interestingOrder = InterestingOrder.asc("foo.bar"), - horizon = RegularQueryProjection(Map(" FRESHID51" -> prop("foo", "bar")), QueryShuffle(Seq(AscSortItem(varFor(" FRESHID51"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID51")), - horizon = RegularQueryProjection(Map("foo.bar" -> varFor(" FRESHID51"))) - )) + horizon = RegularQueryProjection(Map("foo.bar" -> prop("foo", "bar")), QueryShuffle(Seq(AscSortItem(varFor("foo.bar"))(pos)))) )) ) @@ -265,15 +224,11 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val expectation = RegularPlannerQuery( queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.asc("n.prop"), - horizon = RegularQueryProjection(Map( "n" -> varFor("n"), " foo@28" -> prop("n", "prop")), QueryShuffle(Seq(AscSortItem(varFor(" foo@28"))(pos)))), + horizon = RegularQueryProjection(Map("n" -> varFor("n"), "foo" -> prop("n", "prop")), QueryShuffle(Seq(AscSortItem(varFor("foo"))(pos)))), tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" foo@28", "n")), - interestingOrder = InterestingOrder.asc(" foo@28"), - horizon = RegularQueryProjection(Map(" FRESHID57" -> prop("n", "bar"), " FRESHID62" -> varFor(" foo@28")), QueryShuffle(Seq(AscSortItem(varFor(" FRESHID62"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID57", " FRESHID62")), - horizon = RegularQueryProjection(Map("n.bar" -> varFor(" FRESHID57"), "foo" -> varFor(" FRESHID62"))) - )) + queryGraph = QueryGraph(argumentIds = Set("foo", "n")), + interestingOrder = InterestingOrder.asc("foo"), + horizon = RegularQueryProjection(Map("n.bar" -> prop("n", "bar"), "foo" -> varFor("foo")), QueryShuffle(Seq(AscSortItem(varFor("foo"))(pos)))) )) ) @@ -286,15 +241,11 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val expectation = RegularPlannerQuery( queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.asc("n.prop"), - horizon = RegularQueryProjection(Map( "n" -> varFor("n"), "foo" -> prop("n", "prop")), QueryShuffle(Seq(AscSortItem(varFor("foo"))(pos)))), + horizon = RegularQueryProjection(Map("n" -> varFor("n"), "foo" -> prop("n", "prop")), QueryShuffle(Seq(AscSortItem(varFor("foo"))(pos)))), tail = Some(RegularPlannerQuery( queryGraph = QueryGraph(argumentIds = Set("foo", "n")), interestingOrder = InterestingOrder.asc("foo"), - horizon = RegularQueryProjection(Map(" FRESHID57" -> prop("n", "bar")), QueryShuffle(Seq(AscSortItem(varFor("foo"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID57")), - horizon = RegularQueryProjection(Map("n.bar" -> varFor(" FRESHID57"))) - )) + horizon = RegularQueryProjection(Map("n.bar" -> prop("n", "bar")), QueryShuffle(Seq(AscSortItem(varFor("foo"))(pos)))) )) ) @@ -307,11 +258,7 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val expectation = RegularPlannerQuery( queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.empty, - horizon = RegularQueryProjection(Map(" FRESHID19" -> prop("n", "prop")), QueryShuffle(Seq(AscSortItem(Multiply(varFor(" FRESHID19"), SignedDecimalIntegerLiteral("2")(pos))(pos))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID19")), - horizon = RegularQueryProjection(Map("n.prop" -> varFor(" FRESHID19"))) - )) + horizon = RegularQueryProjection(Map("n.prop" -> prop("n", "prop")), QueryShuffle(Seq(AscSortItem(Multiply(varFor("n.prop"), SignedDecimalIntegerLiteral("2")(pos))(pos))(pos)))) ) result should equal(expectation) @@ -323,11 +270,7 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val expectation = RegularPlannerQuery( queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.empty, - horizon = RegularQueryProjection(Map(" FRESHID24" -> Multiply(prop("n", "prop"), SignedDecimalIntegerLiteral("2")(pos))(pos)), QueryShuffle(Seq(AscSortItem(varFor(" FRESHID24"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID24")), - horizon = RegularQueryProjection(Map("n.prop * 2" -> varFor(" FRESHID24"))) - )) + horizon = RegularQueryProjection(Map("n.prop * 2" -> Multiply(prop("n", "prop"), SignedDecimalIntegerLiteral("2")(pos))(pos)), QueryShuffle(Seq(AscSortItem(varFor("n.prop * 2"))(pos)))) ) result should equal(expectation) @@ -337,14 +280,10 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl val result = buildPlannerQuery("MATCH (n) RETURN n, n.prop ORDER BY n.foo, n.prop * 2 DESC") val expectation = RegularPlannerQuery( - queryGraph = QueryGraph(patternNodes = Set(" n@7")), + queryGraph = QueryGraph(patternNodes = Set("n")), interestingOrder = InterestingOrder.empty, - horizon = RegularQueryProjection(Map(" FRESHID17" -> varFor(" n@7"), " FRESHID22" -> prop(" n@7", "prop")), - QueryShuffle(Seq(AscSortItem(prop(" FRESHID17", "foo"))(pos), DescSortItem(Multiply(varFor(" FRESHID22"), SignedDecimalIntegerLiteral("2")(pos))(pos))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID17", " FRESHID22")), - horizon = RegularQueryProjection(Map("n" -> varFor(" FRESHID17"), "n.prop" -> varFor(" FRESHID22"))) - )) + horizon = RegularQueryProjection(Map("n" -> varFor("n"), "n.prop" -> prop("n", "prop")), + QueryShuffle(Seq(AscSortItem(prop("n", "foo"))(pos), DescSortItem(Multiply(varFor("n.prop"), SignedDecimalIntegerLiteral("2")(pos))(pos))(pos)))) ) result should equal(expectation) @@ -359,11 +298,7 @@ class RequiredOrderStatementConvertersTest extends CypherFunSuite with LogicalPl tail = Some(RegularPlannerQuery( queryGraph = QueryGraph(argumentIds = Set("d")), interestingOrder = InterestingOrder.asc("d.year"), - horizon = RegularQueryProjection(Map(" FRESHID26" -> prop("d", "year")), QueryShuffle(Seq(AscSortItem(varFor(" FRESHID26"))(pos)))), - tail = Some(RegularPlannerQuery( - queryGraph = QueryGraph(argumentIds = Set(" FRESHID26")), - horizon = RegularQueryProjection(Map("d.year" -> varFor(" FRESHID26"))) - )) + horizon = RegularQueryProjection(Map("d.year" -> prop("d", "year")), QueryShuffle(Seq(AscSortItem(varFor("d.year"))(pos)))) )) ) diff --git a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/ast/convert/plannerQuery/StatementConvertersTest.scala b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/ast/convert/plannerQuery/StatementConvertersTest.scala index 2371ecb59d27..9c8c73df83e5 100644 --- a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/ast/convert/plannerQuery/StatementConvertersTest.scala +++ b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/ast/convert/plannerQuery/StatementConvertersTest.scala @@ -19,11 +19,18 @@ */ package org.neo4j.cypher.internal.compiler.v3_5.ast.convert.plannerQuery -import org.neo4j.cypher.internal.compiler.v3_5.planner.{LogicalPlanningTestSupport, _} +import org.neo4j.cypher.internal.compiler.v3_5.planner.LogicalPlanningTestSupport +import org.neo4j.cypher.internal.compiler.v3_5.planner._ import org.neo4j.cypher.internal.ir.v3_5._ -import org.neo4j.cypher.internal.v3_5.logical.plans.{FieldSignature, ProcedureReadOnlyAccess, ProcedureSignature, QualifiedName} -import org.opencypher.v9_0.ast.{Hint, UsingIndexHint} -import org.opencypher.v9_0.expressions.SemanticDirection.{BOTH, INCOMING, OUTGOING} +import org.neo4j.cypher.internal.v3_5.logical.plans.FieldSignature +import org.neo4j.cypher.internal.v3_5.logical.plans.ProcedureReadOnlyAccess +import org.neo4j.cypher.internal.v3_5.logical.plans.ProcedureSignature +import org.neo4j.cypher.internal.v3_5.logical.plans.QualifiedName +import org.opencypher.v9_0.ast.Hint +import org.opencypher.v9_0.ast.UsingIndexHint +import org.opencypher.v9_0.expressions.SemanticDirection.BOTH +import org.opencypher.v9_0.expressions.SemanticDirection.INCOMING +import org.opencypher.v9_0.expressions.SemanticDirection.OUTGOING import org.opencypher.v9_0.expressions._ import org.opencypher.v9_0.util.helpers.StringHelper._ import org.opencypher.v9_0.util.symbols._ @@ -823,7 +830,7 @@ class StatementConvertersTest extends CypherFunSuite with LogicalPlanningTestSup val result = query.toString val expectation = - """RegularPlannerQuery(QueryGraph {Nodes: [' candidate@60', ' origin@7', 'c'], Rels: ['( origin@7)--[r1:KNOWS:WORKS_AT]--(c)', '(c)--[r2:KNOWS:WORKS_AT]--( candidate@60)'], Predicates: ['not r1 = r2', 'not (` origin@7`)-[` REL143`:KNOWS]-(` candidate@60`)', 'type(r1) = type(r2)', '` origin@7`.name IN ["Clark Kent"]']},InterestingOrder(List(Desc( FRESHID223)),List()),AggregatingQueryProjection(Map( FRESHID178 -> Property(Variable( origin@7),PropertyKeyName(name)), FRESHID204 -> Property(Variable( candidate@60),PropertyKeyName(name))),Map( FRESHID223 -> FunctionInvocation(Namespace(List()),FunctionName(SUM),false,Vector(FunctionInvocation(Namespace(List()),FunctionName(ROUND),false,Vector(Add(Property(Variable(r2),PropertyKeyName(weight)),Multiply(FunctionInvocation(Namespace(List()),FunctionName(COALESCE),false,Vector(Property(Variable(r2),PropertyKeyName(activity)), SignedDecimalIntegerLiteral(0))),SignedDecimalIntegerLiteral(2)))))))),QueryShuffle(List(DescSortItem(Variable( FRESHID223))),None,Some(SignedDecimalIntegerLiteral(10)))),Some(RegularPlannerQuery(QueryGraph {Arguments: [' FRESHID178', ' FRESHID204', ' FRESHID223']},InterestingOrder(List(),List()),RegularQueryProjection(Map(origin -> Variable( FRESHID178), candidate -> Variable( FRESHID204), boost -> Variable( FRESHID223)),QueryShuffle(List(),None,None)),None)))""" + """RegularPlannerQuery(QueryGraph {Nodes: [' candidate@60', ' origin@7', 'c'], Rels: ['( origin@7)--[r1:KNOWS:WORKS_AT]--(c)', '(c)--[r2:KNOWS:WORKS_AT]--( candidate@60)'], Predicates: ['not r1 = r2', 'not (` origin@7`)-[` REL143`:KNOWS]-(` candidate@60`)', 'type(r1) = type(r2)', '` origin@7`.name IN ["Clark Kent"]']},InterestingOrder(List(Desc(boost)),List()),AggregatingQueryProjection(Map(origin -> Property(Variable( origin@7),PropertyKeyName(name)), candidate -> Property(Variable( candidate@60),PropertyKeyName(name))),Map(boost -> FunctionInvocation(Namespace(List()),FunctionName(SUM),false,Vector(FunctionInvocation(Namespace(List()),FunctionName(ROUND),false,Vector(Add(Property(Variable(r2),PropertyKeyName(weight)),Multiply(FunctionInvocation(Namespace(List()),FunctionName(COALESCE),false,Vector(Property(Variable(r2),PropertyKeyName(activity)), SignedDecimalIntegerLiteral(0))),SignedDecimalIntegerLiteral(2)))))))),QueryShuffle(List(DescSortItem(Variable(boost))),None,Some(SignedDecimalIntegerLiteral(10)))),None)""" result should equal(expectation) } diff --git a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/IndexWithProvidedOrderPlanningIntegrationTest.scala b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/IndexWithProvidedOrderPlanningIntegrationTest.scala index 86a2a0749d63..3ccd2c2ec2b3 100644 --- a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/IndexWithProvidedOrderPlanningIntegrationTest.scala +++ b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/IndexWithProvidedOrderPlanningIntegrationTest.scala @@ -23,7 +23,8 @@ import org.neo4j.cypher.internal.compiler.v3_5.planner.LogicalPlanningTestSuppor import org.neo4j.cypher.internal.ir.v3_5.RegularPlannerQuery import org.neo4j.cypher.internal.planner.v3_5.spi.IndexOrderCapability import org.neo4j.cypher.internal.planner.v3_5.spi.IndexOrderCapability.{ASC, DESC, BOTH} -import org.neo4j.cypher.internal.v3_5.logical.plans.{Skip => SkipPlan, _} +import org.neo4j.cypher.internal.v3_5.logical.plans._ +import org.neo4j.cypher.internal.v3_5.logical.plans.{Skip => SkipPlan} import org.opencypher.v9_0.ast._ import org.opencypher.v9_0.expressions._ import org.opencypher.v9_0.util._ @@ -43,14 +44,12 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with indexOn("Awesome", "prop").providesOrder(orderCapability) } getLogicalPlanFor s"MATCH (n:Awesome) WHERE n.prop > 'foo' RETURN n.prop ORDER BY n.prop $cypherToken" - plan._2 should equal( - Projection( - Projection( - IndexSeek("n:Awesome(prop > 'foo')", indexOrder = plannedOrder), - Map(" FRESHID48" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))), - Map("n.prop" -> Variable(" FRESHID48")(pos))) - ) - } + plan._2 should equal( + Projection( + IndexSeek("n:Awesome(prop > 'foo')", indexOrder = plannedOrder), + Map("n.prop" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))) + ) + } test(s"$cypherToken-$orderCapability: Order by index backed property should plan sort if index does not provide order") { val plan = new given { @@ -58,13 +57,13 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with } getLogicalPlanFor s"MATCH (n:Awesome) WHERE n.prop > 'foo' RETURN n.prop ORDER BY n.prop $cypherToken" plan._2 should equal( + Sort( Projection( - Sort( - Projection( - IndexSeek("n:Awesome(prop > 'foo')", indexOrder = IndexOrderNone), - Map(" FRESHID48" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))), - Seq(sortOrder(" FRESHID48"))), - Map("n.prop" -> Variable(" FRESHID48")(pos))) + IndexSeek( + "n:Awesome(prop > 'foo')", indexOrder = + IndexOrderNone), + Map("n.prop" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))), + Seq(sortOrder("n.prop"))) ) } @@ -79,14 +78,13 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with plan._2 should equal( Projection( + Expand( Projection( - Expand( - Projection( - IndexSeek("n:Awesome(prop > 'foo')", indexOrder = plannedOrder), - Map("nnn" -> Variable("n")(pos))), - "nnn", SemanticDirection.INCOMING, Seq.empty, "m", "r"), - Map(" FRESHID85" -> Property(Variable("nnn")(pos), PropertyKeyName("prop")(pos))(pos))), - Map("nnn.prop" -> Variable(" FRESHID85")(pos))) + IndexSeek( + "n:Awesome(prop > 'foo')", indexOrder = plannedOrder), + Map("nnn" -> Variable("n")(pos))), + "nnn", SemanticDirection.INCOMING, Seq.empty, "m", "r"), + Map("nnn.prop" -> Property(Variable("nnn")(pos), PropertyKeyName("prop")(pos))(pos))) ) } @@ -97,14 +95,12 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with s"""MATCH (n:Awesome) WHERE n.prop > 'foo' |RETURN n AS m ORDER BY m.prop $cypherToken""".stripMargin - plan._2 should equal( - Projection( - Projection( - IndexSeek("n:Awesome(prop > 'foo')", indexOrder = plannedOrder), - Map(" FRESHID46" -> Variable("n")(pos))), - Map("m" -> Variable(" FRESHID46")(pos))) - ) - } + plan._2 should equal( + Projection( + IndexSeek("n:Awesome(prop > 'foo')", indexOrder = plannedOrder), + Map("m" -> Variable("n")(pos))) + ) + } test(s"$cypherToken-$orderCapability: Cannot order by index when ordering is on same property name, but different node") { val plan = new given { @@ -112,15 +108,14 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with } getLogicalPlanFor s"MATCH (m:Awesome), (n:Awesome) WHERE n.prop > 'foo' RETURN m.prop ORDER BY m.prop $cypherToken" plan._2 should equal( + Sort( Projection( - Sort( - Projection( - CartesianProduct( - IndexSeek("n:Awesome(prop > 'foo')", indexOrder = plannedOrder), - NodeByLabelScan("m", LabelName("Awesome")(pos), Set.empty)), - Map(" FRESHID61" -> Property(Variable("m")(pos), PropertyKeyName("prop")(pos))(pos))), - Seq(sortOrder(" FRESHID61"))), - Map("m.prop" -> Variable(" FRESHID61")(pos))) + CartesianProduct( + IndexSeek( + "n:Awesome(prop > 'foo')", indexOrder = plannedOrder), + NodeByLabelScan("m", LabelName("Awesome")(pos), Set.empty)), + Map("m.prop" -> Property(Variable("m")(pos), PropertyKeyName("prop")(pos))(pos))), + Seq(sortOrder("m.prop"))) ) } @@ -129,12 +124,11 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with indexOn("Awesome", "prop").providesOrder(orderCapability) } getLogicalPlanFor s"MATCH (n:Awesome) WHERE n.prop STARTS WITH 'foo' RETURN n.prop ORDER BY n.prop $cypherToken" - plan._2 should equal( - Projection( - Projection( - IndexSeek("n:Awesome(prop STARTS WITH 'foo')", indexOrder = plannedOrder), - Map(" FRESHID58" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))), - Map("n.prop" -> Variable(" FRESHID58")(pos))) + plan._2 should equal( + Projection( + IndexSeek( + "n:Awesome(prop STARTS WITH 'foo')", indexOrder = plannedOrder), + Map("n.prop" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))) ) } @@ -144,14 +138,12 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with indexOn("Awesome", "prop").providesOrder(orderCapability) } getLogicalPlanFor s"MATCH (n:Awesome) WHERE n.prop CONTAINS 'foo' RETURN n.prop ORDER BY n.prop $cypherToken" - plan._2 should equal( + plan._2 should equal( Projection( - Projection( - IndexSeek("n:Awesome(prop CONTAINS 'foo')", indexOrder = plannedOrder), - Map(" FRESHID55" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))), - Map("n.prop" -> Variable(" FRESHID55")(pos))) - ) - } + IndexSeek("n:Awesome(prop CONTAINS 'foo')", indexOrder = plannedOrder), + Map("n.prop" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))) + ) + } // This is supported because internally all kernel indexes which support ordering will just scan and filter to serve ends with test(s"$cypherToken-$orderCapability: Order by index backed property should plan with provided order (ends with scan)") { @@ -159,26 +151,23 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with indexOn("Awesome", "prop").providesOrder(orderCapability) } getLogicalPlanFor s"MATCH (n:Awesome) WHERE n.prop ENDS WITH 'foo' RETURN n.prop ORDER BY n.prop $cypherToken" - plan._2 should equal( + plan._2 should equal( Projection( - Projection( - IndexSeek("n:Awesome(prop ENDS WITH 'foo')", indexOrder = plannedOrder), - Map(" FRESHID56" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))), - Map("n.prop" -> Variable(" FRESHID56")(pos))) - ) - } + IndexSeek("n:Awesome(prop ENDS WITH 'foo')", indexOrder = plannedOrder), + Map("n.prop" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))) + ) + } test(s"$cypherToken-$orderCapability: Order by index backed property should plan with provided order (scan)") { val plan = new given { indexOn("Awesome", "prop").providesOrder(orderCapability) } getLogicalPlanFor s"MATCH (n:Awesome) WHERE EXISTS(n.prop) RETURN n.prop ORDER BY n.prop $cypherToken" - plan._2 should equal( - Projection( - Projection( - IndexSeek("n:Awesome(prop)", indexOrder = plannedOrder), - Map(" FRESHID48" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))), - Map("n.prop" -> Variable(" FRESHID48")(pos))) + plan._2 should equal( + Projection( + IndexSeek( + "n:Awesome(prop)", indexOrder = plannedOrder), + Map("n.prop" -> Property(Variable("n")(pos), PropertyKeyName("prop")(pos))(pos))) ) } @@ -188,19 +177,18 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with indexOn("B", "prop").providesOrder(orderCapability) } getLogicalPlanFor s"MATCH (a:A), (b:B) WHERE a.prop > 'foo' AND a.prop = b.prop RETURN a.prop ORDER BY a.prop $cypherToken" - plan._2 should equal( - Projection( - Projection( - Apply( - IndexSeek("a:A(prop > 'foo')", indexOrder = plannedOrder), - IndexSeek("b:B(prop = ???)", + plan._2 should equal( + Projection( + Apply( + IndexSeek( + "a:A(prop > 'foo')", indexOrder = plannedOrder), + IndexSeek("b:B(prop = ???)", indexOrder = plannedOrder, - paramExpr = Some(prop("a", "prop")), - labelId = 1, + paramExpr = Some(prop("a", "prop")), + labelId = 1, argumentIds = Set("a")) - ), - Map(" FRESHID69" -> Property(Variable("a")(pos), PropertyKeyName("prop")(pos))(pos))), - Map("a.prop" -> Variable(" FRESHID69")(pos))) + ), + Map("a.prop" -> Property(Variable("a")(pos), PropertyKeyName("prop")(pos))(pos))) ) } @@ -211,37 +199,32 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with // This query is very fragile in the sense that the slightest modification will result in a stupid plan } getLogicalPlanFor s"MATCH (a:A), (b:B) WHERE a.prop STARTS WITH 'foo' AND b.prop > a.prop RETURN a.prop, b.prop ORDER BY a.prop $cypherToken, b.prop $cypherToken" - plan._2 should equal( + plan._2 should equal( + Sort( Projection( - Sort( - Projection( - Apply( - IndexSeek("a:A(prop STARTS WITH 'foo')", indexOrder = plannedOrder), - IndexSeek("b:B(prop > ???)", - indexOrder = plannedOrder, - paramExpr = Some(prop("a", "prop")), - labelId = 1, - argumentIds = Set("a")) - ), - Map(" FRESHID79" -> Property(Variable("a")(pos), PropertyKeyName("prop")(pos))(pos), " FRESHID87" -> Property(Variable("b")(pos), PropertyKeyName("prop")(pos))(pos))), - Seq(sortOrder(" FRESHID79"), sortOrder(" FRESHID87"))), - Map("a.prop" -> Variable(" FRESHID79")(pos), "b.prop" -> Variable(" FRESHID87")(pos))) - ) - } + Apply( + IndexSeek("a:A(prop STARTS WITH 'foo')", indexOrder = plannedOrder), + IndexSeek("b:B(prop > ???)", + indexOrder = plannedOrder, + paramExpr = Some(prop("a", "prop")), + labelId = 1, + argumentIds = Set("a")) + ), + Map("a.prop" -> Property(Variable("a")(pos), PropertyKeyName("prop")(pos))(pos), "b.prop" -> Property(Variable("b")(pos), PropertyKeyName("prop")(pos))(pos))), + Seq(sortOrder("a.prop"), sortOrder("b.prop"))) + ) + } test(s"$cypherToken-$orderCapability: Order by index backed property in a plan with an renaming Projection") { val plan = new given { indexOn("A", "prop").providesOrder(orderCapability) } getLogicalPlanFor s"MATCH (a:A) WHERE a.prop > 'foo' WITH a.prop AS theProp, 1 AS x RETURN theProp ORDER BY theProp $cypherToken" - plan._2 should equal( - Projection( - Projection( - Projection( - IndexSeek("a:A(prop > 'foo')", indexOrder = plannedOrder), - Map(" theProp@48" -> Property(Variable("a")(pos), PropertyKeyName("prop")(pos))(pos), "x" -> SignedDecimalIntegerLiteral("1")(pos))), - Map(" FRESHID71" -> varFor(" theProp@48"))), - Map("theProp" -> Variable(" FRESHID71")(pos))) + plan._2 should equal( + Projection( + IndexSeek( + "a:A(prop > 'foo')", indexOrder = plannedOrder), + Map("theProp" -> Property(Variable("a")(pos), PropertyKeyName("prop")(pos))(pos), "x" -> SignedDecimalIntegerLiteral("1")(pos))) ) } @@ -255,14 +238,13 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with } } getLogicalPlanFor s"MATCH (a:A)-[r]->(b) WHERE a.prop > 'foo' RETURN a.prop, count(b) ORDER BY a.prop $cypherToken" - plan._2 should equal( - Projection( - Aggregation( - Expand( - IndexSeek("a:A(prop > 'foo')", indexOrder = plannedOrder), - "a", SemanticDirection.OUTGOING, Seq.empty, "b", "r"), - Map(" FRESHID51" -> prop("a", "prop")), Map(" FRESHID57" -> FunctionInvocation(Namespace(List())(pos),FunctionName("count")(pos), distinct = false,Vector(varFor("b")))(pos))), - Map("a.prop" -> Variable(" FRESHID51")(pos), "count(b)" -> Variable(" FRESHID57")(pos))) + plan._2 should equal( + Aggregation( + Expand( + IndexSeek( + "a:A(prop > 'foo')", indexOrder = plannedOrder), + "a", SemanticDirection.OUTGOING, Seq.empty, "b", "r"), + Map("a.prop" -> prop("a", "prop")), Map("count(b)" -> FunctionInvocation(Namespace(List())(pos), FunctionName("count")(pos), distinct = false, Vector(varFor("b")))(pos))) ) } @@ -276,14 +258,13 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with } } getLogicalPlanFor s"MATCH (a:A)-[r]->(b) WHERE a.prop > 'foo' RETURN DISTINCT a.prop ORDER BY a.prop $cypherToken" - plan._2 should equal( - Projection( - Distinct( - Expand( - IndexSeek("a:A(prop > 'foo')", indexOrder = plannedOrder), - "a", SemanticDirection.OUTGOING, Seq.empty, "b", "r"), - Map(" FRESHID60" -> prop("a", "prop"))), - Map("a.prop" -> Variable(" FRESHID60")(pos))) + plan._2 should equal( + Distinct( + Expand( + IndexSeek( + "a:A(prop > 'foo')", indexOrder = plannedOrder), + "a", SemanticDirection.OUTGOING, Seq.empty, "b", "r"), + Map("a.prop" -> prop("a", "prop"))) ) } @@ -297,16 +278,15 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with } } getLogicalPlanFor s"MATCH (b) OPTIONAL MATCH (a:A)-[r]->(b) USING JOIN ON b WHERE a.prop > 'foo' RETURN a.prop ORDER BY a.prop $cypherToken" - plan._2 should equal( - Projection( - Projection( - LeftOuterHashJoin(Set("b"), - AllNodesScan("b", Set.empty), - Expand( - IndexSeek("a:A(prop > 'foo')", indexOrder = plannedOrder), - "a", SemanticDirection.OUTGOING, Seq.empty, "b", "r")), - Map(" FRESHID86" -> prop("a", "prop"))), - Map("a.prop" -> Variable(" FRESHID86")(pos))) + plan._2 should equal( + Projection( + LeftOuterHashJoin(Set("b"), + AllNodesScan("b", Set.empty), + Expand( + IndexSeek( + "a:A(prop > 'foo')", indexOrder = plannedOrder), + "a", SemanticDirection.OUTGOING, Seq.empty, "b", "r")), + Map("a.prop" -> prop("a", "prop"))) ) } @@ -320,14 +300,13 @@ class IndexWithProvidedOrderPlanningIntegrationTest extends CypherFunSuite with plan._2 should equal( Projection( - Projection( - Apply( - SkipPlan( - IndexSeek("a:A(prop > 'foo')", indexOrder = plannedOrder), - SignedDecimalIntegerLiteral("0")(pos)), - AllNodesScan(" b@54", Set("a"))), - Map(" FRESHID66" -> prop("a", "prop"), " FRESHID72" -> varFor(" b@54"))), - Map("a.prop" -> Variable(" FRESHID66")(pos), "b" -> Variable(" FRESHID72")(pos))) + Apply( + SkipPlan( + IndexSeek( + "a:A(prop > 'foo')", indexOrder = plannedOrder), + SignedDecimalIntegerLiteral("0")(pos)), + AllNodesScan("b", Set("a"))), + Map("a.prop" -> prop("a", "prop"))) ) } } diff --git a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/IndexWithValuesPlanningIntegrationTest.scala b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/IndexWithValuesPlanningIntegrationTest.scala index 88626d50c1a3..168dbf441e7d 100644 --- a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/IndexWithValuesPlanningIntegrationTest.scala +++ b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/IndexWithValuesPlanningIntegrationTest.scala @@ -291,14 +291,13 @@ class IndexWithValuesPlanningIntegrationTest extends CypherFunSuite with Logical plan._2 should equal( Projection( - Projection( - Sort( - Projection( - IndexSeek("n:Awesome(prop = 'foo')", GetValue), - Map(" FRESHID61" -> FunctionInvocation(Namespace(List())(pos), FunctionName("toUpper")(pos), distinct = false, IndexedSeq(cachedNodeProperty("n", "prop")))(pos))), - Seq(Ascending(" FRESHID61"))), - Map(" FRESHID48" -> Property(Variable("n")(pos), PropertyKeyName("foo")(pos))(pos))), - Map("n.foo" -> Variable(" FRESHID48")(pos))) + Sort( + Projection( + IndexSeek( + "n:Awesome(prop = 'foo')", GetValue), + Map(" FRESHID61" -> FunctionInvocation(Namespace(List())(pos), FunctionName("toUpper")(pos), distinct = false, IndexedSeq(cachedNodeProperty("n", "prop")))(pos))), + Seq(Ascending(" FRESHID61"))), + Map("n.foo" -> Property(Variable("n")(pos), PropertyKeyName("foo")(pos))(pos))) ) } @@ -321,14 +320,13 @@ class IndexWithValuesPlanningIntegrationTest extends CypherFunSuite with Logical } getLogicalPlanFor "MATCH (n:Awesome) WHERE n.prop = 'foo' RETURN sum(n.foo), n.prop ORDER BY n.prop" plan._2 should equal( - Projection( - Sort( - Aggregation( - IndexSeek("n:Awesome(prop = 'foo')", GetValue), - Map(cachedNodePropertyProj(" FRESHID60", "n", "prop")), - Map(" FRESHID46" -> FunctionInvocation(Namespace(List())(pos), FunctionName("sum")(pos), distinct = false, IndexedSeq(Property(Variable("n")(pos), PropertyKeyName("foo")(pos))(pos)))(pos))), - Seq(Ascending(" FRESHID60"))), - Map("sum(n.foo)" -> Variable(" FRESHID46")(pos), "n.prop" -> Variable(" FRESHID60")(pos))) + Sort( + Aggregation( + IndexSeek( + "n:Awesome(prop = 'foo')", GetValue), + Map(cachedNodePropertyProj("n.prop", "n", "prop")), + Map("sum(n.foo)" -> FunctionInvocation(Namespace(List())(pos), FunctionName("sum")(pos), distinct = false, IndexedSeq(Property(Variable("n")(pos), PropertyKeyName("foo")(pos))(pos)))(pos))), + Seq(Ascending("n.prop"))) ) } diff --git a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/QueryGraphProducer.scala b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/QueryGraphProducer.scala index 86035a81a1e9..044b67f83d85 100644 --- a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/QueryGraphProducer.scala +++ b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/QueryGraphProducer.scala @@ -24,10 +24,17 @@ import org.neo4j.cypher.internal.compiler.v3_5.phases.LogicalPlanState import org.neo4j.cypher.internal.compiler.v3_5.planner._ import org.neo4j.cypher.internal.compiler.v3_5.test_helpers.ContextHelper import org.neo4j.cypher.internal.ir.v3_5.PlannerQuery -import org.neo4j.cypher.internal.planner.v3_5.spi.{IDPPlannerName, PlanningAttributes} -import org.opencypher.v9_0.ast.semantics.{SemanticCheckResult, SemanticChecker, SemanticTable} -import org.opencypher.v9_0.ast.{Query, Statement} -import org.opencypher.v9_0.frontend.phases.{CNFNormalizer, LateAstRewriting, Namespacer, rewriteEqualityToInPredicate} +import org.neo4j.cypher.internal.planner.v3_5.spi.IDPPlannerName +import org.neo4j.cypher.internal.planner.v3_5.spi.PlanningAttributes +import org.opencypher.v9_0.ast.semantics.SemanticCheckResult +import org.opencypher.v9_0.ast.semantics.SemanticChecker +import org.opencypher.v9_0.ast.semantics.SemanticTable +import org.opencypher.v9_0.ast.Query +import org.opencypher.v9_0.ast.Statement +import org.opencypher.v9_0.frontend.phases.CNFNormalizer +import org.opencypher.v9_0.frontend.phases.LateAstRewriting +import org.opencypher.v9_0.frontend.phases.Namespacer +import org.opencypher.v9_0.frontend.phases.rewriteEqualityToInPredicate import org.opencypher.v9_0.rewriting.rewriters._ import org.opencypher.v9_0.util.inSequence import org.scalatest.mock.MockitoSugar @@ -42,7 +49,7 @@ trait QueryGraphProducer extends MockitoSugar { val q = query + " RETURN 1 AS Result" val ast = parser.parse(q) val mkException = new SyntaxExceptionCreator(query, Some(pos)) - val cleanedStatement: Statement = ast.endoRewrite(inSequence(normalizeReturnClauses(mkException), normalizeWithClauses(mkException))) + val cleanedStatement: Statement = ast.endoRewrite(inSequence(normalizeWithAndReturnClauses(mkException))) val onError = SyntaxExceptionCreator.throwOnError(mkException) val SemanticCheckResult(semanticState, errors) = SemanticChecker.check(cleanedStatement) onError(errors) diff --git a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/steps/ReplacePropertyLookupsWithVariablesTest.scala b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/steps/ReplacePropertyLookupsWithVariablesTest.scala index 3f600b9b937e..342082690f82 100644 --- a/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/steps/ReplacePropertyLookupsWithVariablesTest.scala +++ b/community/cypher/cypher-planner-3.5/src/test/scala/org/neo4j/cypher/internal/compiler/v3_5/planner/logical/steps/ReplacePropertyLookupsWithVariablesTest.scala @@ -100,11 +100,4 @@ class ReplacePropertyLookupsWithVariablesTest extends CypherFunSuite with AstCon val resultState = replacePropertyLookupsWithVariables.transform(state, mock[PlannerContext]) (resultState.logicalPlan, resultState.semanticTable()) } - - // TODO remove after depending on frontend 9.0.8 - private def mapOf(keysAndValues: (String, Expression)*): MapExpression = MapExpression(keysAndValues.map { - case (k, v) => PropertyKeyName(k)(pos) -> v - })(pos) - - } diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/IndexWithProvidedOrderAcceptanceTest.scala b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/IndexWithProvidedOrderAcceptanceTest.scala index 9f9dfa3c31a6..d827840fbc11 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/IndexWithProvidedOrderAcceptanceTest.scala +++ b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/IndexWithProvidedOrderAcceptanceTest.scala @@ -230,7 +230,7 @@ class IndexWithProvidedOrderAcceptanceTest extends ExecutionEngineFunSuite with } // Only tested in ASC mode because it's hard to make compatibility check out otherwise - test("ASC: Order by index backed property in a plan with a outer join") { + test("ASC: Order by index backed property in a plan with an outer join") { // Be careful with what is created in createSomeNodes. It underwent careful cardinality tuning to get exactly the plan we want here. val result = executeWith(Configs.Interpreted - Configs.Cost3_1 - Configs.Cost2_3, """MATCH (b:B {foo:1, bar:1}) diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/IndexWithValuesAcceptanceTest.scala b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/IndexWithValuesAcceptanceTest.scala index 423cb10cbea4..0d40fe4a90c9 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/IndexWithValuesAcceptanceTest.scala +++ b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/IndexWithValuesAcceptanceTest.scala @@ -157,13 +157,11 @@ class IndexWithValuesAcceptanceTest extends ExecutionEngineFunSuite with QuerySt val result = executeWith(Configs.Interpreted, "PROFILE MATCH (n:Awesome) WHERE n.prop1 > 41 RETURN n.prop2 ORDER BY n.prop1", executeBefore = createSomeNodes) result.executionPlanDescription() should includeSomewhere.aPlan("Projection") - .containingArgument("{n.prop2 : `anon[46]`}") - .onTopOf(aPlan("Projection") - .containingArgument("{ : n.prop2}") - // just for n.prop2, not for n.prop1 - .withDBHits(6) - .onTopOf(aPlan("NodeIndexSeekByRange") - .withExactVariables("n", "cached[n.prop1]"))) + .containingArgument("{n.prop2 : n.prop2}") + // just for n.prop2, not for n.prop1 + .withDBHits(6) + .onTopOf(aPlan("NodeIndexSeekByRange") + .withExactVariables("n", "cached[n.prop1]")) result.toList should equal(List( Map("n.prop2" -> 3), Map("n.prop2" -> 3), Map("n.prop2" -> 1), Map("n.prop2" -> 1), diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/OrderAcceptanceTest.scala b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/OrderAcceptanceTest.scala index 2416c69f480f..603842bba04e 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/OrderAcceptanceTest.scala +++ b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/OrderAcceptanceTest.scala @@ -195,7 +195,7 @@ class OrderAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsTe result.executionPlanDescription() should includeSomewhere .aPlan("Projection") - .containingArgument("{ : a.name}") + .containingArgument("{a.name : a.name}") .onTopOf(aPlan("Sort") .withOrder(ProvidedOrder.asc("anon[49]")) .onTopOf(aPlan("Projection") @@ -204,7 +204,6 @@ class OrderAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsTe )) } - // Does not regress but has some awkward Projections we could get rid of test("ORDER BY previously unprojected column in RETURN and return that column") { val result = executeWith(Configs.All, """ @@ -215,15 +214,14 @@ class OrderAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsTe result.executionPlanDescription() should includeSomewhere .aPlan("Projection") - .containingArgument("{ : a.name}") + .containingArgument("{a.name : a.name}") .onTopOf(aPlan("Sort") .onTopOf(aPlan("Projection") .containingVariables("a") - .containingArgument("{ : a.age}") + .containingArgument("{a.age : a.age}") )) } - // Does not regress but has some awkward Projections we could get rid of test("ORDER BY previously unprojected column in RETURN and project and return that column") { val result = executeWith(Configs.All, """ @@ -234,11 +232,11 @@ class OrderAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsTe result.executionPlanDescription() should includeSomewhere .aPlan("Projection") - .containingArgument("{ : a.name}") + .containingArgument("{a.name : a.name}") .onTopOf(aPlan("Sort") .onTopOf(aPlan("Projection") .containingVariables("a") - .containingArgument("{ : a.age}") + .containingArgument("{age : a.age}") )) } @@ -270,7 +268,7 @@ class OrderAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsTe .aPlan("Sort") .onTopOf(aPlan("Projection") .containingVariables("a") - .containingArgument("{ : a.age}") + .containingArgument("{a.age : a.age}") ) } @@ -286,7 +284,7 @@ class OrderAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsTe .aPlan("Sort") .onTopOf(aPlan("Projection") .containingVariables("a") - .containingArgument("{ : a.age}") + .containingArgument("{age : a.age}") ) } diff --git a/pom.xml b/pom.xml index 321ef84b0eb6..a8bde9a7fdaf 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ headers/AGPL-3-header.txt - 9.0.7 + 9.0.8 3.4.2 2.11.12 2.11