Skip to content

Commit

Permalink
Change name of Cypher version
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusmelke committed May 8, 2018
1 parent 047b6b3 commit eb10f6b
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 104 deletions.
Expand Up @@ -25,7 +25,7 @@ case object CypherVersion extends CypherOptionCompanion[CypherVersion] {
case object v2_3 extends CypherVersion("2.3")
case object v3_1 extends CypherVersion("3.1")
case object v3_3 extends CypherVersion("3.3")
case object v3_5 extends CypherVersion("3.4")
case object v3_5 extends CypherVersion("3.5")

val default = v3_5
val all: Set[CypherVersion] = Set(v2_3, v3_1, v3_3, v3_5)
Expand Down
Expand Up @@ -27,7 +27,7 @@ import org.neo4j.cypher.internal.frontend.v3_5.phases.CompilationPhaseTracer
import org.neo4j.cypher.internal.util.v3_5.InputPosition
import org.neo4j.cypher.{InvalidArgumentException, SyntaxException, exceptionHandler, _}
import org.neo4j.graphdb.factory.GraphDatabaseSettings
import org.neo4j.graphdb.impl.notification.NotificationCode.{CREATE_UNIQUE_UNAVAILABLE_FALLBACK, RULE_PLANNER_UNAVAILABLE_FALLBACK, RUNTIME_UNSUPPORTED, START_DEPRECATED, START_UNAVAILABLE_FALLBACK}
import org.neo4j.graphdb.impl.notification.NotificationCode._
import org.neo4j.graphdb.impl.notification.NotificationDetail.Factory.message
import org.neo4j.kernel.GraphDatabaseQueryService
import org.neo4j.kernel.configuration.Config
Expand Down Expand Up @@ -169,7 +169,7 @@ class CompilerEngineDelegator(graph: GraphDatabaseQueryService,
produceParsedQuery(preParsedQuery, tracer, preParsingNotifications)

parserQuery.onError {
// if there is a create unique in the cypher 3.4 query try to fallback to 3.1
// if there is a create unique in the cypher 3.5 query try to fallback to 3.1
case ex: util.v3_5.SyntaxException if ex.getMessage.startsWith("CREATE UNIQUE") =>
preParsingNotifications = preParsingNotifications +
createUniqueNotification(ex, preParsedQuery)
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -20,9 +20,9 @@
package org.neo4j.cypher

import org.neo4j.cypher.internal.ExecutionEngine
import org.neo4j.cypher.internal.util.v3_5.test_helpers.CypherFunSuite
import org.neo4j.cypher.internal.javacompat.GraphDatabaseCypherService
import org.neo4j.cypher.internal.planner.v3_5.spi.CostBasedPlannerName
import org.neo4j.cypher.internal.util.v3_5.test_helpers.CypherFunSuite
import org.neo4j.graphdb.factory.GraphDatabaseSettings
import org.neo4j.graphdb.{ExecutionPlanDescription, GraphDatabaseService, Result}
import org.neo4j.test.TestGraphDatabaseFactory
Expand Down Expand Up @@ -76,11 +76,11 @@ class ExecutionEngineIT extends CypherFunSuite with GraphIcing {
plan2.getArguments.get("planner-impl") should equal(CostBasedPlannerName.default.name)
}

test("by default when using cypher 3.4 some queries should default to COST") {
test("by default when using cypher 3.5 some queries should default to COST") {
//given
db = new TestGraphDatabaseFactory()
.newImpermanentDatabaseBuilder()
.setConfig(GraphDatabaseSettings.cypher_parser_version, "3.4").newGraphDatabase()
.setConfig(GraphDatabaseSettings.cypher_parser_version, "3.5").newGraphDatabase()
val service = new GraphDatabaseCypherService(db)

//when
Expand Down Expand Up @@ -158,12 +158,12 @@ class ExecutionEngineIT extends CypherFunSuite with GraphIcing {
plan.getArguments.get("planner-impl") should equal("IDP")
}

test("should be able to force COST as default when using cypher 3.4") {
test("should be able to force COST as default when using cypher 3.5") {
//given
db = new TestGraphDatabaseFactory()
.newImpermanentDatabaseBuilder()
.setConfig(GraphDatabaseSettings.cypher_planner, "COST")
.setConfig(GraphDatabaseSettings.cypher_parser_version, "3.4").newGraphDatabase()
.setConfig(GraphDatabaseSettings.cypher_parser_version, "3.5").newGraphDatabase()
val service = new GraphDatabaseCypherService(db)

//when
Expand Down
Expand Up @@ -72,9 +72,9 @@ class QueryCachingTest extends CypherFunSuite with GraphDatabaseTestSupport with
val actual = cacheListener.trace.map(str => str.replaceAll("\\s+", " "))
val expected = List(
s"cacheFlushDetected",
s"cacheMiss: CYPHER 3.4 $query",
s"cacheHit: CYPHER 3.4 $query",
s"cacheHit: CYPHER 3.4 $query")
s"cacheMiss: CYPHER 3.5 $query",
s"cacheHit: CYPHER 3.5 $query",
s"cacheHit: CYPHER 3.5 $query")

actual should equal(expected)
}
Expand Down
Expand Up @@ -23,7 +23,7 @@ import org.neo4j.cypher.internal.frontend.v3_5.PlannerName

sealed abstract class CostBasedPlannerName extends PlannerName {
val toTextOutput = "COST"
val version = "3.4"
val version = "3.5"
}

object CostBasedPlannerName {
Expand Down Expand Up @@ -52,7 +52,7 @@ case object DPPlannerName extends CostBasedPlannerName {
*/
case object ProcedurePlannerName extends PlannerName {
val name = "PROCEDURE"
val version = "3.4"
val version = "3.5"

override def toTextOutput: String = "PROCEDURE"
}
Expand Down
Expand Up @@ -23,7 +23,7 @@ import org.neo4j.cypher.internal.frontend.v3_5.PlannerName
import org.neo4j.cypher.internal.planner.v3_5.spi.PlanningAttributes.Cardinalities
import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments._
import org.neo4j.cypher.internal.util.v3_5.InternalException
import org.neo4j.cypher.internal.v3_5.expressions.{FunctionInvocation, FunctionName, LabelToken, MapExpression, Namespace, PropertyKeyName, PropertyKeyToken, Expression => ASTExpression}
import org.neo4j.cypher.internal.v3_5.expressions.{FunctionInvocation, FunctionName, LabelToken, MapExpression, Namespace, PropertyKeyToken, Expression => ASTExpression}
import org.neo4j.cypher.internal.v3_5.functions.Point
import org.neo4j.cypher.internal.v3_5.logical.plans
import org.neo4j.cypher.internal.v3_5.logical.plans._
Expand All @@ -36,7 +36,7 @@ object LogicalPlan2PlanDescription extends ((LogicalPlan, PlannerName, Boolean,
cardinalities: Cardinalities): InternalPlanDescription = {
new LogicalPlan2PlanDescription(readOnly, cardinalities).create(input)
.addArgument(Version("CYPHER "+plannerName.version))
.addArgument(RuntimeVersion("3.4"))
.addArgument(RuntimeVersion("3.5"))
.addArgument(Planner(plannerName.toTextOutput))
.addArgument(PlannerImpl(plannerName.name))
.addArgument(PlannerVersion(plannerName.version))
Expand Down
Expand Up @@ -31,6 +31,10 @@ import org.scalatest.prop.TableDrivenPropertyChecks

class LogicalPlan2PlanDescriptionTest extends CypherFunSuite with TableDrivenPropertyChecks {

private val CYPHER_VERSION = Version("CYPHER 3.5")
private val RUNTIME_VERSION = RuntimeVersion("3.5")
private val PLANNER_VERSION = PlannerVersion("3.5")

test("tests") {
implicit val idGen: IdGen = new SequentialIdGen()
val readOnly = true
Expand All @@ -53,33 +57,58 @@ class LogicalPlan2PlanDescriptionTest extends CypherFunSuite with TableDrivenPro
"logical plan" -> "expected plan description",

attach(AllNodesScan("a", Set.empty), 1.0) ->
PlanDescriptionImpl(id, "AllNodesScan", NoChildren, Seq(EstimatedRows(1), Version("CYPHER 3.4"), RuntimeVersion("3.4"), Planner("COST"), PlannerImpl("IDP"), PlannerVersion("3.4")), Set("a"))
PlanDescriptionImpl(id, "AllNodesScan", NoChildren,
Seq(EstimatedRows(1), CYPHER_VERSION, RUNTIME_VERSION, Planner("COST"), PlannerImpl("IDP"),
PLANNER_VERSION), Set("a"))

, attach(AllNodesScan("b", Set.empty), 42.0) ->
PlanDescriptionImpl(id, "AllNodesScan", NoChildren, Seq(EstimatedRows(42), Version("CYPHER 3.4"), RuntimeVersion("3.4"), Planner("COST"), PlannerImpl("IDP"), PlannerVersion("3.4")), Set("b"))
PlanDescriptionImpl(id, "AllNodesScan", NoChildren,
Seq(EstimatedRows(42), CYPHER_VERSION, RUNTIME_VERSION, Planner("COST"), PlannerImpl("IDP"),
PLANNER_VERSION), Set("b"))

, attach(NodeByLabelScan("node", AstLabelName("X")(DummyPosition(0)), Set.empty), 33.0) ->
PlanDescriptionImpl(id, "NodeByLabelScan", NoChildren, Seq(LabelName("X"), EstimatedRows(33), Version("CYPHER 3.4"), RuntimeVersion("3.4"), Planner("COST"), PlannerImpl("IDP"), PlannerVersion("3.4")), Set("node"))

, attach(NodeByIdSeek("node", ManySeekableArgs(ListLiteral(Seq(SignedDecimalIntegerLiteral("1")(pos)))(pos)), Set.empty), 333.0) ->
PlanDescriptionImpl(id, "NodeByIdSeek", NoChildren, Seq(EstimatedRows(333), Version("CYPHER 3.4"), RuntimeVersion("3.4"), Planner("COST"), PlannerImpl("IDP"), PlannerVersion("3.4")), Set("node"))

, attach(NodeIndexSeek("x", LabelToken("Label", LabelId(0)), Seq(PropertyKeyToken("Prop", PropertyKeyId(0))), ManyQueryExpression(ListLiteral(Seq(StringLiteral("Andres")(pos)))(pos)), Set.empty), 23.0) ->
PlanDescriptionImpl(id, "NodeIndexSeek", NoChildren, Seq(Index("Label", Seq("Prop")), EstimatedRows(23), Version("CYPHER 3.4"), RuntimeVersion("3.4"), Planner("COST"), PlannerImpl("IDP"), PlannerVersion("3.4")), Set("x"))

, attach(NodeUniqueIndexSeek("x", LabelToken("Lebal", LabelId(0)), Seq(PropertyKeyToken("Porp", PropertyKeyId(0))), ManyQueryExpression(ListLiteral(Seq(StringLiteral("Andres")(pos)))(pos)), Set.empty), 95.0) ->
PlanDescriptionImpl(id, "NodeUniqueIndexSeek", NoChildren, Seq(Index("Lebal", Seq("Porp")), EstimatedRows(95), Version("CYPHER 3.4"), RuntimeVersion("3.4"), Planner("COST"), PlannerImpl("IDP"), PlannerVersion("3.4")), Set("x"))
PlanDescriptionImpl(id, "NodeByLabelScan", NoChildren,
Seq(LabelName("X"), EstimatedRows(33), CYPHER_VERSION, RUNTIME_VERSION, Planner("COST"),
PlannerImpl("IDP"), PLANNER_VERSION), Set("node"))

, attach(
NodeByIdSeek("node", ManySeekableArgs(ListLiteral(Seq(SignedDecimalIntegerLiteral("1")(pos)))(pos)), Set.empty),
333.0) ->
PlanDescriptionImpl(id, "NodeByIdSeek", NoChildren,
Seq(EstimatedRows(333), CYPHER_VERSION, RUNTIME_VERSION, Planner("COST"),
PlannerImpl("IDP"), PLANNER_VERSION), Set("node"))

, attach(NodeIndexSeek("x", LabelToken("Label", LabelId(0)), Seq(PropertyKeyToken("Prop", PropertyKeyId(0))),
ManyQueryExpression(ListLiteral(Seq(StringLiteral("Andres")(pos)))(pos)), Set.empty),
23.0) ->
PlanDescriptionImpl(id, "NodeIndexSeek", NoChildren,
Seq(Index("Label", Seq("Prop")), EstimatedRows(23), CYPHER_VERSION, RUNTIME_VERSION,
Planner("COST"), PlannerImpl("IDP"), PLANNER_VERSION), Set("x"))

, attach(
NodeUniqueIndexSeek("x", LabelToken("Lebal", LabelId(0)), Seq(PropertyKeyToken("Porp", PropertyKeyId(0))),
ManyQueryExpression(ListLiteral(Seq(StringLiteral("Andres")(pos)))(pos)), Set.empty),
95.0) ->
PlanDescriptionImpl(id, "NodeUniqueIndexSeek", NoChildren,
Seq(Index("Lebal", Seq("Porp")), EstimatedRows(95), CYPHER_VERSION, RUNTIME_VERSION,
Planner("COST"), PlannerImpl("IDP"), PLANNER_VERSION), Set("x"))

, attach(Expand(lhsLP, "a", SemanticDirection.OUTGOING, Seq.empty, "b", "r1", ExpandAll), 95.0) ->
PlanDescriptionImpl(id, "Expand(All)", SingleChild(lhsPD), Seq(ExpandExpression("a", "r1", Seq.empty, "b", SemanticDirection.OUTGOING, 1, Some(1)),
EstimatedRows(95), Version("CYPHER 3.4"), RuntimeVersion("3.4"), Planner("COST"), PlannerImpl("IDP"), PlannerVersion("3.4")), Set("a", "r1", "b"))
PlanDescriptionImpl(id, "Expand(All)", SingleChild(lhsPD),
Seq(ExpandExpression("a", "r1", Seq.empty, "b", SemanticDirection.OUTGOING, 1, Some(1)),
EstimatedRows(95), CYPHER_VERSION, RUNTIME_VERSION, Planner("COST"), PlannerImpl("IDP"),
PLANNER_VERSION), Set("a", "r1", "b"))

, attach(Expand(lhsLP, "a", SemanticDirection.OUTGOING, Seq.empty, "a", "r1", ExpandInto), 113.0) ->
PlanDescriptionImpl(id, "Expand(Into)", SingleChild(lhsPD), Seq(ExpandExpression("a", "r1", Seq.empty, "a", SemanticDirection.OUTGOING, 1, Some(1)),
EstimatedRows(113), Version("CYPHER 3.4"), RuntimeVersion("3.4"), Planner("COST"), PlannerImpl("IDP"), PlannerVersion("3.4")), Set("a", "r1"))
PlanDescriptionImpl(id, "Expand(Into)", SingleChild(lhsPD),
Seq(ExpandExpression("a", "r1", Seq.empty, "a", SemanticDirection.OUTGOING, 1, Some(1)),
EstimatedRows(113), CYPHER_VERSION, RUNTIME_VERSION, Planner("COST"),
PlannerImpl("IDP"), PLANNER_VERSION), Set("a", "r1"))

, attach(NodeHashJoin(Set("a"), lhsLP, rhsLP), 2345.0) ->
PlanDescriptionImpl(id, "NodeHashJoin", TwoChildren(lhsPD, rhsPD), Seq(KeyNames(Seq("a")), EstimatedRows(2345), Version("CYPHER 3.4"), RuntimeVersion("3.4"), Planner("COST"), PlannerImpl("IDP"), PlannerVersion("3.4")), Set("a", "b"))
PlanDescriptionImpl(id, "NodeHashJoin", TwoChildren(lhsPD, rhsPD),
Seq(KeyNames(Seq("a")), EstimatedRows(2345), CYPHER_VERSION, RUNTIME_VERSION,
Planner("COST"), PlannerImpl("IDP"), PLANNER_VERSION), Set("a", "b"))
)

forAll(modeCombinations) {
Expand Down
Expand Up @@ -159,7 +159,7 @@ public class GraphDatabaseSettings implements LoadableConfig
@Description( "Set this to specify the default parser (language version)." )
public static final Setting<String> cypher_parser_version = setting(
"cypher.default_language_version",
options( "2.3", "3.1", "3.3","3.4", DEFAULT ), DEFAULT );
options( "2.3", "3.1", "3.3","3.5", DEFAULT ), DEFAULT );

@Description( "Set this to specify the default planner for the default language version." )
public static final Setting<String> cypher_planner = setting(
Expand Down
Expand Up @@ -345,14 +345,14 @@ object CypherComparisonSupport {

object V3_3 extends Version("3.3") {
// 3.3 has 3.4 runtime
override val acceptedRuntimeVersionNames = Set("3.4")
override val acceptedRuntimeVersionNames = Set("3.5")
}

object v3_5 extends Version("3.4")
object v3_5 extends Version("3.5")

object Default extends Version("") {
override val acceptedRuntimeVersionNames = Set("2.3", "3.1", "3.3", "3.4")
override val acceptedPlannerVersionNames = Set("2.3", "3.1", "3.3", "3.4")
override val acceptedRuntimeVersionNames = Set("2.3", "3.1", "3.3", "3.5")
override val acceptedPlannerVersionNames = Set("2.3", "3.1", "3.3", "3.5")
}

}
Expand Down
Expand Up @@ -52,8 +52,8 @@ class HelpfulErrorMessagesTest extends ExecutionEngineFunSuite with CypherCompar
"The given query is not currently supported in the selected cost-based planner"))
}

test("should provide sensible error message for 3.4 rule planner") {
intercept[Exception](graph.execute("CYPHER 3.4 planner=rule RETURN 1")).getMessage should be("Unsupported PLANNER - VERSION combination: rule - 3.4")
test("should provide sensible error message for 3.5 rule planner") {
intercept[Exception](graph.execute("CYPHER 3.5 planner=rule RETURN 1")).getMessage should be("Unsupported PLANNER - VERSION combination: rule - 3.5")
}

test("should not fail for specifying rule planner if no version specified") {
Expand Down
Expand Up @@ -155,7 +155,7 @@ class MergeNodeCompatibilityAcceptanceTest extends ExecutionEngineFunSuite with
}

def expectMergeConstraintConflictException(query: String, messages: Seq[String]): Unit = {
Seq("2.3", "3.1", "3.4").foreach { version =>
Seq("2.3", "3.1", "3.5").foreach { version =>
val exception = intercept[MergeConstraintConflictException] {
innerExecuteDeprecated(s"CYPHER $version $query", Map.empty)
}
Expand Down

0 comments on commit eb10f6b

Please sign in to comment.