Skip to content

Commit

Permalink
Update frontend dependency
Browse files Browse the repository at this point in the history
Adapt test expectations after removed rewriter
  • Loading branch information
sherfert authored and pontusmelke committed Oct 9, 2018
1 parent d61b8fd commit 5273e39
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 289 deletions.

Large diffs are not rendered by default.

Expand Up @@ -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._
Expand Down Expand Up @@ -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)
}
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -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)))
)
}

Expand All @@ -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")))
)
}

Expand Down
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Expand Up @@ -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)


}
Expand Up @@ -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})
Expand Down
Expand Up @@ -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),
Expand Down
Expand Up @@ -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")
Expand All @@ -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,
"""
Expand 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,
"""
Expand 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}")
))
}

Expand Down Expand Up @@ -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}")
)
}

Expand All @@ -286,7 +284,7 @@ class OrderAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsTe
.aPlan("Sort")
.onTopOf(aPlan("Projection")
.containingVariables("a")
.containingArgument("{ : a.age}")
.containingArgument("{age : a.age}")
)
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -87,7 +87,7 @@

<license-text.header>headers/AGPL-3-header.txt</license-text.header>

<openCypher.frontend.version>9.0.7</openCypher.frontend.version>
<openCypher.frontend.version>9.0.8</openCypher.frontend.version>
<scala-maven-plugin.version>3.4.2</scala-maven-plugin.version>
<scala.version>2.11.12</scala.version>
<scala.binary.version>2.11</scala.binary.version>
Expand Down

0 comments on commit 5273e39

Please sign in to comment.