From 308a55bccf7f1846c8d07c99947d6f87c06013aa Mon Sep 17 00:00:00 2001 From: Pontus Melke Date: Mon, 5 Sep 2016 09:59:25 +0200 Subject: [PATCH] Changed Function -> UserFunction --- .../ProcedureCallAcceptanceTest.scala | 10 +-- .../compiler/v3_1/CypherCompiler.scala | 4 +- .../compiler/v3_1/ast/QueryTagger.scala | 6 +- .../v3_1/ast/ResolvedFunctionInvocation.scala | 4 +- .../normalizedEqualsArguments.scala | 9 ++- .../commands/ExpressionConverters.scala | 4 +- .../rewriters/normalizeArgumentOrder.scala | 4 +- .../replaceAliasedFunctionInvocations.scala | 2 +- .../rewriteEqualityToInCollection.scala | 2 +- .../ir/expressions/ExpressionConverter.scala | 2 +- .../ir/functions/functionConverter.scala | 2 +- .../expressions/FunctionInvocation.scala | 4 +- .../helpers/simpleExpressionEvaluator.scala | 6 +- .../logical/idp/expandSolverStep.scala | 10 +-- .../planner/logical/plans/NonSargable.scala | 2 +- .../v3_1/planner/logical/plans/Sargable.scala | 14 ++-- .../steps/PatternExpressionSolver.scala | 5 +- .../logical/steps/countStorePlanner.scala | 6 +- .../logical/steps/getDegreeRewriter.scala | 6 +- .../logical/steps/idSeekLeafPlanner.scala | 2 +- .../logical/steps/planShortestPaths.scala | 6 +- .../compiler/v3_1/rewriteProcedureCalls.scala | 6 +- .../compiler/v3_1/spi/PlanContext.scala | 2 +- .../v3_1/spi/ProcedureSignature.scala | 14 ++-- .../v3_1/RewriteProcedureCallsTest.scala | 2 +- .../AggregationsAreIsolatedTest.scala | 2 +- .../NormalizedEqualsArgumentsTest.scala | 4 +- .../StatementConvertersTest.scala | 16 ++--- .../NormalizeArgumentOrderTest.scala | 4 +- .../ast/rewriters/ProjectNamedPathsTest.scala | 4 +- ...eplaceAliasedFunctionInvocationsTest.scala | 6 +- .../simpleExpressionEvaluatorTest.scala | 6 +- .../planner/LogicalPlanningTestSupport.scala | 2 +- .../planner/LogicalPlanningTestSupport2.scala | 2 +- .../logical/LeafPlanningIntegrationTest.scala | 4 +- ...athProjectionPlanningIntegrationTest.scala | 6 +- .../logical/idp/IDPQueryGraphSolverTest.scala | 2 +- .../logical/plans/IdSeekLeafPlannerTest.scala | 22 +++---- .../plans/IndexScanLeafPlannerTest.scala | 5 +- .../planner/logical/plans/SargableTest.scala | 8 +-- .../logical/steps/AggregationTest.scala | 4 +- .../logical/steps/countStorePlannerTest.scala | 6 +- .../ExceptionTranslatingPlanContext.scala | 2 +- .../v3_1/TransactionBoundPlanContext.scala | 4 +- .../cypher/GraphDatabaseTestSupport.scala | 12 ++-- .../internal/frontend/v3_1/ast/Clause.scala | 4 +- .../internal/frontend/v3_1/ast/Function.scala | 24 +++---- .../frontend/v3_1/ast/IsAggregate.scala | 4 +- ...ion.scala => UserFunctionInvocation.scala} | 24 +++---- .../v3_1/ast/functions/Coalesce.scala | 2 +- .../frontend/v3_1/ast/functions/Collect.scala | 2 +- .../frontend/v3_1/ast/functions/Exists.scala | 2 +- .../frontend/v3_1/ast/functions/Has.scala | 5 +- .../frontend/v3_1/ast/functions/Head.scala | 2 +- .../frontend/v3_1/ast/functions/Labels.scala | 6 +- .../frontend/v3_1/ast/functions/Last.scala | 2 +- .../frontend/v3_1/ast/functions/Length.scala | 8 +-- .../frontend/v3_1/ast/functions/Max.scala | 6 +- .../frontend/v3_1/ast/functions/Min.scala | 6 +- .../v3_1/ast/functions/PercentileCont.scala | 4 +- .../v3_1/ast/functions/PercentileDisc.scala | 5 +- .../frontend/v3_1/ast/functions/Point.scala | 2 +- .../frontend/v3_1/ast/functions/Reduce.scala | 4 +- .../frontend/v3_1/ast/functions/Tail.scala | 2 +- .../v3_1/ast/functions/ToBoolean.scala | 6 +- .../frontend/v3_1/ast/functions/ToFloat.scala | 8 +-- .../v3_1/ast/functions/ToInteger.scala | 6 +- .../v3_1/ast/functions/ToString.scala | 6 +- .../frontend/v3_1/ast/functions/Type.scala | 6 +- .../ast/functions/UnresolvedFunction.scala | 4 +- .../frontend/v3_1/parser/Expressions.scala | 4 +- .../frontend/v3_1/ast/ExpressionTest.scala | 6 +- .../frontend/v3_1/ast/IsAggregateTest.scala | 6 +- .../v3_1/ast/functions/FunctionTestBase.scala | 4 +- .../parser/FunctionInvocationParserTest.scala | 10 +-- .../java/org/neo4j/kernel/api/KernelAPI.java | 4 +- .../org/neo4j/kernel/api/ReadOperations.java | 4 +- ...unction.java => CallableUserFunction.java} | 12 ++-- ...nature.java => UserFunctionSignature.java} | 10 +-- .../org/neo4j/kernel/impl/api/Kernel.java | 4 +- .../kernel/impl/api/OperationsFacade.java | 4 +- .../kernel/impl/proc/ProcedureJarLoader.java | 10 +-- .../kernel/impl/proc/ProcedureRegistry.java | 22 +++---- .../neo4j/kernel/impl/proc/Procedures.java | 16 ++--- .../proc/ReflectiveProcedureCompiler.java | 38 +++++------ .../{Function.java => UserFunction.java} | 2 +- .../ConstraintIndexCreatorTest.java | 4 +- .../proc/MethodSignatureCompilerTest.java | 6 +- ...t.java => ReflectiveUserFunctionTest.java} | 66 +++++++++---------- ...st.java => UserFunctionSignatureTest.java} | 8 +-- ...ctionsTest.java => UserFunctionsTest.java} | 23 +++---- .../{FunctionIT.java => UserFunctionIT.java} | 50 +++++++------- 92 files changed, 355 insertions(+), 363 deletions(-) rename community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/{FunctionInvocation.scala => UserFunctionInvocation.scala} (64%) rename community/kernel/src/main/java/org/neo4j/kernel/api/proc/{CallableFunction.java => CallableUserFunction.java} (79%) rename community/kernel/src/main/java/org/neo4j/kernel/api/proc/{FunctionSignature.java => UserFunctionSignature.java} (94%) rename community/kernel/src/main/java/org/neo4j/procedure/{Function.java => UserFunction.java} (99%) rename community/kernel/src/test/java/org/neo4j/kernel/impl/proc/{ReflectiveFunctionTest.java => ReflectiveUserFunctionTest.java} (86%) rename community/kernel/src/test/java/org/neo4j/kernel/impl/proc/{FunctionSignatureTest.java => UserFunctionSignatureTest.java} (89%) rename community/kernel/src/test/java/org/neo4j/kernel/impl/proc/{FunctionsTest.java => UserFunctionsTest.java} (87%) rename integrationtests/src/test/java/org/neo4j/procedure/{FunctionIT.java => UserFunctionIT.java} (97%) diff --git a/community/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/ProcedureCallAcceptanceTest.scala b/community/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/ProcedureCallAcceptanceTest.scala index e952e6db16d8..9513d59e67dd 100644 --- a/community/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/ProcedureCallAcceptanceTest.scala +++ b/community/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/ProcedureCallAcceptanceTest.scala @@ -22,10 +22,10 @@ package org.neo4j.internal.cypher.acceptance import org.neo4j.collection.RawIterator import org.neo4j.cypher._ import org.neo4j.kernel.api.exceptions.ProcedureException -import org.neo4j.kernel.api.proc.CallableFunction.BasicFunction import org.neo4j.kernel.api.proc.CallableProcedure.BasicProcedure -import org.neo4j.kernel.api.proc.FunctionSignature._ -import org.neo4j.kernel.api.proc.ProcedureSignature._ +import org.neo4j.kernel.api.proc.CallableUserFunction.BasicUserFunction +import org.neo4j.kernel.api.proc.ProcedureSignature.procedureSignature +import org.neo4j.kernel.api.proc.UserFunctionSignature.functionSignature import org.neo4j.kernel.api.proc.{Context, Neo4jTypes, ProcedureSignature} abstract class ProcedureCallAcceptanceTest extends ExecutionEngineFunSuite { @@ -57,11 +57,11 @@ abstract class ProcedureCallAcceptanceTest extends ExecutionEngineFunSuite { } protected def registerUserFunction(value: AnyRef) = - registerFunction("my.first.value") { builder => + registerUserDefinedFunction("my.first.value") { builder => val builder = functionSignature(Array("my", "first"), "value") builder.out(Neo4jTypes.NTAny) - new BasicFunction(builder.build) { + new BasicUserFunction(builder.build) { override def apply(ctx: Context, input: Array[AnyRef]): AnyRef = value } } diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/CypherCompiler.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/CypherCompiler.scala index 49e59b2ac44b..115481971177 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/CypherCompiler.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/CypherCompiler.scala @@ -34,7 +34,7 @@ import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.plans.rewriter.Lo import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.{CachedMetricsFactory, DefaultQueryPlanner, SimpleMetricsFactory} import org.neo4j.cypher.internal.compiler.v3_1.spi.{PlanContext, ProcedureSignature} import org.neo4j.cypher.internal.compiler.v3_1.tracing.rewriters.RewriterStepSequencer -import org.neo4j.cypher.internal.frontend.v3_1.ast.{FunctionInvocation, FunctionName, Statement} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{FunctionName, Statement, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.notification.{DeprecatedFunctionNotification, DeprecatedProcedureNotification, InternalNotification} import org.neo4j.cypher.internal.frontend.v3_1.parser.CypherParser import org.neo4j.cypher.internal.frontend.v3_1.{InputPosition, SemanticTable, inSequence} @@ -230,7 +230,7 @@ case class CypherCompiler(parser: CypherParser, private def syntaxDeprecationNotifications(statement: Statement): Set[InternalNotification] = statement.treeFold(Set.empty[InternalNotification]) { - case f@FunctionInvocation(_, FunctionName(name), _, _) if aliases.get(name).nonEmpty => + case f@UserFunctionInvocation(_, FunctionName(name), _, _) if aliases.get(name).nonEmpty => (seq) => (seq + DeprecatedFunctionNotification(f.position, name, aliases(name)), None) } diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/QueryTagger.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/QueryTagger.scala index 8ef4530e4122..a1776fbdc0ce 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/QueryTagger.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/QueryTagger.scala @@ -300,9 +300,9 @@ object QueryTagger extends QueryTagger[String] { // functions lift[ASTNode] { - case f: FunctionInvocation if mathFunctions contains f.function => Set(MathFunctionTag) - case f: FunctionInvocation if stringFunctions contains f.function => Set(StringFunctionTag) - case f: FunctionInvocation if isAggregation(f.function) => Set(AggregationTag) + case f: UserFunctionInvocation if mathFunctions contains f.function => Set(MathFunctionTag) + case f: UserFunctionInvocation if stringFunctions contains f.function => Set(StringFunctionTag) + case f: UserFunctionInvocation if isAggregation(f.function) => Set(AggregationTag) } )) diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/ResolvedFunctionInvocation.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/ResolvedFunctionInvocation.scala index ee819c5f0850..758b895aa13f 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/ResolvedFunctionInvocation.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/ResolvedFunctionInvocation.scala @@ -27,7 +27,7 @@ import org.neo4j.cypher.internal.frontend.v3_1.ast._ object ResolvedFunctionInvocation { - def apply(signatureLookup: QualifiedName => Option[UserDefinedFunctionSignature])(unresolved: FunctionInvocation): ResolvedFunctionInvocation = { + def apply(signatureLookup: QualifiedName => Option[UserFunctionSignature])(unresolved: UserFunctionInvocation): ResolvedFunctionInvocation = { val position = unresolved.position val name = QualifiedName(unresolved) val signature = signatureLookup(name) @@ -46,7 +46,7 @@ object ResolvedFunctionInvocation { * @param position The position in the original query string. */ case class ResolvedFunctionInvocation(qualifiedName: QualifiedName, - fcnSignature: Option[UserDefinedFunctionSignature], + fcnSignature: Option[UserFunctionSignature], callArguments: IndexedSeq[Expression]) (val position: InputPosition) extends Expression { diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/normalizedEqualsArguments.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/normalizedEqualsArguments.scala index 05197ab4b17d..943deee6aae6 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/normalizedEqualsArguments.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/normalizedEqualsArguments.scala @@ -19,9 +19,8 @@ */ package org.neo4j.cypher.internal.compiler.v3_1.ast.conditions -import org.neo4j.cypher.internal.frontend.v3_1.ast.functions import org.neo4j.cypher.internal.compiler.v3_1.tracing.rewriters.Condition -import org.neo4j.cypher.internal.frontend.v3_1.ast.{Expression, FunctionInvocation, Property, Equals} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{Equals, Expression, Property, UserFunctionInvocation, functions} case object normalizedEqualsArguments extends Condition { def apply(that: Any): Seq[String] = { @@ -29,15 +28,15 @@ case object normalizedEqualsArguments extends Condition { equals.collect { case eq@Equals(expr, Property(_,_)) if !expr.isInstanceOf[Property] && notIdFunction(expr) => s"Equals at ${eq.position} is not normalized: $eq" - case eq@Equals(expr, func@FunctionInvocation(_, _, _, _)) if isIdFunction(func) && notIdFunction(expr) => + case eq@Equals(expr, func@UserFunctionInvocation(_, _, _, _)) if isIdFunction(func) && notIdFunction(expr) => s"Equals at ${eq.position} is not normalized: $eq" } } - private def isIdFunction(func: FunctionInvocation) = func.function == functions.Id + private def isIdFunction(func: UserFunctionInvocation) = func.function == functions.Id private def notIdFunction(expr: Expression) = - !expr.isInstanceOf[FunctionInvocation] || !isIdFunction(expr.asInstanceOf[FunctionInvocation]) + !expr.isInstanceOf[UserFunctionInvocation] || !isIdFunction(expr.asInstanceOf[UserFunctionInvocation]) override def name: String = productPrefix } diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/convert/commands/ExpressionConverters.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/convert/commands/ExpressionConverters.scala index 9b7f5d9ebf6b..4b3f1701f954 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/convert/commands/ExpressionConverters.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/convert/commands/ExpressionConverters.scala @@ -36,7 +36,7 @@ import org.neo4j.cypher.internal.frontend.v3_1.{InternalException, SemanticDirec import org.neo4j.graphdb.Direction object ExpressionConverters { - def toCommandExpression(expression: ast.Function, invocation: ast.FunctionInvocation): CommandExpression = + def toCommandExpression(expression: ast.Function, invocation: ast.UserFunctionInvocation): CommandExpression = expression match { case Abs => commandexpressions.AbsFunction(toCommandExpression(invocation.arguments.head)) case Acos => commandexpressions.AcosFunction(toCommandExpression(invocation.arguments.head)) @@ -259,7 +259,7 @@ object ExpressionConverters { case e: ast.Divide => commandexpressions.Divide(toCommandExpression(e.lhs), toCommandExpression(e.rhs)) case e: ast.Modulo => commandexpressions.Modulo(toCommandExpression(e.lhs), toCommandExpression(e.rhs)) case e: ast.Pow => commandexpressions.Pow(toCommandExpression(e.lhs), toCommandExpression(e.rhs)) - case e: ast.FunctionInvocation => toCommandExpression(e.function, e) + case e: ast.UserFunctionInvocation => toCommandExpression(e.function, e) case e: ast.CountStar => commandexpressions.CountStar() case e: ast.Property => toCommandProperty(e) case e: ast.Parameter => toCommandParameter(e) diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/normalizeArgumentOrder.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/normalizeArgumentOrder.scala index 930418447904..93fe69f860b2 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/normalizeArgumentOrder.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/normalizeArgumentOrder.scala @@ -33,10 +33,10 @@ case object normalizeArgumentOrder extends Rewriter { private val instance: Rewriter = topDown(Rewriter.lift { // move id(n) on equals to the left - case predicate @ Equals(func@FunctionInvocation(_, _, _, _), _) if func.function == functions.Id => + case predicate @ Equals(func@UserFunctionInvocation(_, _, _, _), _) if func.function == functions.Id => predicate - case predicate @ Equals(lhs, rhs @ FunctionInvocation(_, _, _, _)) if rhs.function == functions.Id => + case predicate @ Equals(lhs, rhs @ UserFunctionInvocation(_, _, _, _)) if rhs.function == functions.Id => predicate.copy(lhs = rhs, rhs = lhs)(predicate.position) // move n.prop on equals to the left diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/replaceAliasedFunctionInvocations.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/replaceAliasedFunctionInvocations.scala index 4794161f1ce3..23c253368b35 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/replaceAliasedFunctionInvocations.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/replaceAliasedFunctionInvocations.scala @@ -37,7 +37,7 @@ case object replaceAliasedFunctionInvocations extends Rewriter { "rels" -> "relationships")(CaseInsensitiveOrdered) val instance: Rewriter = bottomUp(Rewriter.lift { - case func@FunctionInvocation(_, f@FunctionName(name), _, _) if aliases.get(name).nonEmpty => + case func@UserFunctionInvocation(_, f@FunctionName(name), _, _) if aliases.get(name).nonEmpty => func.copy(functionName = FunctionName(aliases(name))(f.position))(func.position) }) diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/rewriteEqualityToInCollection.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/rewriteEqualityToInCollection.scala index c690e1a61146..93708c3d4afc 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/rewriteEqualityToInCollection.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/rewriteEqualityToInCollection.scala @@ -32,7 +32,7 @@ case object rewriteEqualityToInCollection extends Rewriter { private val instance: Rewriter = bottomUp(Rewriter.lift { // id(a) = value => id(a) IN [value] - case predicate@Equals(func@FunctionInvocation(_, _, _, IndexedSeq(idExpr)), idValueExpr) + case predicate@Equals(func@UserFunctionInvocation(_, _, _, IndexedSeq(idExpr)), idValueExpr) if func.function == functions.Id => In(func, Collection(Seq(idValueExpr))(idValueExpr.position))(predicate.position) diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/codegen/ir/expressions/ExpressionConverter.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/codegen/ir/expressions/ExpressionConverter.scala index 7f468740de84..a0eb083606fa 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/codegen/ir/expressions/ExpressionConverter.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/codegen/ir/expressions/ExpressionConverter.scala @@ -158,7 +158,7 @@ object ExpressionConverter { case ast.Not(inner) => Not(callback(inner)) - case f: ast.FunctionInvocation => functionConverter(f, callback) + case f: ast.UserFunctionInvocation => functionConverter(f, callback) case other => throw new CantCompileQueryException(s"Expression of $other not yet supported") } diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/codegen/ir/functions/functionConverter.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/codegen/ir/functions/functionConverter.scala index 7d563e863229..d365bf1ba1ab 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/codegen/ir/functions/functionConverter.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/codegen/ir/functions/functionConverter.scala @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.frontend.v3_1.ast object functionConverter { - def apply(fcn: ast.FunctionInvocation, callback: ast.Expression => CodeGenExpression) + def apply(fcn: ast.UserFunctionInvocation, callback: ast.Expression => CodeGenExpression) (implicit context: CodeGenContext): CodeGenExpression = fcn.function match { // id(n) diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/commands/expressions/FunctionInvocation.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/commands/expressions/FunctionInvocation.scala index 8cf7b66baf28..855876b2c8f1 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/commands/expressions/FunctionInvocation.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/commands/expressions/FunctionInvocation.scala @@ -24,10 +24,10 @@ import org.neo4j.cypher.internal.compiler.v3_1.executionplan.ProcedureCallMode import org.neo4j.cypher.internal.compiler.v3_1.helpers.{RuntimeJavaValueConverter, RuntimeScalaValueConverter} import org.neo4j.cypher.internal.compiler.v3_1.mutation.GraphElementPropertyFunctions import org.neo4j.cypher.internal.compiler.v3_1.pipes.QueryState -import org.neo4j.cypher.internal.compiler.v3_1.spi.UserDefinedFunctionSignature +import org.neo4j.cypher.internal.compiler.v3_1.spi.UserFunctionSignature import org.neo4j.cypher.internal.compiler.v3_1.symbols.SymbolTable -case class FunctionInvocation(signature: UserDefinedFunctionSignature, arguments: IndexedSeq[Expression]) +case class FunctionInvocation(signature: UserFunctionSignature, arguments: IndexedSeq[Expression]) extends Expression with GraphElementPropertyFunctions { private val callMode = ProcedureCallMode.fromAccessMode(signature.accessMode) diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/helpers/simpleExpressionEvaluator.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/helpers/simpleExpressionEvaluator.scala index 13d8b473afa9..52cf0fe19062 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/helpers/simpleExpressionEvaluator.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/helpers/simpleExpressionEvaluator.scala @@ -23,7 +23,7 @@ import org.neo4j.cypher.internal.compiler.v3_1.ExecutionContext import org.neo4j.cypher.internal.compiler.v3_1.ast.convert.commands.ExpressionConverters import org.neo4j.cypher.internal.compiler.v3_1.pipes.{NullPipeDecorator, QueryState} import org.neo4j.cypher.internal.frontend.v3_1.ast.functions.{Rand, Timestamp} -import org.neo4j.cypher.internal.frontend.v3_1.ast.{FunctionInvocation, FunctionName, Parameter, Expression} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{Expression, Parameter, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.{CypherException => InternalCypherException} import scala.collection.mutable @@ -38,8 +38,8 @@ object simpleExpressionEvaluator { def isNonDeterministic(expr: Expression): Boolean = expr.inputs.exists { - case (func@FunctionInvocation(_, _, _, _), _) if func.function == Rand => true - case (func@FunctionInvocation(_, _, _, _), _) if func.function == Timestamp => true + case (func@UserFunctionInvocation(_, _, _, _), _) if func.function == Rand => true + case (func@UserFunctionInvocation(_, _, _, _), _) if func.function == Timestamp => true case _ => false } diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/idp/expandSolverStep.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/idp/expandSolverStep.scala index 27c6ded13c07..81a9ddfc7b77 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/idp/expandSolverStep.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/idp/expandSolverStep.scala @@ -19,10 +19,10 @@ */ package org.neo4j.cypher.internal.compiler.v3_1.planner.logical.idp -import org.neo4j.cypher.internal.frontend.v3_1.ast._ import org.neo4j.cypher.internal.compiler.v3_1.planner.QueryGraph import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.LogicalPlanningContext import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.plans._ +import org.neo4j.cypher.internal.frontend.v3_1.ast._ case class expandSolverStep(qg: QueryGraph) extends IDPSolverStep[PatternRelationship, LogicalPlan, LogicalPlanningContext] { @@ -83,16 +83,16 @@ object expandSolverStep { (variable, innerPredicate) -> all //MATCH p = ... WHERE all(n in nodes(p)... or all(r in relationships(p) case all@AllIterablePredicate(FilterScope(variable, Some(innerPredicate)), - FunctionInvocation(_, FunctionName(fname), false, - Seq(PathExpression( + UserFunctionInvocation(_, FunctionName(fname), false, + Seq(PathExpression( NodePathStep(startNode, MultiRelationshipPathStep(rel, _, NilPathStep) ))) )) if (fname == "nodes" || fname == "relationships") && startNode.name == nodeId.name && rel.name == patternRel.name.name => (variable, innerPredicate) -> all //MATCH p = ... WHERE all(n in nodes(p)... or all(r in relationships(p) case none@NoneIterablePredicate(FilterScope(variable, Some(innerPredicate)), - FunctionInvocation(_, FunctionName(fname), false, - Seq(PathExpression( + UserFunctionInvocation(_, FunctionName(fname), false, + Seq(PathExpression( NodePathStep(startNode, MultiRelationshipPathStep(rel, _, NilPathStep) ))) )) if (fname == "nodes" || fname == "relationships") && startNode.name == nodeId.name && rel.name == patternRel.name.name => (variable, Not(innerPredicate)(innerPredicate.position)) -> none diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/NonSargable.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/NonSargable.scala index b909551a83d2..5c1ca65bf099 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/NonSargable.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/NonSargable.scala @@ -35,7 +35,7 @@ object AsDynamicPropertyNonSeekable { object AsDynamicPropertyNonScannable { def unapply(v: Any) = v match { - case func@FunctionInvocation(_, _, _, IndexedSeq(ContainerIndex(variable: Variable, _))) + case func@UserFunctionInvocation(_, _, _, IndexedSeq(ContainerIndex(variable: Variable, _))) if func.function == functions.Exists => Some(variable) diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/Sargable.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/Sargable.scala index 53a63d55ddb1..86dfc2efe1e4 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/Sargable.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/Sargable.scala @@ -38,7 +38,7 @@ object WithSeekableArgs { object AsIdSeekable { def unapply(v: Any) = v match { - case WithSeekableArgs(func@FunctionInvocation(_, _, _, IndexedSeq(ident: Variable)), rhs) + case WithSeekableArgs(func@UserFunctionInvocation(_, _, _, IndexedSeq(ident: Variable)), rhs) if func.function == functions.Id && !rhs.dependencies(ident) => Some(IdSeekable(func, ident, rhs)) case _ => @@ -59,7 +59,7 @@ object AsPropertySeekable { object AsPropertyScannable { def unapply(v: Any): Option[Scannable[Expression]] = v match { - case func@FunctionInvocation(_, _, _, IndexedSeq(property@Property(ident: Variable, _))) + case func@UserFunctionInvocation(_, _, _, IndexedSeq(property@Property(ident: Variable, _))) if func.function == functions.Exists => Some(ExplicitlyPropertyScannable(func, ident, property)) @@ -85,7 +85,7 @@ object AsPropertyScannable { private def partialPropertyPredicate[P <: Expression](predicate: P, lhs: Expression) = lhs match { case property@Property(ident: Variable, _) => PartialPredicate.ifNotEqual( - FunctionInvocation(FunctionName(functions.Exists.name)(predicate.position), property)(predicate.position), + UserFunctionInvocation(FunctionName(functions.Exists.name)(predicate.position), property)(predicate.position), predicate ).map(ImplicitlyPropertyScannable(_, ident, property)) @@ -130,8 +130,8 @@ sealed trait EqualitySeekable[T <: Expression] extends Seekable[T] { def args: SeekableArgs } -case class IdSeekable(expr: FunctionInvocation, ident: Variable, args: SeekableArgs) - extends EqualitySeekable[FunctionInvocation] { +case class IdSeekable(expr: UserFunctionInvocation, ident: Variable, args: SeekableArgs) + extends EqualitySeekable[UserFunctionInvocation] { def dependencies = args.dependencies } @@ -182,8 +182,8 @@ sealed trait Scannable[+T <: Expression] extends Sargable[T] { def propertyKey = property.propertyKey } -case class ExplicitlyPropertyScannable(expr: FunctionInvocation, ident: Variable, property: Property) - extends Scannable[FunctionInvocation] +case class ExplicitlyPropertyScannable(expr: UserFunctionInvocation, ident: Variable, property: Property) + extends Scannable[UserFunctionInvocation] case class ImplicitlyPropertyScannable[+T <: Expression](expr: PartialPredicate[T], ident: Variable, property: Property) extends Scannable[PartialPredicate[T]] diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/PatternExpressionSolver.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/PatternExpressionSolver.scala index 1a80bb687c81..7c2ed6c351c7 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/PatternExpressionSolver.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/PatternExpressionSolver.scala @@ -53,8 +53,7 @@ Would be solved with a plan such as */ case class PatternExpressionSolver(pathStepBuilder: EveryPath => PathStep = projectNamedPaths.patternPartPathExpression) { - import PatternExpressionSolver.solvePatternExpressions - import PatternExpressionSolver.solvePatternComprehensions + import PatternExpressionSolver.{solvePatternComprehensions, solvePatternExpressions} def apply(source: LogicalPlan, expressions: Seq[Expression]) (implicit context: LogicalPlanningContext): (LogicalPlan, Seq[Expression]) = { @@ -250,7 +249,7 @@ case class CollectionSubQueryExpressionSolver[T <: Expression](namer: T => (T, M topDown(inner, stopper = { case _: PatternComprehension => false case _: ScopeExpression | _: CaseExpression => true - case f: FunctionInvocation => f.function == Exists + case f: UserFunctionInvocation => f.function == Exists case _ => false }) } diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/countStorePlanner.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/countStorePlanner.scala index 83d4ad38aad9..1e522d46ffc0 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/countStorePlanner.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/countStorePlanner.scala @@ -23,7 +23,7 @@ import org.neo4j.cypher.internal.compiler.v3_1.pipes.LazyTypes import org.neo4j.cypher.internal.compiler.v3_1.planner._ import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.LogicalPlanningContext import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.plans._ -import org.neo4j.cypher.internal.frontend.v3_1.SemanticDirection.{BOTH, INCOMING, OUTGOING} +import org.neo4j.cypher.internal.frontend.v3_1.SemanticDirection.{INCOMING, OUTGOING} import org.neo4j.cypher.internal.frontend.v3_1.ast._ case object countStorePlanner { @@ -54,7 +54,7 @@ case object countStorePlanner { argumentIds: Set[IdName], selections: Selections)(implicit context: LogicalPlanningContext): Option[LogicalPlan] = exp match { case // COUNT() - func@FunctionInvocation(_, _, false, Vector(Variable(variableName))) if func.function == functions.Count => + func@UserFunctionInvocation(_, _, false, Vector(Variable(variableName))) if func.function == functions.Count => trySolveNodeAggregation(query, columnName, Some(variableName), patternRelationships, patternNodes, argumentIds, selections) case // COUNT(*) @@ -62,7 +62,7 @@ case object countStorePlanner { trySolveNodeAggregation(query, columnName, None, patternRelationships, patternNodes, argumentIds, selections) case // COUNT(n.prop) - func@FunctionInvocation(_, _, false, Vector(Property(Variable(variableName), PropertyKeyName(propKeyName)))) + func@UserFunctionInvocation(_, _, false, Vector(Property(Variable(variableName), PropertyKeyName(propKeyName)))) if func.function == functions.Count => val labelCheck: Option[LabelName] => (Option[LogicalPlan] => Option[LogicalPlan]) = { case None => _ => None diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/getDegreeRewriter.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/getDegreeRewriter.scala index 5953f59dbc4f..14179e315288 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/getDegreeRewriter.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/getDegreeRewriter.scala @@ -33,17 +33,17 @@ case object getDegreeRewriter extends Rewriter { private def rewriter = Rewriter.lift { // LENGTH( (a)-[]->() ) - case func@FunctionInvocation(_, _, _, IndexedSeq(PatternExpression(RelationshipsPattern(RelationshipChain(NodePattern(Some(node), List(), None), RelationshipPattern(None, _, types, None, None, dir), NodePattern(None, List(), None)))))) + case func@UserFunctionInvocation(_, _, _, IndexedSeq(PatternExpression(RelationshipsPattern(RelationshipChain(NodePattern(Some(node), List(), None), RelationshipPattern(None, _, types, None, None, dir), NodePattern(None, List(), None)))))) if func.function == functions.Length || func.function == functions.Size => calculateUsingGetDegree(func, node, types, dir) // LENGTH( ()-[]->(a) ) - case func@FunctionInvocation(_, _, _, IndexedSeq(PatternExpression(RelationshipsPattern(RelationshipChain(NodePattern(None, List(), None), RelationshipPattern(None, _, types, None, None, dir), NodePattern(Some(node), List(), None)))))) + case func@UserFunctionInvocation(_, _, _, IndexedSeq(PatternExpression(RelationshipsPattern(RelationshipChain(NodePattern(None, List(), None), RelationshipPattern(None, _, types, None, None, dir), NodePattern(Some(node), List(), None)))))) if func.function == functions.Length || func.function == functions.Size => calculateUsingGetDegree(func, node, types, dir.reversed) } - private def calculateUsingGetDegree(func: FunctionInvocation, node: Variable, types: Seq[RelTypeName], dir: SemanticDirection): Expression = { + private def calculateUsingGetDegree(func: UserFunctionInvocation, node: Variable, types: Seq[RelTypeName], dir: SemanticDirection): Expression = { types .map(typ => GetDegree(node.copyId, Some(typ), dir)(typ.position)) .reduceOption[Expression](Add(_, _)(func.position)) diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/idSeekLeafPlanner.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/idSeekLeafPlanner.scala index 8e6424f70175..66ad5eb9c56f 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/idSeekLeafPlanner.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/idSeekLeafPlanner.scala @@ -86,5 +86,5 @@ object idSeekLeafPlanner extends LeafPlanner { private def relTypeAsStringLiteral(relType: RelTypeName) = StringLiteral(relType.name)(relType.position) private def typeOfRelExpr(idExpr: Variable) = - FunctionInvocation(FunctionName("type")(idExpr.position), idExpr)(idExpr.position) + UserFunctionInvocation(FunctionName("type")(idExpr.position), idExpr)(idExpr.position) } diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/planShortestPaths.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/planShortestPaths.scala index babeb4e61daa..476fb12d1314 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/planShortestPaths.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/planShortestPaths.scala @@ -46,8 +46,8 @@ case object planShortestPaths { val (safePredicates, needFallbackPredicates) = predicates.partition { // TODO: Once we support node predicates we should enable all NONE and ALL predicates as safe predicates - case NoneIterablePredicate(_, f@FunctionInvocation(_, _, _, _)) if f.function == Nodes => false - case AllIterablePredicate(_, f@FunctionInvocation(_, _, _, _)) if f.function == Nodes => false + case NoneIterablePredicate(_, f@UserFunctionInvocation(_, _, _, _)) if f.function == Nodes => false + case AllIterablePredicate(_, f@UserFunctionInvocation(_, _, _, _)) if f.function == Nodes => false case NoneIterablePredicate(FilterScope(_, Some(innerPredicate)), _) if doesNotDependOnFullPath(innerPredicate) => true case AllIterablePredicate(FilterScope(_, Some(innerPredicate)), _) if doesNotDependOnFullPath(innerPredicate) => true case _ => false @@ -127,7 +127,7 @@ case object planShortestPaths { // Plan Sort and Limit val pos = shortestPath.expr.position val pathVariable = Variable(pathName.name)(pos) - val lengthOfPath = FunctionInvocation(FunctionName(Length.name)(pos), pathVariable)(pos) + val lengthOfPath = UserFunctionInvocation(FunctionName(Length.name)(pos), pathVariable)(pos) val columnName = FreshIdNameGenerator.name(pos) val rhsProjMap = Map(columnName -> lengthOfPath) diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/rewriteProcedureCalls.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/rewriteProcedureCalls.scala index eef732037c45..ff8eb7e39dce 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/rewriteProcedureCalls.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/rewriteProcedureCalls.scala @@ -20,7 +20,7 @@ package org.neo4j.cypher.internal.compiler.v3_1 import org.neo4j.cypher.internal.compiler.v3_1.ast.{ResolvedCall, ResolvedFunctionInvocation} -import org.neo4j.cypher.internal.compiler.v3_1.spi.{ProcedureSignature, QualifiedName, UserDefinedFunctionSignature} +import org.neo4j.cypher.internal.compiler.v3_1.spi.{ProcedureSignature, QualifiedName, UserFunctionSignature} import org.neo4j.cypher.internal.frontend.v3_1.ast._ import org.neo4j.cypher.internal.frontend.v3_1.{Rewriter, bottomUp} @@ -29,7 +29,7 @@ import org.neo4j.cypher.internal.frontend.v3_1.{Rewriter, bottomUp} object rewriteProcedureCalls { def apply(procSignatureLookup: QualifiedName => ProcedureSignature, - funcSignatureLookup: QualifiedName => Option[UserDefinedFunctionSignature]) = { + funcSignatureLookup: QualifiedName => Option[UserFunctionSignature]) = { // rewriter that amends unresolved procedure calls with procedure signature information val resolveCalls = bottomUp(Rewriter.lift { @@ -40,7 +40,7 @@ object rewriteProcedureCalls { val coerced = resolved.coerceArguments coerced - case function: FunctionInvocation if function.needsToBeResolved => + case function: UserFunctionInvocation if function.needsToBeResolved => val resolved = ResolvedFunctionInvocation(funcSignatureLookup)(function) // We coerce here to ensure that the semantic check run after this rewriter assigns a type diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/spi/PlanContext.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/spi/PlanContext.scala index 27cf31d4eb32..6eb7bc320da6 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/spi/PlanContext.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/spi/PlanContext.scala @@ -64,5 +64,5 @@ trait PlanContext extends TokenContext with ProcedureSignatureResolver { trait ProcedureSignatureResolver { def procedureSignature(name: QualifiedName): ProcedureSignature - def functionSignature(name: QualifiedName): Option[UserDefinedFunctionSignature] + def functionSignature(name: QualifiedName): Option[UserFunctionSignature] } diff --git a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/spi/ProcedureSignature.scala b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/spi/ProcedureSignature.scala index f88c02f569fe..3c0a10f5c710 100644 --- a/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/spi/ProcedureSignature.scala +++ b/community/cypher/cypher-compiler-3.1/src/main/scala/org/neo4j/cypher/internal/compiler/v3_1/spi/ProcedureSignature.scala @@ -19,7 +19,7 @@ */ package org.neo4j.cypher.internal.compiler.v3_1.spi -import org.neo4j.cypher.internal.frontend.v3_1.ast.{FunctionInvocation, UnresolvedCall} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{UnresolvedCall, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.symbols.CypherType case class ProcedureSignature(name: QualifiedName, @@ -33,16 +33,16 @@ case class ProcedureSignature(name: QualifiedName, def isVoid = outputSignature.isEmpty } -case class UserDefinedFunctionSignature(name: QualifiedName, - inputSignature: IndexedSeq[CypherType], - outputType: CypherType, - deprecationInfo: Option[String], - accessMode: ProcedureReadOnlyAccess) +case class UserFunctionSignature(name: QualifiedName, + inputSignature: IndexedSeq[CypherType], + outputType: CypherType, + deprecationInfo: Option[String], + accessMode: ProcedureReadOnlyAccess) object QualifiedName { def apply(unresolved: UnresolvedCall): QualifiedName = QualifiedName(unresolved.procedureNamespace.parts, unresolved.procedureName.name) - def apply(unresolved: FunctionInvocation): QualifiedName = + def apply(unresolved: UserFunctionInvocation): QualifiedName = QualifiedName(unresolved.namespace.parts, unresolved.functionName.name) } diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/RewriteProcedureCallsTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/RewriteProcedureCallsTest.scala index 9d35788555e2..1c01263ebf94 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/RewriteProcedureCallsTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/RewriteProcedureCallsTest.scala @@ -35,7 +35,7 @@ class RewriteProcedureCallsTest extends CypherFunSuite with AstConstructionTestS val signature = ProcedureSignature(qualifiedName, signatureInputs, signatureOutputs, None, ProcedureReadOnlyAccess(Array.empty[String])) val procLookup: (QualifiedName) => ProcedureSignature = _ => signature - val fcnLookup: (QualifiedName) => Option[UserDefinedFunctionSignature] = _ => None + val fcnLookup: (QualifiedName) => Option[UserFunctionSignature] = _ => None test("should resolve standalone procedure calls") { val unresolved = UnresolvedCall(ns, name, None, None)(pos) diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/AggregationsAreIsolatedTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/AggregationsAreIsolatedTest.scala index 94b5b1a0b292..ca6d1dd12c59 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/AggregationsAreIsolatedTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/AggregationsAreIsolatedTest.scala @@ -40,7 +40,7 @@ class AggregationsAreIsolatedTest extends CypherFunSuite with AstConstructionTes test("unhappy when aggregations are both top-level and sub-expression of the expression") { val equals: Expression = Equals(CountStar()_, UnsignedDecimalIntegerLiteral("42")_)_ - val ast: Expression = FunctionInvocation(FunctionName("count")_, equals)_ + val ast: Expression = UserFunctionInvocation(FunctionName("count")_, equals)_ condition(ast) should equal(Seq(s"Expression $equals contains child expressions which are aggregations")) } diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/NormalizedEqualsArgumentsTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/NormalizedEqualsArgumentsTest.scala index 1a6372e3f402..f51115093c30 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/NormalizedEqualsArgumentsTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/conditions/NormalizedEqualsArgumentsTest.scala @@ -62,6 +62,6 @@ class NormalizedEqualsArgumentsTest extends CypherFunSuite with AstConstructionT condition(ast) should equal(Seq(s"Equals at ${ast.position} is not normalized: $ast")) } - private def id(name: String): FunctionInvocation = - FunctionInvocation(FunctionName("id")(pos), distinct = false, Array(Variable(name)(pos)))(pos) + private def id(name: String): UserFunctionInvocation = + UserFunctionInvocation(FunctionName("id")(pos), distinct = false, Array(Variable(name)(pos)))(pos) } diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/convert/plannerQuery/StatementConvertersTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/convert/plannerQuery/StatementConvertersTest.scala index 45f6d550c199..cc268b73d3df 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/convert/plannerQuery/StatementConvertersTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/convert/plannerQuery/StatementConvertersTest.scala @@ -120,7 +120,7 @@ class StatementConvertersTest extends CypherFunSuite with LogicalPlanningTestSup query.queryGraph.selections should equal(Selections(Set( Predicate(Set(IdName("n")), In( - FunctionInvocation(FunctionName("id")_, distinct = false, Vector(Variable("n")(pos)))(pos), + UserFunctionInvocation(FunctionName("id")_, distinct = false, Vector(Variable("n")(pos)))(pos), Collection(Seq(SignedDecimalIntegerLiteral("42")_))_ )_ )))) @@ -136,7 +136,7 @@ class StatementConvertersTest extends CypherFunSuite with LogicalPlanningTestSup query.queryGraph.selections should equal(Selections(Set( Predicate(Set(IdName("n")), In( - FunctionInvocation(FunctionName("id")_, distinct = false, Vector(Variable("n")(pos)))(pos), + UserFunctionInvocation(FunctionName("id")_, distinct = false, Vector(Variable("n")(pos)))(pos), Collection(Seq(lit42, lit43))_ )_ )))) @@ -153,7 +153,7 @@ class StatementConvertersTest extends CypherFunSuite with LogicalPlanningTestSup query.queryGraph.selections should equal(Selections(Set( Predicate(Set(IdName("n")), HasLabels(nIdent, Seq(A))_), Predicate(Set(IdName("n")), In( - FunctionInvocation(FunctionName("id")_, distinct = false, Vector(Variable("n")(pos)))(pos), + UserFunctionInvocation(FunctionName("id")_, distinct = false, Vector(Variable("n")(pos)))(pos), Collection(Seq(SignedDecimalIntegerLiteral("42")_))_ )_ )))) @@ -637,7 +637,7 @@ class StatementConvertersTest extends CypherFunSuite with LogicalPlanningTestSup tailQg.queryGraph.selections.predicates should equal(Set( Predicate( Set(IdName("b"), IdName("property")), - In(FunctionInvocation(FunctionName("id") _, Variable("b") _) _, Collection(Seq(Variable("property")(pos))) _) _ + In(UserFunctionInvocation(FunctionName("id") _, Variable("b") _) _, Collection(Seq(Variable("property")(pos))) _) _ ) )) @@ -662,7 +662,7 @@ class StatementConvertersTest extends CypherFunSuite with LogicalPlanningTestSup secondQuery.queryGraph.selections.predicates should equal(Set( Predicate( Set(IdName("b"), IdName("property")), - In(FunctionInvocation(FunctionName("id") _, Variable("b") _) _, Collection(Seq(Variable("property")(pos))) _) _ + In(UserFunctionInvocation(FunctionName("id") _, Variable("b") _) _, Collection(Seq(Variable("property")(pos))) _) _ ))) secondQuery.horizon should equal( @@ -688,7 +688,7 @@ class StatementConvertersTest extends CypherFunSuite with LogicalPlanningTestSup tailQg.queryGraph.selections.predicates should equal(Set( Predicate( Set(IdName("b"), IdName("property")), - In(FunctionInvocation(FunctionName("id") _, Variable("b") _) _, Collection(Seq(Variable("property") _)) _) _ + In(UserFunctionInvocation(FunctionName("id") _, Variable("b") _) _, Collection(Seq(Variable("property") _)) _) _ ) )) @@ -961,7 +961,7 @@ class StatementConvertersTest extends CypherFunSuite with LogicalPlanningTestSup query.queryGraph.patternNodes should equal(Set(IdName("row"))) val functionName: FunctionName = FunctionName("collect") _ - val functionInvocation: FunctionInvocation = FunctionInvocation(functionName, varFor("row")) _ + val functionInvocation: UserFunctionInvocation = UserFunctionInvocation(functionName, varFor("row")) _ query.horizon should equal( AggregatingQueryProjection( @@ -1023,7 +1023,7 @@ class StatementConvertersTest extends CypherFunSuite with LogicalPlanningTestSup query.horizon should equal(RegularQueryProjection( projections = Map( - "x" -> FunctionInvocation(FunctionName("coalesce")_, distinct = false, Vector(varFor("b"), varFor("c")))(pos) + "x" -> UserFunctionInvocation(FunctionName("coalesce")_, distinct = false, Vector(varFor("b"), varFor("c")))(pos) ) )) diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/NormalizeArgumentOrderTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/NormalizeArgumentOrderTest.scala index 77794ec798e4..dbd34b012f52 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/NormalizeArgumentOrderTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/NormalizeArgumentOrderTest.scala @@ -116,8 +116,8 @@ class NormalizeArgumentOrderTest extends CypherFunSuite with AstConstructionTest normalizeArgumentOrder(input) should equal(LessThanOrEqual(rhs, lhs)(pos)) } - private def id(name: String): FunctionInvocation = - FunctionInvocation(FunctionName("id")(pos), distinct = false, Array(Variable(name)(pos)))(pos) + private def id(name: String): UserFunctionInvocation = + UserFunctionInvocation(FunctionName("id")(pos), distinct = false, Array(Variable(name)(pos)))(pos) } diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/ProjectNamedPathsTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/ProjectNamedPathsTest.scala index 083c308047b3..b3ab28459848 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/ProjectNamedPathsTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/ProjectNamedPathsTest.scala @@ -252,7 +252,7 @@ class ProjectNamedPathsTest extends CypherFunSuite with AstRewritingTestSupport val WHERE = Where( GreaterThan( - FunctionInvocation(FunctionName("length")(pos), PathExpression(NodePathStep(aId, SingleRelationshipPathStep(rId, SemanticDirection.OUTGOING, NilPathStep)))(pos))(pos), + UserFunctionInvocation(FunctionName("length")(pos), PathExpression(NodePathStep(aId, SingleRelationshipPathStep(rId, SemanticDirection.OUTGOING, NilPathStep)))(pos))(pos), SignedDecimalIntegerLiteral("10")(pos) )(pos) )(pos) @@ -297,7 +297,7 @@ class ProjectNamedPathsTest extends CypherFunSuite with AstRewritingTestSupport val WITH1 = With(distinct = false, ReturnItems(includeExisting = false, Seq( - AliasedReturnItem(FunctionInvocation(FunctionName("length")(pos), pathExpression)(pos), l)(pos), + AliasedReturnItem(UserFunctionInvocation(FunctionName("length")(pos), pathExpression)(pos), l)(pos), AliasedReturnItem(CountStar()(pos), x)(pos) ))(pos), None, None, None, None)(pos) diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/ReplaceAliasedFunctionInvocationsTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/ReplaceAliasedFunctionInvocationsTest.scala index a316d7e4a9a0..2f9fb77c0c30 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/ReplaceAliasedFunctionInvocationsTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/ast/rewriters/ReplaceAliasedFunctionInvocationsTest.scala @@ -19,7 +19,7 @@ */ package org.neo4j.cypher.internal.compiler.v3_1.ast.rewriters -import org.neo4j.cypher.internal.frontend.v3_1.ast.{AstConstructionTestSupport, FunctionInvocation, FunctionName} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{AstConstructionTestSupport, FunctionName, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.test_helpers.CypherFunSuite class ReplaceAliasedFunctionInvocationsTest extends CypherFunSuite with AstConstructionTestSupport { @@ -27,13 +27,13 @@ class ReplaceAliasedFunctionInvocationsTest extends CypherFunSuite with AstConst val rewriter = replaceAliasedFunctionInvocations test("should rewrite toInt()") { - val before = FunctionInvocation(FunctionName("toInt")(pos), literalInt(1))(pos) + val before = UserFunctionInvocation(FunctionName("toInt")(pos), literalInt(1))(pos) rewriter(before) should equal(before.copy(functionName = FunctionName("toInteger")(pos))(pos)) } test("doesn't touch toInteger()") { - val before = FunctionInvocation(FunctionName("toInteger")(pos), literalInt(1))(pos) + val before = UserFunctionInvocation(FunctionName("toInteger")(pos), literalInt(1))(pos) rewriter(before) should equal(before) } diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/helpers/simpleExpressionEvaluatorTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/helpers/simpleExpressionEvaluatorTest.scala index 779bcab0a215..bf21df72d4bc 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/helpers/simpleExpressionEvaluatorTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/helpers/simpleExpressionEvaluatorTest.scala @@ -21,7 +21,7 @@ package org.neo4j.cypher.internal.compiler.v3_1.helpers import org.neo4j.cypher.internal.compiler.v3_1.helpers.simpleExpressionEvaluator.isNonDeterministic import org.neo4j.cypher.internal.frontend.v3_1.DummyPosition -import org.neo4j.cypher.internal.frontend.v3_1.ast.{FunctionName, FunctionInvocation} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{FunctionName, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.test_helpers.CypherFunSuite class SimpleExpressionEvaluatorTest extends CypherFunSuite { @@ -29,8 +29,8 @@ class SimpleExpressionEvaluatorTest extends CypherFunSuite { test("isNonDeterministic should not care about capitalization") { isNonDeterministic( - FunctionInvocation(FunctionName("ranD")(pos), distinct = false, IndexedSeq.empty)(pos)) shouldBe true + UserFunctionInvocation(FunctionName("ranD")(pos), distinct = false, IndexedSeq.empty)(pos)) shouldBe true isNonDeterministic( - FunctionInvocation(FunctionName("Timestamp")(pos), distinct = false, IndexedSeq.empty)(pos)) shouldBe true + UserFunctionInvocation(FunctionName("Timestamp")(pos), distinct = false, IndexedSeq.empty)(pos)) shouldBe true } } diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/LogicalPlanningTestSupport.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/LogicalPlanningTestSupport.scala index 816cc33c9275..4aa49919f187 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/LogicalPlanningTestSupport.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/LogicalPlanningTestSupport.scala @@ -193,7 +193,7 @@ trait LogicalPlanningTestSupport extends CypherTestSupport with AstConstructionT } def buildPlannerUnionQuery(query: String, procLookup: Option[QualifiedName => ProcedureSignature] = None, - fcnLookup: Option[QualifiedName => Option[UserDefinedFunctionSignature]] = None) = { + fcnLookup: Option[QualifiedName => Option[UserFunctionSignature]] = None) = { val signature = ProcedureSignature( QualifiedName(Seq.empty, "foo"), inputSignature = IndexedSeq.empty, diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/LogicalPlanningTestSupport2.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/LogicalPlanningTestSupport2.scala index 86356d427e45..4fb72360d190 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/LogicalPlanningTestSupport2.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/LogicalPlanningTestSupport2.scala @@ -156,7 +156,7 @@ trait LogicalPlanningTestSupport2 extends CypherTestSupport with AstConstruction override def procedureSignature(name: QualifiedName): ProcedureSignature = ??? - override def functionSignature(name: QualifiedName): Option[UserDefinedFunctionSignature] = ??? + override def functionSignature(name: QualifiedName): Option[UserFunctionSignature] = ??? } def planFor(queryString: String): SemanticPlan = { diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/LeafPlanningIntegrationTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/LeafPlanningIntegrationTest.scala index 9253b7e11b7b..08ab64d2e9b2 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/LeafPlanningIntegrationTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/LeafPlanningIntegrationTest.scala @@ -300,8 +300,8 @@ class LeafPlanningIntegrationTest extends CypherFunSuite with LogicalPlanningTes } planFor "MATCH (n:Awesome) WHERE exists(n.prop) AND n.prop = 42 RETURN n" plan.plan should equal( - Selection(Seq(FunctionInvocation(FunctionName("exists") _, Property(varFor("n"), PropertyKeyName("prop") _) _) _), - NodeIndexSeek( + Selection(Seq(UserFunctionInvocation(FunctionName("exists") _, Property(varFor("n"), PropertyKeyName("prop") _) _) _), + NodeIndexSeek( "n", LabelToken("Awesome", LabelId(0)), PropertyKeyToken(PropertyKeyName("prop") _, PropertyKeyId(0)), diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/NamedPathProjectionPlanningIntegrationTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/NamedPathProjectionPlanningIntegrationTest.scala index 68726f2ee326..4a493952d282 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/NamedPathProjectionPlanningIntegrationTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/NamedPathProjectionPlanningIntegrationTest.scala @@ -46,7 +46,7 @@ class NamedPathProjectionPlanningIntegrationTest extends CypherFunSuite with Log result should equal( Selection( Seq(Equals( - FunctionInvocation(FunctionName("head") _, FunctionInvocation(FunctionName("nodes") _, pathExpr) _) _, + UserFunctionInvocation(FunctionName("head") _, UserFunctionInvocation(FunctionName("nodes") _, pathExpr) _) _, varFor("a") ) _), Expand(NodeByLabelScan("a", lblName("X"), Set.empty)(solved), "a", SemanticDirection.OUTGOING, Seq.empty, "b", "r")(solved) @@ -63,11 +63,11 @@ class NamedPathProjectionPlanningIntegrationTest extends CypherFunSuite with Log Selection( Seq( Equals( - FunctionInvocation(FunctionName("head") _, FunctionInvocation(FunctionName("nodes") _, pathExpr) _) _, + UserFunctionInvocation(FunctionName("head") _, UserFunctionInvocation(FunctionName("nodes") _, pathExpr) _) _, Variable("a") _ ) _, GreaterThan( - FunctionInvocation(FunctionName("length") _, pathExpr) _, + UserFunctionInvocation(FunctionName("length") _, pathExpr) _, SignedDecimalIntegerLiteral("10") _ ) _ ), diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/idp/IDPQueryGraphSolverTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/idp/IDPQueryGraphSolverTest.scala index 533dd3d18709..a6fb3b59abdf 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/idp/IDPQueryGraphSolverTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/idp/IDPQueryGraphSolverTest.scala @@ -829,7 +829,7 @@ class IDPQueryGraphSolverTest extends CypherFunSuite with LogicalPlanningTestSup qg = QueryGraph(// MATCH (a)-[r]->(b) WHERE id(r) = 42 RETURN * patternNodes = Set("a", "b"), patternRelationships = Set(PatternRelationship("r", ("a", "b"), SemanticDirection.OUTGOING, Seq.empty, SimplePatternLength)), - selections = Selections.from(In(FunctionInvocation(FunctionName("id")(pos), varFor("r"))(pos), Collection(Seq(SignedDecimalIntegerLiteral("42")(pos)))(pos))(pos)) + selections = Selections.from(In(UserFunctionInvocation(FunctionName("id")(pos), varFor("r"))(pos), Collection(Seq(SignedDecimalIntegerLiteral("42")(pos)))(pos))(pos)) ) }.withLogicalPlanningContext { (cfg, ctx) => implicit val x = ctx diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/IdSeekLeafPlannerTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/IdSeekLeafPlannerTest.scala index 50bafb96fd1a..9c8ec18bb0dc 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/IdSeekLeafPlannerTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/IdSeekLeafPlannerTest.scala @@ -41,7 +41,7 @@ class IdSeekLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSupp // given val variable: Variable = Variable("n")_ val expr = In( - FunctionInvocation(FunctionName("id")_, distinct = false, Array(variable))_, + UserFunctionInvocation(FunctionName("id")_, distinct = false, Array(variable))_, Collection( Seq(SignedDecimalIntegerLiteral("42")_, SignedDecimalIntegerLiteral("43")_, SignedDecimalIntegerLiteral("43")_) )_ @@ -77,7 +77,7 @@ class IdSeekLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSupp // given val variable: Variable = Variable("n")_ val expr = In( - FunctionInvocation(FunctionName("id")_, variable)_, + UserFunctionInvocation(FunctionName("id")_, variable)_, Variable("arr")_ )_ val qg = QueryGraph( @@ -110,7 +110,7 @@ class IdSeekLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSupp // given match (n) where id(n) in arr val variable: Variable = Variable("n")_ val expr = In( - FunctionInvocation(FunctionName("id")_, variable)_, + UserFunctionInvocation(FunctionName("id")_, variable)_, Variable("arr")_ )_ val qg = QueryGraph( @@ -141,7 +141,7 @@ class IdSeekLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSupp // given match (n) where id(n) in arr val variable: Variable = Variable("n")_ val expr = In( - FunctionInvocation(FunctionName("id")_, variable)_, + UserFunctionInvocation(FunctionName("id")_, variable)_, Variable("arr")_ )_ val qg = QueryGraph( @@ -172,7 +172,7 @@ class IdSeekLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSupp // given val rIdent: Variable = Variable("r")_ val expr = In( - FunctionInvocation(FunctionName("id")_, distinct = false, Array(rIdent))_, + UserFunctionInvocation(FunctionName("id")_, distinct = false, Array(rIdent))_, Collection( Seq(SignedDecimalIntegerLiteral("42")_, SignedDecimalIntegerLiteral("43")_, SignedDecimalIntegerLiteral("43")_) )_ @@ -210,7 +210,7 @@ class IdSeekLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSupp // given val rIdent: Variable = Variable("r")_ val expr = In( - FunctionInvocation(FunctionName("id")_, distinct = false, Array(rIdent))_, + UserFunctionInvocation(FunctionName("id")_, distinct = false, Array(rIdent))_, Collection( Seq(SignedDecimalIntegerLiteral("42")_, SignedDecimalIntegerLiteral("43")_, SignedDecimalIntegerLiteral("43")_) )_ @@ -247,7 +247,7 @@ class IdSeekLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSupp // given val rIdent: Variable = Variable("r")_ val expr = In( - FunctionInvocation(FunctionName("id")_, distinct = false, Array(rIdent))_, + UserFunctionInvocation(FunctionName("id")_, distinct = false, Array(rIdent))_, Collection(Seq(SignedDecimalIntegerLiteral("42")_))_ )_ val from = IdName("from") @@ -283,7 +283,7 @@ class IdSeekLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSupp // then resultPlans should equal( Seq(Selection( - Seq(Equals(FunctionInvocation(FunctionName("type")_, rIdent)_, StringLiteral("X")_)_), + Seq(Equals(UserFunctionInvocation(FunctionName("type")_, rIdent)_, StringLiteral("X")_)_), UndirectedRelationshipByIdSeek(IdName("r"), ManySeekableArgs(Collection(Seq(SignedDecimalIntegerLiteral("42")_))_), from, end, Set.empty)(solved) )(solved)) ) @@ -293,7 +293,7 @@ class IdSeekLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSupp // given val rIdent: Variable = Variable("r")_ val expr = In( - FunctionInvocation(FunctionName("id")_, distinct = false, Array(rIdent))_, + UserFunctionInvocation(FunctionName("id")_, distinct = false, Array(rIdent))_, Collection(Seq(SignedDecimalIntegerLiteral("42")_))_ )_ val from = IdName("from") @@ -332,8 +332,8 @@ class IdSeekLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSupp Seq(Selection( Seq( Ors(Set( - Equals(FunctionInvocation(FunctionName("type")_, rIdent)_, StringLiteral("X")_)(pos), - Equals(FunctionInvocation(FunctionName("type")_, rIdent)_, StringLiteral("Y")_)(pos) + Equals(UserFunctionInvocation(FunctionName("type")_, rIdent)_, StringLiteral("X")_)(pos), + Equals(UserFunctionInvocation(FunctionName("type")_, rIdent)_, StringLiteral("Y")_)(pos) ))_ ), UndirectedRelationshipByIdSeek(IdName("r"), ManySeekableArgs(Collection(Seq(SignedDecimalIntegerLiteral("42")_))_), from, end, Set.empty)(solved) diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/IndexScanLeafPlannerTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/IndexScanLeafPlannerTest.scala index 6a0770e82aac..7ce99bcc7254 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/IndexScanLeafPlannerTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/IndexScanLeafPlannerTest.scala @@ -19,11 +19,10 @@ */ package org.neo4j.cypher.internal.compiler.v3_1.planner.logical.plans -import org.neo4j.cypher.internal.frontend.v3_1.ast._ -import org.neo4j.cypher.internal.frontend.v3_1.ast.functions import org.neo4j.cypher.internal.compiler.v3_1.planner.BeLikeMatcher._ import org.neo4j.cypher.internal.compiler.v3_1.planner._ import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.steps.indexScanLeafPlanner +import org.neo4j.cypher.internal.frontend.v3_1.ast.{functions, _} import org.neo4j.cypher.internal.frontend.v3_1.test_helpers.CypherFunSuite class IndexScanLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSupport2 { @@ -32,7 +31,7 @@ class IndexScanLeafPlannerTest extends CypherFunSuite with LogicalPlanningTestSu val hasLabels: Expression = HasLabels(varFor("n"), Seq(LabelName("Awesome") _)) _ val property: Expression = Property(varFor("n"), PropertyKeyName("prop") _) _ - val existsPredicate: Expression = FunctionInvocation(FunctionName(functions.Exists.name) _, property) _ + val existsPredicate: Expression = UserFunctionInvocation(FunctionName(functions.Exists.name) _, property) _ val startsWithPredicate: Expression = StartsWith(property, StringLiteral("") _) _ val ltPredicate: Expression = LessThan(property, SignedDecimalIntegerLiteral("12") _) _ val neqPredicate: Expression = NotEquals(property, SignedDecimalIntegerLiteral("12") _) _ diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/SargableTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/SargableTest.scala index 3157fc17dc44..35e3c118b387 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/SargableTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/plans/SargableTest.scala @@ -65,7 +65,7 @@ class SargableTest extends CypherFunSuite with AstConstructionTestSupport { } test("IdSeekable works") { - val leftExpr: FunctionInvocation = FunctionInvocation(FunctionName("id") _, nodeA)_ + val leftExpr: UserFunctionInvocation = UserFunctionInvocation(FunctionName("id") _, nodeA)_ Mockito.when(expr2.dependencies).thenReturn(Set.empty[Variable]) val expr: Equals = Equals(leftExpr, expr2) _ @@ -80,7 +80,7 @@ class SargableTest extends CypherFunSuite with AstConstructionTestSupport { } test("IdSeekable does not match if rhs depends on lhs variable") { - val leftExpr: FunctionInvocation = FunctionInvocation(FunctionName("id") _, nodeA)_ + val leftExpr: UserFunctionInvocation = UserFunctionInvocation(FunctionName("id") _, nodeA)_ Mockito.when(expr2.dependencies).thenReturn(Set(nodeA)) val expr: Equals = Equals(leftExpr, expr2) _ @@ -90,7 +90,7 @@ class SargableTest extends CypherFunSuite with AstConstructionTestSupport { } test("IdSeekable does not match if function is not the id function") { - val leftExpr: FunctionInvocation = FunctionInvocation(FunctionName("rand") _, nodeA)_ + val leftExpr: UserFunctionInvocation = UserFunctionInvocation(FunctionName("rand") _, nodeA)_ Mockito.when(expr2.dependencies).thenReturn(Set.empty[Variable]) val expr: Equals = Equals(leftExpr, expr2) _ @@ -143,7 +143,7 @@ class SargableTest extends CypherFunSuite with AstConstructionTestSupport { test("PropertyScannable works") { val propertyExpr: Property = Property(nodeA, PropertyKeyName("name")_)_ - val expr: FunctionInvocation = FunctionInvocation(FunctionName("exists") _, propertyExpr)_ + val expr: UserFunctionInvocation = UserFunctionInvocation(FunctionName("exists") _, propertyExpr)_ assertMatches(expr) { case AsPropertyScannable(scannable) => diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/AggregationTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/AggregationTest.scala index bbbdbb8ef513..0d622050a7a7 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/AggregationTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/AggregationTest.scala @@ -19,16 +19,16 @@ */ package org.neo4j.cypher.internal.compiler.v3_1.planner.logical.steps -import org.neo4j.cypher.internal.frontend.v3_1.ast._ import org.neo4j.cypher.internal.compiler.v3_1.planner._ import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.plans.{Aggregation, LogicalPlan, Projection} +import org.neo4j.cypher.internal.frontend.v3_1.ast._ import org.neo4j.cypher.internal.frontend.v3_1.test_helpers.CypherFunSuite class AggregationTest extends CypherFunSuite with LogicalPlanningTestSupport { val aggregatingMap: Map[String, Expression] = Map("count(*)" -> CountStar()(pos)) val propExp: Expression = Property(varFor("n"), PropertyKeyName("prop")(pos))(pos) - val countExp: Expression = FunctionInvocation(FunctionName("count")(pos), propExp)(pos) + val countExp: Expression = UserFunctionInvocation(FunctionName("count")(pos), propExp)(pos) val aggregatingMap2: Map[String, Expression] = Map("count(n.prop)" -> countExp) val propExp2: Expression = Property(varFor("n"), PropertyKeyName("bar")(pos))(pos) diff --git a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/countStorePlannerTest.scala b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/countStorePlannerTest.scala index 55ad0a2fc6c7..c198f29007d8 100644 --- a/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/countStorePlannerTest.scala +++ b/community/cypher/cypher-compiler-3.1/src/test/scala/org/neo4j/cypher/internal/compiler/v3_1/planner/logical/steps/countStorePlannerTest.scala @@ -19,12 +19,12 @@ */ package org.neo4j.cypher.internal.compiler.v3_1.planner.logical.steps -import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.plans.{RelationshipCountFromCountStore, NodeCountFromCountStore, IdName, LogicalPlan} +import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.plans.{IdName, LogicalPlan, NodeCountFromCountStore, RelationshipCountFromCountStore} import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.{LogicalPlanningContext, Metrics, QueryGraphProducer, QueryGraphSolver} import org.neo4j.cypher.internal.compiler.v3_1.planner.{AggregatingQueryProjection, LogicalPlanningTestSupport} import org.neo4j.cypher.internal.compiler.v3_1.spi.PlanContext import org.neo4j.cypher.internal.frontend.v3_1.SemanticTable -import org.neo4j.cypher.internal.frontend.v3_1.ast.{AstConstructionTestSupport, FunctionInvocation, FunctionName, Variable} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{AstConstructionTestSupport, FunctionName, UserFunctionInvocation, Variable} import org.neo4j.cypher.internal.frontend.v3_1.test_helpers.CypherFunSuite import org.scalatest.matchers.{MatchResult, Matcher} @@ -147,7 +147,7 @@ class countStorePlannerTest extends CypherFunSuite with LogicalPlanningTestSuppo def producePlannerQuery(query: String, variable: String) = { val (pq, _) = producePlannerQueryForPattern(query) pq.withHorizon(AggregatingQueryProjection( - aggregationExpressions = Map(s"count($variable)" -> FunctionInvocation(FunctionName("count") _, Variable(variable) _) _))) + aggregationExpressions = Map(s"count($variable)" -> UserFunctionInvocation(FunctionName("count") _, Variable(variable) _) _))) } case class IsCountPlan(variable: String, noneExpected: Boolean) extends Matcher[Option[LogicalPlan]] { diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/ExceptionTranslatingPlanContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/ExceptionTranslatingPlanContext.scala index effaa611a555..5a291282392f 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/ExceptionTranslatingPlanContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/ExceptionTranslatingPlanContext.scala @@ -51,7 +51,7 @@ class ExceptionTranslatingPlanContext(inner: PlanContext) extends PlanContext wi override def procedureSignature(name: QualifiedName): ProcedureSignature = translateException(inner.procedureSignature(name)) - override def functionSignature(name: QualifiedName): Option[UserDefinedFunctionSignature] = + override def functionSignature(name: QualifiedName): Option[UserFunctionSignature] = translateException(inner.functionSignature(name)) override def hasIndexRule(labelName: String): Boolean = diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundPlanContext.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundPlanContext.scala index 277548996c16..92fb33d129f2 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundPlanContext.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_1/TransactionBoundPlanContext.scala @@ -142,7 +142,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapperv3_1) ProcedureSignature(name, input, output, deprecationInfo, mode) } - override def functionSignature(name: QualifiedName): Option[UserDefinedFunctionSignature] = { + override def functionSignature(name: QualifiedName): Option[UserFunctionSignature] = { val kn = new KernelQualifiedName(name.namespace.asJava, name.name) val maybeFunction = tc.statement.readOperations().functionGet(kn) if (maybeFunction.isPresent) { @@ -153,7 +153,7 @@ class TransactionBoundPlanContext(tc: TransactionalContextWrapperv3_1) val output = asCypherType(ks.outputType()) val deprecationInfo = asOption(ks.deprecated()) - Some(UserDefinedFunctionSignature(name, input, output, deprecationInfo, ProcedureReadOnlyAccess(ks.allowed()))) + Some(UserFunctionSignature(name, input, output, deprecationInfo, ProcedureReadOnlyAccess(ks.allowed()))) } else None } diff --git a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/GraphDatabaseTestSupport.scala b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/GraphDatabaseTestSupport.scala index 5ed63b8e6eb1..c3236a8b35f7 100644 --- a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/GraphDatabaseTestSupport.scala +++ b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/GraphDatabaseTestSupport.scala @@ -32,7 +32,7 @@ import org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService import org.neo4j.graphdb._ import org.neo4j.graphdb.config.Setting import org.neo4j.kernel.api.KernelAPI -import org.neo4j.kernel.api.proc.{FunctionSignature, CallableFunction, CallableProcedure, ProcedureSignature} +import org.neo4j.kernel.api.proc.{CallableProcedure, CallableUserFunction, ProcedureSignature, UserFunctionSignature} import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge import org.neo4j.kernel.monitoring import org.neo4j.test.TestGraphDatabaseFactory @@ -229,17 +229,17 @@ trait GraphDatabaseTestSupport extends CypherTestSupport with GraphIcing { proc } - def registerFunction[T <: CallableFunction](qualifiedName: String)(f: FunctionSignature.Builder => T): T = { + def registerUserDefinedFunction[T <: CallableUserFunction](qualifiedName: String)(f: UserFunctionSignature.Builder => T): T = { val parts = qualifiedName.split('.') val namespace = parts.reverse.tail.reverse val name = parts.last - registerFunction(namespace: _*)(name)(f) + registerUserFunction(namespace: _*)(name)(f) } - def registerFunction[T <: CallableFunction](namespace: String*)(name: String)(f: FunctionSignature.Builder => T): T = { - val builder = FunctionSignature.functionSignature(namespace.toArray, name) + def registerUserFunction[T <: CallableUserFunction](namespace: String*)(name: String)(f: UserFunctionSignature.Builder => T): T = { + val builder = UserFunctionSignature.functionSignature(namespace.toArray, name) val func = f(builder) - kernelAPI.registerFunction(func) + kernelAPI.registerUserFunction(func) func } diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/Clause.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/Clause.scala index b74f65809473..a8f940e73678 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/Clause.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/Clause.scala @@ -139,7 +139,7 @@ case class Match(optional: Boolean, pattern: Pattern, hints: Seq[UsingHint], whe acc => (acc :+ name, None) case In(Property(Variable(id), PropertyKeyName(name)),_) if id == variable => acc => (acc :+ name, None) - case predicate@FunctionInvocation(_, _, _, IndexedSeq(Property(Variable(id), PropertyKeyName(name)))) + case predicate@UserFunctionInvocation(_, _, _, IndexedSeq(Property(Variable(id), PropertyKeyName(name)))) if id == variable && predicate.function == functions.Exists => acc => (acc :+ name, None) case IsNotNull(Property(Variable(id), PropertyKeyName(name))) if id == variable => @@ -181,7 +181,7 @@ case class Match(optional: Boolean, pattern: Pattern, hints: Seq[UsingHint], whe private def applicable(other: Expression) = { other match { case _: Property => false - case f: FunctionInvocation => f.function != functions.Id + case f: UserFunctionInvocation => f.function != functions.Id case _ => true } } diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/Function.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/Function.scala index d222c8adec7b..9032e6320b45 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/Function.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/Function.scala @@ -103,23 +103,23 @@ object Function { abstract class Function extends SemanticChecking { def name: String - def semanticCheckHook(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation): SemanticCheck = + def semanticCheckHook(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation): SemanticCheck = when(invocation.distinct) { SemanticError(s"Invalid use of DISTINCT with function '$name'", invocation.position) } chain invocation.arguments.semanticCheck(ctx) chain semanticCheck(ctx, invocation) - protected def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation): SemanticCheck + protected def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation): SemanticCheck - protected def checkArgs(invocation: ast.FunctionInvocation, n: Int): Option[SemanticError] = + protected def checkArgs(invocation: ast.UserFunctionInvocation, n: Int): Option[SemanticError] = Vector(checkMinArgs(invocation, n), checkMaxArgs(invocation, n)).flatten.headOption - protected def checkMaxArgs(invocation: ast.FunctionInvocation, n: Int): Option[SemanticError] = + protected def checkMaxArgs(invocation: ast.UserFunctionInvocation, n: Int): Option[SemanticError] = if (invocation.arguments.length > n) Some(SemanticError(s"Too many parameters for function '$name'", invocation.position)) else None - protected def checkMinArgs(invocation: ast.FunctionInvocation, n: Int): Option[SemanticError] = + protected def checkMinArgs(invocation: ast.UserFunctionInvocation, n: Int): Option[SemanticError] = if (invocation.arguments.length < n) Some(SemanticError(s"Insufficient parameters for function '$name'", invocation.position)) else @@ -127,11 +127,11 @@ abstract class Function extends SemanticChecking { def asFunctionName(implicit position: InputPosition) = FunctionName(name)(position) - def asInvocation(argument: ast.Expression, distinct: Boolean = false)(implicit position: InputPosition): FunctionInvocation = - FunctionInvocation(asFunctionName, distinct = distinct, IndexedSeq(argument))(position) + def asInvocation(argument: ast.Expression, distinct: Boolean = false)(implicit position: InputPosition): UserFunctionInvocation = + UserFunctionInvocation(asFunctionName, distinct = distinct, IndexedSeq(argument))(position) - def asInvocation(lhs: ast.Expression, rhs: ast.Expression)(implicit position: InputPosition): FunctionInvocation = - FunctionInvocation(asFunctionName, distinct = false, IndexedSeq(lhs, rhs))(position) + def asInvocation(lhs: ast.Expression, rhs: ast.Expression)(implicit position: InputPosition): UserFunctionInvocation = + UserFunctionInvocation(asFunctionName, distinct = false, IndexedSeq(lhs, rhs))(position) } @@ -142,11 +142,11 @@ trait SimpleTypedFunction { self: Function => private lazy val signatureLengths = signatures.map(_.argumentTypes.length) - def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation): SemanticCheck = + def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation): SemanticCheck = checkMinArgs(invocation, signatureLengths.min) chain checkMaxArgs(invocation, signatureLengths.max) chain checkTypes(invocation) - private def checkTypes(invocation: ast.FunctionInvocation): SemanticCheck = s => { + private def checkTypes(invocation: ast.UserFunctionInvocation): SemanticCheck = s => { val initSignatures = signatures.filter(_.argumentTypes.length == invocation.arguments.length) val (remainingSignatures: Seq[Signature], result) = invocation.arguments.foldLeft((initSignatures, SemanticCheckResult.success(s))) { @@ -178,7 +178,7 @@ trait SimpleTypedFunction { self: Function => abstract class AggregatingFunction extends Function { - override def semanticCheckHook(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation): SemanticCheck = + override def semanticCheckHook(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation): SemanticCheck = when(ctx == ast.Expression.SemanticContext.Simple) { SemanticError(s"Invalid use of aggregating function $name(...) in this context", invocation.position) } chain invocation.arguments.semanticCheck(ctx) chain semanticCheck(ctx, invocation) diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/IsAggregate.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/IsAggregate.scala index f070a7980c05..29c17d13d48f 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/IsAggregate.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/IsAggregate.scala @@ -25,10 +25,10 @@ object IsAggregate { case expr: CountStar => Some(expr) - case fi: FunctionInvocation if fi.distinct => + case fi: UserFunctionInvocation if fi.distinct => Some(fi) - case fi: FunctionInvocation => + case fi: UserFunctionInvocation => fi.function match { case fun: AggregatingFunction => Some(fi) case _ => None diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/FunctionInvocation.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/UserFunctionInvocation.scala similarity index 64% rename from community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/FunctionInvocation.scala rename to community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/UserFunctionInvocation.scala index 24e657576128..530a6e07b7f4 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/FunctionInvocation.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/UserFunctionInvocation.scala @@ -19,23 +19,23 @@ */ package org.neo4j.cypher.internal.frontend.v3_1.ast +import org.neo4j.cypher.internal.frontend.v3_1.InputPosition import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext import org.neo4j.cypher.internal.frontend.v3_1.ast.functions.UnresolvedFunction -import org.neo4j.cypher.internal.frontend.v3_1.{InputPosition, _} -object FunctionInvocation { - def apply(name: FunctionName, argument: Expression)(position: InputPosition): FunctionInvocation = - FunctionInvocation(Namespace()(position), name, distinct = false, IndexedSeq(argument))(position) - def apply(left: Expression, name: FunctionName, right: Expression): FunctionInvocation = - FunctionInvocation(Namespace()(name.position), name, distinct = false, IndexedSeq(left, right))(name.position) - def apply(expression: Expression, name: FunctionName): FunctionInvocation = - FunctionInvocation(Namespace()(name.position), name, distinct = false, IndexedSeq(expression))(name.position) - def apply(functionName: FunctionName, distinct: Boolean, args: IndexedSeq[Expression])(position: InputPosition): FunctionInvocation = - FunctionInvocation(Namespace()(position), functionName, distinct, args)(position) +object UserFunctionInvocation { + def apply(name: FunctionName, argument: Expression)(position: InputPosition): UserFunctionInvocation = + UserFunctionInvocation(Namespace()(position), name, distinct = false, IndexedSeq(argument))(position) + def apply(left: Expression, name: FunctionName, right: Expression): UserFunctionInvocation = + UserFunctionInvocation(Namespace()(name.position), name, distinct = false, IndexedSeq(left, right))(name.position) + def apply(expression: Expression, name: FunctionName): UserFunctionInvocation = + UserFunctionInvocation(Namespace()(name.position), name, distinct = false, IndexedSeq(expression))(name.position) + def apply(functionName: FunctionName, distinct: Boolean, args: IndexedSeq[Expression])(position: InputPosition): UserFunctionInvocation = + UserFunctionInvocation(Namespace()(position), functionName, distinct, args)(position) } -case class FunctionInvocation(namespace: Namespace, functionName: FunctionName, distinct: Boolean, args: IndexedSeq[Expression]) - (val position: InputPosition) extends Expression { +case class UserFunctionInvocation(namespace: Namespace, functionName: FunctionName, distinct: Boolean, args: IndexedSeq[Expression]) + (val position: InputPosition) extends Expression { val name = functionName.name val function = Function.lookup.getOrElse(name.toLowerCase, UnresolvedFunction) diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Coalesce.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Coalesce.scala index 1393ebf8d67c..cfbf0e33dc7a 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Coalesce.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Coalesce.scala @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.frontend.v3_1.symbols._ case object Coalesce extends Function { def name = "coalesce" - def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation) = + def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation) = checkMinArgs(invocation, 1) chain invocation.arguments.expectType(CTAny.covariant) chain invocation.specifyType(invocation.arguments.leastUpperBoundsOfTypes) diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Collect.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Collect.scala index f59d0e2b443b..c43d24d6e391 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Collect.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Collect.scala @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.frontend.v3_1.symbols._ case object Collect extends AggregatingFunction { def name = "collect" - def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation) = + def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation) = checkArgs(invocation, 1) ifOkChain { invocation.arguments(0).expectType(CTAny.covariant) chain invocation.specifyType(invocation.arguments(0).types(_).wrapInList) diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Exists.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Exists.scala index 9e1d41cabbdc..1c3f180370d7 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Exists.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Exists.scala @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.frontend.v3_1.{SemanticError, ast} case object Exists extends Function { def name = "EXISTS" - def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation) = + def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation) = checkArgs(invocation, 1) ifOkChain { invocation.arguments.head.expectType(CTAny.covariant) chain (invocation.arguments.head match { diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Has.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Has.scala index 30fa6c55d4b5..261ea4dde50d 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Has.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Has.scala @@ -19,8 +19,7 @@ */ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions -import org.neo4j.cypher.internal.frontend.v3_1.ast.{ContainerIndex, Function} -import org.neo4j.cypher.internal.frontend.v3_1.symbols._ +import org.neo4j.cypher.internal.frontend.v3_1.ast.Function import org.neo4j.cypher.internal.frontend.v3_1.{SemanticError, ast} /* @@ -30,6 +29,6 @@ import org.neo4j.cypher.internal.frontend.v3_1.{SemanticError, ast} case object Has extends Function { def name = "HAS" - def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation) = + def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation) = SemanticError(s"HAS is no longer supported in Cypher, please use EXISTS instead", invocation.position) } diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Head.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Head.scala index fd69ca0a4b0d..84b512e62ac8 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Head.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Head.scala @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.frontend.v3_1.{TypeGenerator, ast} case object Head extends Function { def name = "head" - def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation) = + def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation) = checkArgs(invocation, 1) ifOkChain { invocation.arguments.head.expectType(CTList(CTAny).covariant) chain invocation.specifyType(possibleInnerTypes(invocation.arguments.head)) diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Labels.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Labels.scala index 75e0aae28c80..6a89529bfddf 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Labels.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Labels.scala @@ -20,20 +20,20 @@ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext -import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, FunctionInvocation} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.symbols._ import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheckResult, SemanticError, SemanticState, _} case object Labels extends Function { def name = "labels" - override protected def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation): SemanticCheck = + override protected def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation): SemanticCheck = checkMinArgs(invocation, 1) ifOkChain checkMaxArgs(invocation, 1) ifOkChain checkTypeOfArgument(invocation) ifOkChain invocation.specifyType(CTList(CTString)) - private def checkTypeOfArgument(invocation: FunctionInvocation): SemanticCheck = (s: SemanticState) => { + private def checkTypeOfArgument(invocation: UserFunctionInvocation): SemanticCheck = (s: SemanticState) => { val e = invocation.args.head s.expressionType(e).specified match { diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Last.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Last.scala index dbbf89bbb940..00772bb912a5 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Last.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Last.scala @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheck, TypeGenerator, as case object Last extends Function { def name = "last" - def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation): SemanticCheck = + def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation): SemanticCheck = checkArgs(invocation, 1) ifOkChain { invocation.arguments.head.expectType(CTList(CTAny).covariant) chain invocation.specifyType(possibleInnerTypes(invocation.arguments.head)) diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Length.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Length.scala index 22494c244eca..51acff6fbabc 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Length.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Length.scala @@ -19,11 +19,11 @@ */ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions -import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheckResult, SemanticState} import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext -import org.neo4j.cypher.internal.frontend.v3_1.ast.{FunctionInvocation, Function, SimpleTypedFunction} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, SimpleTypedFunction, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.notification.LengthOnNonPathNotification import org.neo4j.cypher.internal.frontend.v3_1.symbols._ +import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheckResult, SemanticState} case object Length extends Function with SimpleTypedFunction { def name = "length" @@ -35,10 +35,10 @@ case object Length extends Function with SimpleTypedFunction { Signature(Vector(CTPath), CTInteger) ) - override def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation) = + override def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation) = super.semanticCheck(ctx, invocation) chain checkForInvalidUsage(ctx, invocation) - def checkForInvalidUsage(ctx: SemanticContext, invocation: FunctionInvocation) = (originalState: SemanticState) => { + def checkForInvalidUsage(ctx: SemanticContext, invocation: UserFunctionInvocation) = (originalState: SemanticState) => { val newState = invocation.args.foldLeft(originalState) { case (state, expr) if state.expressionType(expr).actual != CTPath.invariant => state.addNotification(LengthOnNonPathNotification(expr.position)) diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Max.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Max.scala index e3d67289f6b3..ef8a65765c34 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Max.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Max.scala @@ -20,7 +20,7 @@ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext -import org.neo4j.cypher.internal.frontend.v3_1.ast.{AggregatingFunction, FunctionInvocation} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{AggregatingFunction, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.symbols._ import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheck, SemanticCheckResult, SemanticError, SemanticState} @@ -28,13 +28,13 @@ case object Max extends AggregatingFunction { def name = "max" - override protected def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation): SemanticCheck = + override protected def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation): SemanticCheck = checkMinArgs(invocation, 1) ifOkChain checkMaxArgs(invocation, 1) ifOkChain checkTypeOfArgument(invocation) ifOkChain invocation.specifyType(invocation.args.head.types) - private def checkTypeOfArgument(invocation: FunctionInvocation): SemanticCheck = (s: SemanticState) => { + private def checkTypeOfArgument(invocation: UserFunctionInvocation): SemanticCheck = (s: SemanticState) => { val argument = invocation.args.head val specifiedType = s.expressionType(argument).specified val correctType = Seq(CTFloat, CTInteger, CTString, CTNumber, CTAny).foldLeft(false) { diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Min.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Min.scala index a3228a26e258..de3e7f85ce47 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Min.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Min.scala @@ -20,20 +20,20 @@ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext -import org.neo4j.cypher.internal.frontend.v3_1.ast.{AggregatingFunction, FunctionInvocation} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{AggregatingFunction, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.symbols._ import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheck, SemanticCheckResult, SemanticError, SemanticState} case object Min extends AggregatingFunction { def name = "min" - override protected def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation): SemanticCheck = + override protected def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation): SemanticCheck = checkMinArgs(invocation, 1) ifOkChain checkMaxArgs(invocation, 1) ifOkChain checkTypeOfArgument(invocation) ifOkChain invocation.specifyType(invocation.args.head.types) - private def checkTypeOfArgument(invocation: FunctionInvocation): SemanticCheck = (s: SemanticState) => { + private def checkTypeOfArgument(invocation: UserFunctionInvocation): SemanticCheck = (s: SemanticState) => { val argument = invocation.args.head val specifiedType = s.expressionType(argument).specified val correctType = Seq(CTFloat, CTInteger, CTString, CTNumber, CTAny).foldLeft(false) { diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/PercentileCont.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/PercentileCont.scala index 3877f0e3fec2..59fbe15c7702 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/PercentileCont.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/PercentileCont.scala @@ -20,7 +20,7 @@ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext -import org.neo4j.cypher.internal.frontend.v3_1.ast.{AggregatingFunction, FunctionInvocation, SimpleTypedFunction} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{AggregatingFunction, SimpleTypedFunction, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.symbols._ case object PercentileCont extends AggregatingFunction with SimpleTypedFunction { @@ -29,6 +29,6 @@ case object PercentileCont extends AggregatingFunction with SimpleTypedFunction val signatures = Vector( Signature(argumentTypes = Vector(CTFloat, CTFloat), outputType = CTFloat) ) - override def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation) = + override def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation) = super.semanticCheck(ctx, invocation) ifOkChain checkPercentileRange(invocation.args(1)) } diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/PercentileDisc.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/PercentileDisc.scala index 29650f23921a..b0f7db172435 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/PercentileDisc.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/PercentileDisc.scala @@ -20,9 +20,8 @@ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext -import org.neo4j.cypher.internal.frontend.v3_1.ast.{Parameter, AggregatingFunction, DoubleLiteral, FunctionInvocation, Literal, SimpleTypedFunction} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{AggregatingFunction, SimpleTypedFunction, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.symbols._ -import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheck, SemanticCheckResult, SemanticError} case object PercentileDisc extends AggregatingFunction with SimpleTypedFunction { def name = "percentileDisc" @@ -32,6 +31,6 @@ case object PercentileDisc extends AggregatingFunction with SimpleTypedFunction Signature(argumentTypes = Vector(CTFloat, CTFloat), outputType = CTFloat) ) - override def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation) = + override def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation) = super.semanticCheck(ctx, invocation) ifOkChain checkPercentileRange(invocation.args(1)) } diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Point.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Point.scala index f9262c133a89..997805c6d7b6 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Point.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Point.scala @@ -28,7 +28,7 @@ case object Point extends Function with SimpleTypedFunction { override def name = "point" - override def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation) = + override def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation) = super.semanticCheck(ctx, invocation) ifOkChain checkPointMap(invocation.args(0)) /* diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Reduce.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Reduce.scala index 620982a388a8..45888996d118 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Reduce.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Reduce.scala @@ -27,9 +27,9 @@ import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheck, SemanticError, as case object Reduce extends Function { def name = "reduce" - override def semanticCheckHook(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation): SemanticCheck = + override def semanticCheckHook(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation): SemanticCheck = semanticCheck(ctx, invocation) - def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation): SemanticCheck = + def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation): SemanticCheck = SemanticError(s"${name}(...) requires '| expression' (an accumulation expression)", invocation.position) } diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Tail.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Tail.scala index 99a8a69aacb9..2cb1b7e75ea1 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Tail.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Tail.scala @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.frontend.v3_1.symbols._ case object Tail extends Function { def name = "tail" - def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.FunctionInvocation) = + def semanticCheck(ctx: ast.Expression.SemanticContext, invocation: ast.UserFunctionInvocation) = checkArgs(invocation, 1) ifOkChain { invocation.arguments(0).expectType(CTList(CTAny).covariant) chain invocation.specifyType(invocation.arguments(0).types) diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToBoolean.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToBoolean.scala index e18a731f7e33..5590a593efbc 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToBoolean.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToBoolean.scala @@ -20,7 +20,7 @@ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext -import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, FunctionInvocation} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.symbols._ import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheck, SemanticCheckResult, SemanticError, SemanticState} @@ -28,13 +28,13 @@ case object ToBoolean extends Function { def name = "toBoolean" - override protected def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation): SemanticCheck = + override protected def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation): SemanticCheck = checkMinArgs(invocation, 1) ifOkChain checkMaxArgs(invocation, 1) ifOkChain checkTypeOfArgument(invocation) ifOkChain invocation.specifyType(CTBoolean) - private def checkTypeOfArgument(invocation: FunctionInvocation): SemanticCheck = (s: SemanticState) => { + private def checkTypeOfArgument(invocation: UserFunctionInvocation): SemanticCheck = (s: SemanticState) => { val argument = invocation.args.head val specifiedType = s.expressionType(argument).specified val correctType = Seq(CTString, CTBoolean, CTAny).foldLeft(false) { diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToFloat.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToFloat.scala index e521a634838a..eab7ad4ac73d 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToFloat.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToFloat.scala @@ -19,21 +19,21 @@ */ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions -import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheckResult, SemanticError, SemanticState, _} import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext -import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, FunctionInvocation} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.symbols._ +import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheckResult, SemanticError, SemanticState, _} case object ToFloat extends Function { def name = "toFloat" - override protected def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation): SemanticCheck = + override protected def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation): SemanticCheck = checkMinArgs(invocation, 1) ifOkChain checkMaxArgs(invocation, 1) ifOkChain checkTypeOfArgument(invocation) ifOkChain invocation.specifyType(CTFloat) - private def checkTypeOfArgument(invocation: FunctionInvocation): SemanticCheck = (s: SemanticState) => { + private def checkTypeOfArgument(invocation: UserFunctionInvocation): SemanticCheck = (s: SemanticState) => { val e = invocation.args.head s.expressionType(e).specified match { diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToInteger.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToInteger.scala index c760dee75ccb..bac9cf46c5e8 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToInteger.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToInteger.scala @@ -20,7 +20,7 @@ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext -import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, FunctionInvocation} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.symbols._ import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheck, SemanticCheckResult, SemanticError, SemanticState} @@ -28,13 +28,13 @@ case object ToInteger extends Function { def name = "toInteger" - override protected def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation): SemanticCheck = + override protected def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation): SemanticCheck = checkMinArgs(invocation, 1) ifOkChain checkMaxArgs(invocation, 1) ifOkChain checkTypeOfArgument(invocation) ifOkChain invocation.specifyType(CTInteger) - private def checkTypeOfArgument(invocation: FunctionInvocation): SemanticCheck = (s: SemanticState) => { + private def checkTypeOfArgument(invocation: UserFunctionInvocation): SemanticCheck = (s: SemanticState) => { val e = invocation.args.head s.expressionType(e).specified match { diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToString.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToString.scala index 2ce11a8ea1ba..faa9e040bd4d 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToString.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/ToString.scala @@ -20,20 +20,20 @@ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext -import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, FunctionInvocation} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.symbols._ import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheck, SemanticCheckResult, SemanticError, SemanticState} case object ToString extends Function { override def name = "toString" - override protected def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation): SemanticCheck = + override protected def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation): SemanticCheck = checkMinArgs(invocation, 1) ifOkChain checkMaxArgs(invocation, 1) ifOkChain checkTypeOfArgument(invocation) ifOkChain invocation.specifyType(CTString) - private def checkTypeOfArgument(invocation: FunctionInvocation): SemanticCheck = (s: SemanticState) => { + private def checkTypeOfArgument(invocation: UserFunctionInvocation): SemanticCheck = (s: SemanticState) => { val e = invocation.args.head s.expressionType(e).specified match { diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Type.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Type.scala index 66f4909d8ef5..a80ae3469d87 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Type.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/Type.scala @@ -20,20 +20,20 @@ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext -import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, FunctionInvocation} +import org.neo4j.cypher.internal.frontend.v3_1.ast.{Function, UserFunctionInvocation} import org.neo4j.cypher.internal.frontend.v3_1.symbols._ import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheckResult, SemanticError, SemanticState, _} case object Type extends Function { def name = "type" - override protected def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation): SemanticCheck = + override protected def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation): SemanticCheck = checkMinArgs(invocation, 1) ifOkChain checkMaxArgs(invocation, 1) ifOkChain checkTypeOfArgument(invocation) ifOkChain invocation.specifyType(CTString) - private def checkTypeOfArgument(invocation: FunctionInvocation): SemanticCheck = (s: SemanticState) => { + private def checkTypeOfArgument(invocation: UserFunctionInvocation): SemanticCheck = (s: SemanticState) => { val e = invocation.args.head s.expressionType(e).specified match { diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/UnresolvedFunction.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/UnresolvedFunction.scala index 61da6d08e346..e3cf0754d7f1 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/UnresolvedFunction.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/UnresolvedFunction.scala @@ -19,13 +19,13 @@ */ package org.neo4j.cypher.internal.frontend.v3_1.ast.functions +import org.neo4j.cypher.internal.frontend.v3_1.SemanticCheckResult import org.neo4j.cypher.internal.frontend.v3_1.ast.Expression.SemanticContext import org.neo4j.cypher.internal.frontend.v3_1.ast._ -import org.neo4j.cypher.internal.frontend.v3_1.{SemanticCheckResult, InputPosition, SemanticError} case object UnresolvedFunction extends Function { def name = "UNKNOWN" //we cannot do a full semantic check until we have resolved the function call. - override protected def semanticCheck(ctx: SemanticContext, invocation: FunctionInvocation) = SemanticCheckResult.success + override protected def semanticCheck(ctx: SemanticContext, invocation: UserFunctionInvocation) = SemanticCheckResult.success } diff --git a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/parser/Expressions.scala b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/parser/Expressions.scala index 328b37b186b5..049a60eef5d3 100644 --- a/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/parser/Expressions.scala +++ b/community/cypher/frontend-3.1/src/main/scala/org/neo4j/cypher/internal/frontend/v3_1/parser/Expressions.scala @@ -193,11 +193,11 @@ trait Expressions extends Parser private def IdInColl: Rule2[ast.Variable, ast.Expression] = Variable ~~ keyword("IN") ~~ Expression - def FunctionInvocation: Rule1[ast.FunctionInvocation] = rule("a function") { + def FunctionInvocation: Rule1[ast.UserFunctionInvocation] = rule("a function") { ((group(Namespace ~~ FunctionName ~~ "(" ~~ (keyword("DISTINCT") ~ push(true) | EMPTY ~ push(false)) ~~ zeroOrMore(Expression, separator = CommaSep) ~~ ")" - ) ~~> (_.toIndexedSeq)) memoMismatches) ~~>> (ast.FunctionInvocation(_, _, _, _)) + ) ~~> (_.toIndexedSeq)) memoMismatches) ~~>> (ast.UserFunctionInvocation(_, _, _, _)) } def ListComprehension: Rule1[ast.ListComprehension] = rule("[") { diff --git a/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/ExpressionTest.scala b/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/ExpressionTest.scala index abe89403dfd2..47905bbb10e5 100644 --- a/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/ExpressionTest.scala +++ b/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/ExpressionTest.scala @@ -94,7 +94,7 @@ class ExpressionTest extends CypherFunSuite with AstConstructionTestSupport { varFor("x"), PatternExpression(pat), None, - Some(FunctionInvocation(FunctionName("head")_, FunctionInvocation(FunctionName("nodes")_, varFor("x"))_)_) + Some(UserFunctionInvocation(FunctionName("head")_, UserFunctionInvocation(FunctionName("nodes")_, varFor("x"))_)_) )_ expr.dependencies should equal(Set(varFor("n"), varFor("k"))) @@ -171,8 +171,8 @@ class ExpressionTest extends CypherFunSuite with AstConstructionTestSupport { )_ )_) - val callNodes: Expression = FunctionInvocation(FunctionName("nodes") _, varFor("x"))_ - val callHead: Expression = FunctionInvocation(FunctionName("head") _, callNodes) _ + val callNodes: Expression = UserFunctionInvocation(FunctionName("nodes") _, varFor("x"))_ + val callHead: Expression = UserFunctionInvocation(FunctionName("head") _, callNodes) _ // extract(x IN (n)-->(k) | head(nodes(x)) ) val expr: Expression = ExtractExpression( diff --git a/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/IsAggregateTest.scala b/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/IsAggregateTest.scala index 84b9dfbfa870..ff9150d8c018 100644 --- a/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/IsAggregateTest.scala +++ b/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/IsAggregateTest.scala @@ -30,19 +30,19 @@ class IsAggregateTest extends CypherFunSuite with AstConstructionTestSupport { } test("max(null) is an aggregate expression") { - val expr: Expression = FunctionInvocation(FunctionName("max")_, Null()_)_ + val expr: Expression = UserFunctionInvocation(FunctionName("max")_, Null()_)_ IsAggregate.unapply(expr) should equal(Some(expr)) } test("distinct id(null) an aggregate expression") { - val expr: Expression = FunctionInvocation(Namespace()_, FunctionName("id")_, distinct = true, Vector(Null()_))(pos) + val expr: Expression = UserFunctionInvocation(Namespace()_, FunctionName("id")_, distinct = true, Vector(Null()_))(pos) IsAggregate.unapply(expr) should equal(Some(expr)) } test("id(null) is not an aggregate expression") { - val expr: Expression = FunctionInvocation(Namespace()_, FunctionName("id")_, distinct = false, Vector(Null()_))(pos) + val expr: Expression = UserFunctionInvocation(Namespace()_, FunctionName("id")_, distinct = false, Vector(Null()_))(pos) IsAggregate.unapply(expr) should equal(None) } diff --git a/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/FunctionTestBase.scala b/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/FunctionTestBase.scala index 36c885e300cf..6527d3d51bdc 100644 --- a/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/FunctionTestBase.scala +++ b/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/ast/functions/FunctionTestBase.scala @@ -41,10 +41,10 @@ abstract class FunctionTestBase(funcName: String) extends CypherFunSuite { result.errors.head.msg should equal(message) } - protected def evaluateWithTypes(argumentTypes: IndexedSeq[TypeSpec]): (SemanticCheckResult, ast.FunctionInvocation) = { + protected def evaluateWithTypes(argumentTypes: IndexedSeq[TypeSpec]): (SemanticCheckResult, ast.UserFunctionInvocation) = { val arguments = argumentTypes.map(DummyExpression(_)) - val invocation = ast.FunctionInvocation( + val invocation = ast.UserFunctionInvocation( ast.FunctionName(funcName)(DummyPosition(6)), distinct = false, arguments diff --git a/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/parser/FunctionInvocationParserTest.scala b/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/parser/FunctionInvocationParserTest.scala index f3822b5970b6..7dee9e8dc14c 100644 --- a/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/parser/FunctionInvocationParserTest.scala +++ b/community/cypher/frontend-3.1/src/test/scala/org/neo4j/cypher/internal/frontend/v3_1/parser/FunctionInvocationParserTest.scala @@ -22,7 +22,7 @@ package org.neo4j.cypher.internal.frontend.v3_1.parser import org.neo4j.cypher.internal.frontend.v3_1.{DummyPosition, ast} class FunctionInvocationParserTest - extends ParserAstTest[ast.FunctionInvocation] + extends ParserAstTest[ast.UserFunctionInvocation] with Expressions with Literals with Base @@ -31,11 +31,11 @@ class FunctionInvocationParserTest implicit val parser = FunctionInvocation test("foo()") { - yields(ast.FunctionInvocation(ast.Namespace()(pos), ast.FunctionName("foo")(pos), distinct = false, Vector.empty)) + yields(ast.UserFunctionInvocation(ast.Namespace()(pos), ast.FunctionName("foo")(pos), distinct = false, Vector.empty)) } test("foo('test', 1 + 2)") { - yields(ast.FunctionInvocation(ast.Namespace()(pos), ast.FunctionName("foo")(pos), distinct = false, Vector( + yields(ast.UserFunctionInvocation(ast.Namespace()(pos), ast.FunctionName("foo")(pos), distinct = false, Vector( ast.StringLiteral("test")(pos), ast.Add( ast.SignedDecimalIntegerLiteral("1")(pos), @@ -43,11 +43,11 @@ class FunctionInvocationParserTest ))) } test("my.namespace.foo()") { - yields(ast.FunctionInvocation(ast.Namespace(List("my", "namespace"))(pos), ast.FunctionName("foo")(pos), distinct = false, Vector.empty)) + yields(ast.UserFunctionInvocation(ast.Namespace(List("my", "namespace"))(pos), ast.FunctionName("foo")(pos), distinct = false, Vector.empty)) } test("my.namespace.foo('test', 1 + 2)") { - yields(ast.FunctionInvocation(ast.Namespace(List("my", "namespace"))(pos), ast.FunctionName("foo")(pos), distinct = false, Vector( + yields(ast.UserFunctionInvocation(ast.Namespace(List("my", "namespace"))(pos), ast.FunctionName("foo")(pos), distinct = false, Vector( ast.StringLiteral("test")(pos), ast.Add( ast.SignedDecimalIntegerLiteral("1")(pos), diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/KernelAPI.java b/community/kernel/src/main/java/org/neo4j/kernel/api/KernelAPI.java index 55f5335c940e..514eec681c0a 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/KernelAPI.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/KernelAPI.java @@ -21,8 +21,8 @@ import org.neo4j.kernel.api.exceptions.ProcedureException; import org.neo4j.kernel.api.exceptions.TransactionFailureException; -import org.neo4j.kernel.api.proc.CallableFunction; import org.neo4j.kernel.api.proc.CallableProcedure; +import org.neo4j.kernel.api.proc.CallableUserFunction; import org.neo4j.kernel.api.security.AccessMode; /** @@ -84,5 +84,5 @@ KernelTransaction newTransaction( KernelTransaction.Type type, AccessMode access * * @param function function to register */ - void registerFunction( CallableFunction function ) throws ProcedureException; + void registerUserFunction( CallableUserFunction function ) throws ProcedureException; } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java b/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java index 8e4fb2eb0fe7..260a0e3ee11e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/ReadOperations.java @@ -45,9 +45,9 @@ import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException; import org.neo4j.kernel.api.index.IndexDescriptor; import org.neo4j.kernel.api.index.InternalIndexState; -import org.neo4j.kernel.api.proc.FunctionSignature; import org.neo4j.kernel.api.proc.ProcedureSignature; import org.neo4j.kernel.api.proc.QualifiedName; +import org.neo4j.kernel.api.proc.UserFunctionSignature; import org.neo4j.kernel.impl.api.RelationshipVisitor; import org.neo4j.kernel.impl.api.store.RelationshipIterator; import org.neo4j.register.Register.DoubleLongRegister; @@ -558,7 +558,7 @@ DoubleLongRegister indexSample( IndexDescriptor index, DoubleLongRegister target ProcedureSignature procedureGet( QualifiedName name ) throws ProcedureException; /** Fetch a function given its signature, or empty if no such function exists*/ - Optional functionGet( QualifiedName name ); + Optional functionGet( QualifiedName name ); /** Fetch all registered procedures */ Set proceduresGetAll(); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/proc/CallableFunction.java b/community/kernel/src/main/java/org/neo4j/kernel/api/proc/CallableUserFunction.java similarity index 79% rename from community/kernel/src/main/java/org/neo4j/kernel/api/proc/CallableFunction.java rename to community/kernel/src/main/java/org/neo4j/kernel/api/proc/CallableUserFunction.java index 4be5e0ca419e..81ba135e919d 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/proc/CallableFunction.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/proc/CallableUserFunction.java @@ -21,22 +21,22 @@ import org.neo4j.kernel.api.exceptions.ProcedureException; -public interface CallableFunction +public interface CallableUserFunction { - FunctionSignature signature(); + UserFunctionSignature signature(); Object apply( Context ctx, Object[] input ) throws ProcedureException; - abstract class BasicFunction implements CallableFunction + abstract class BasicUserFunction implements CallableUserFunction { - private final FunctionSignature signature; + private final UserFunctionSignature signature; - protected BasicFunction( FunctionSignature signature ) + protected BasicUserFunction( UserFunctionSignature signature ) { this.signature = signature; } @Override - public FunctionSignature signature() + public UserFunctionSignature signature() { return signature; } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/proc/FunctionSignature.java b/community/kernel/src/main/java/org/neo4j/kernel/api/proc/UserFunctionSignature.java similarity index 94% rename from community/kernel/src/main/java/org/neo4j/kernel/api/proc/FunctionSignature.java rename to community/kernel/src/main/java/org/neo4j/kernel/api/proc/UserFunctionSignature.java index aa0ab1acbdd8..24653f5e4984 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/proc/FunctionSignature.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/proc/UserFunctionSignature.java @@ -33,7 +33,7 @@ * This describes the signature of a function, made up of its namespace, name, and input/output description. * Function uniqueness is currently *only* on the namespace/name level - no function overloading allowed (yet). */ -public class FunctionSignature +public class UserFunctionSignature { private final QualifiedName name; private final List inputSignature; @@ -42,7 +42,7 @@ public class FunctionSignature private final Optional deprecated; private final Optional description; - public FunctionSignature( QualifiedName name, + public UserFunctionSignature( QualifiedName name, List inputSignature, Neo4jTypes.AnyType type, Optional deprecated, @@ -90,7 +90,7 @@ public boolean equals( Object o ) if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } - FunctionSignature that = (FunctionSignature) o; + UserFunctionSignature that = (UserFunctionSignature) o; return name.equals( that.name ) && @@ -158,13 +158,13 @@ public Builder allowed( String[] allowed ) return this; } - public FunctionSignature build() + public UserFunctionSignature build() { if (outputType == null) { throw new IllegalStateException( "output type must be set" ); } - return new FunctionSignature(name, inputSignature, outputType, deprecated, allowed, description ); + return new UserFunctionSignature(name, inputSignature, outputType, deprecated, allowed, description ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/Kernel.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/Kernel.java index efec20bb181c..aefc0528943d 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/Kernel.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/Kernel.java @@ -25,8 +25,8 @@ import org.neo4j.kernel.api.TransactionHook; import org.neo4j.kernel.api.exceptions.ProcedureException; import org.neo4j.kernel.api.exceptions.TransactionFailureException; -import org.neo4j.kernel.api.proc.CallableFunction; import org.neo4j.kernel.api.proc.CallableProcedure; +import org.neo4j.kernel.api.proc.CallableUserFunction; import org.neo4j.kernel.api.security.AccessMode; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.proc.Procedures; @@ -121,7 +121,7 @@ public void registerProcedure( CallableProcedure procedure ) throws ProcedureExc } @Override - public void registerFunction( CallableFunction function ) throws ProcedureException + public void registerUserFunction( CallableUserFunction function ) throws ProcedureException { procedures.register( function ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java index 2f1254ce4c18..bf38e2561566 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java @@ -73,9 +73,9 @@ import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.proc.BasicContext; import org.neo4j.kernel.api.proc.Context; -import org.neo4j.kernel.api.proc.FunctionSignature; import org.neo4j.kernel.api.proc.ProcedureSignature; import org.neo4j.kernel.api.proc.QualifiedName; +import org.neo4j.kernel.api.proc.UserFunctionSignature; import org.neo4j.kernel.api.properties.DefinedProperty; import org.neo4j.kernel.api.properties.Property; import org.neo4j.kernel.api.security.AccessMode; @@ -551,7 +551,7 @@ public ProcedureSignature procedureGet( QualifiedName name ) throws ProcedureExc } @Override - public Optional functionGet( QualifiedName name ) + public Optional functionGet( QualifiedName name ) { statement.assertOpen(); return procedures.function( name ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ProcedureJarLoader.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ProcedureJarLoader.java index c8e791cc4012..9fa6bcfb7b3d 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ProcedureJarLoader.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ProcedureJarLoader.java @@ -33,8 +33,8 @@ import org.neo4j.collection.PrefetchingRawIterator; import org.neo4j.collection.RawIterator; import org.neo4j.kernel.api.exceptions.KernelException; -import org.neo4j.kernel.api.proc.CallableFunction; import org.neo4j.kernel.api.proc.CallableProcedure; +import org.neo4j.kernel.api.proc.CallableUserFunction; import org.neo4j.logging.Log; import static java.util.stream.Collectors.toList; @@ -163,14 +163,14 @@ protected Class fetchNextOrNull() throws IOException public static class Callables { private final List procedures = new ArrayList<>(); - private final List functions = new ArrayList<>(); + private final List functions = new ArrayList<>(); public void add( CallableProcedure proc ) { procedures.add( proc ); } - public void add( CallableFunction func ) + public void add( CallableUserFunction func ) { functions.add( func ); } @@ -180,7 +180,7 @@ public List procedures() return procedures; } - public List functions() + public List functions() { return functions; } @@ -190,7 +190,7 @@ public void addAllProcedures( List callableProcedures ) procedures.addAll( callableProcedures ); } - public void addAllFunctions( List callableFunctions ) + public void addAllFunctions( List callableFunctions ) { functions.addAll( callableFunctions ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ProcedureRegistry.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ProcedureRegistry.java index 8c4de9e36b54..a65fe0996358 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ProcedureRegistry.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ProcedureRegistry.java @@ -30,18 +30,18 @@ import org.neo4j.collection.RawIterator; import org.neo4j.kernel.api.exceptions.ProcedureException; import org.neo4j.kernel.api.exceptions.Status; -import org.neo4j.kernel.api.proc.CallableFunction; import org.neo4j.kernel.api.proc.CallableProcedure; +import org.neo4j.kernel.api.proc.CallableUserFunction; import org.neo4j.kernel.api.proc.Context; import org.neo4j.kernel.api.proc.FieldSignature; -import org.neo4j.kernel.api.proc.FunctionSignature; import org.neo4j.kernel.api.proc.ProcedureSignature; import org.neo4j.kernel.api.proc.QualifiedName; +import org.neo4j.kernel.api.proc.UserFunctionSignature; public class ProcedureRegistry { private final Map procedures = new HashMap<>(); - private final Map functions = new HashMap<>(); + private final Map functions = new HashMap<>(); /** * Register a new procedure. @@ -81,12 +81,12 @@ public void register( CallableProcedure proc, boolean overrideCurrentImplementat * * @param function the function. */ - public void register( CallableFunction function, boolean overrideCurrentImplementation ) throws ProcedureException + public void register( CallableUserFunction function, boolean overrideCurrentImplementation ) throws ProcedureException { - FunctionSignature signature = function.signature(); + UserFunctionSignature signature = function.signature(); QualifiedName name = signature.name(); - CallableFunction oldImplementation = functions.get( name ); + CallableUserFunction oldImplementation = functions.get( name ); if ( oldImplementation == null ) { functions.put( name, function ); @@ -130,9 +130,9 @@ public ProcedureSignature procedure( QualifiedName name ) throws ProcedureExcept return proc.signature(); } - public Optional function( QualifiedName name ) + public Optional function( QualifiedName name ) { - CallableFunction func = functions.get( name ); + CallableUserFunction func = functions.get( name ); if ( func == null ) { return Optional.empty(); @@ -154,7 +154,7 @@ public RawIterator callProcedure( Context ctx, Qual public Object callFunction( Context ctx, QualifiedName name, Object[] input ) throws ProcedureException { - CallableFunction func = functions.get( name ); + CallableUserFunction func = functions.get( name ); if ( func == null ) { throw noSuchFunction( name ); @@ -183,9 +183,9 @@ public Set getAllProcedures() return procedures.values().stream().map( CallableProcedure::signature ).collect( Collectors.toSet()); } - public Set getAllFunctions() + public Set getAllFunctions() { - return functions.values().stream().map( CallableFunction::signature ).collect( Collectors.toSet() ); + return functions.values().stream().map( CallableUserFunction::signature ).collect( Collectors.toSet() ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/Procedures.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/Procedures.java index 69fef571c14d..677ef39be6e3 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/Procedures.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/Procedures.java @@ -27,12 +27,12 @@ import org.neo4j.function.ThrowingConsumer; import org.neo4j.kernel.api.exceptions.KernelException; import org.neo4j.kernel.api.exceptions.ProcedureException; -import org.neo4j.kernel.api.proc.CallableFunction; import org.neo4j.kernel.api.proc.CallableProcedure; +import org.neo4j.kernel.api.proc.CallableUserFunction; import org.neo4j.kernel.api.proc.Context; -import org.neo4j.kernel.api.proc.FunctionSignature; import org.neo4j.kernel.api.proc.ProcedureSignature; import org.neo4j.kernel.api.proc.QualifiedName; +import org.neo4j.kernel.api.proc.UserFunctionSignature; import org.neo4j.kernel.builtinprocs.SpecialBuiltInProcedures; import org.neo4j.kernel.lifecycle.LifecycleAdapter; import org.neo4j.logging.Log; @@ -79,7 +79,7 @@ public void register( CallableProcedure proc ) throws ProcedureException * Register a new function. This method must not be called concurrently with {@link #procedure(QualifiedName)}. * @param function the fucntion. */ - public void register( CallableFunction function ) throws ProcedureException + public void register( CallableUserFunction function ) throws ProcedureException { register( function, false ); } @@ -88,7 +88,7 @@ public void register( CallableFunction function ) throws ProcedureException * Register a new procedure. This method must not be called concurrently with {@link #procedure(QualifiedName)}. * @param function the function. */ - public void register( CallableFunction function, boolean overrideCurrentImplementation ) throws ProcedureException + public void register( CallableUserFunction function, boolean overrideCurrentImplementation ) throws ProcedureException { registry.register( function, overrideCurrentImplementation ); } @@ -138,7 +138,7 @@ public void registerFunction( Class func ) throws KernelException */ public void registerFunction( Class func, boolean overrideCurrentImplementation ) throws KernelException { - for ( CallableFunction function : compiler.compileFunction( func ) ) + for ( CallableUserFunction function : compiler.compileFunction( func ) ) { register( function, overrideCurrentImplementation ); } @@ -170,7 +170,7 @@ public ProcedureSignature procedure( QualifiedName name ) throws ProcedureExcept return registry.procedure( name ); } - public Optional function( QualifiedName name ) + public Optional function( QualifiedName name ) { return registry.function( name ); } @@ -180,7 +180,7 @@ public Set getAllProcedures() return registry.getAllProcedures(); } - public Set getAllFunctions() + public Set getAllFunctions() { return registry.getAllFunctions(); } @@ -208,7 +208,7 @@ public void start() throws Throwable register( procedure ); } - for ( CallableFunction function : callables.functions() ) + for ( CallableUserFunction function : callables.functions() ) { register( function ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ReflectiveProcedureCompiler.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ReflectiveProcedureCompiler.java index ae977a44673d..3d0cd280b71b 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ReflectiveProcedureCompiler.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/ReflectiveProcedureCompiler.java @@ -35,21 +35,21 @@ import org.neo4j.kernel.api.exceptions.KernelException; import org.neo4j.kernel.api.exceptions.ProcedureException; import org.neo4j.kernel.api.exceptions.Status; -import org.neo4j.kernel.api.proc.CallableFunction; import org.neo4j.kernel.api.proc.CallableProcedure; +import org.neo4j.kernel.api.proc.CallableUserFunction; import org.neo4j.kernel.api.proc.Context; import org.neo4j.kernel.api.proc.FieldSignature; -import org.neo4j.kernel.api.proc.FunctionSignature; import org.neo4j.kernel.api.proc.Mode; import org.neo4j.kernel.api.proc.Neo4jTypes; import org.neo4j.kernel.api.proc.ProcedureSignature; import org.neo4j.kernel.api.proc.QualifiedName; +import org.neo4j.kernel.api.proc.UserFunctionSignature; import org.neo4j.kernel.impl.proc.OutputMappers.OutputMapper; import org.neo4j.logging.Log; import org.neo4j.procedure.Description; -import org.neo4j.procedure.Function; import org.neo4j.procedure.PerformsWrites; import org.neo4j.procedure.Procedure; +import org.neo4j.procedure.UserFunction; import static java.util.Collections.emptyIterator; import static java.util.Collections.emptyList; @@ -76,12 +76,12 @@ public ReflectiveProcedureCompiler( TypeMappers typeMappers, ComponentRegistry c this.typeMappers = typeMappers; } - public List compileFunction( Class fcnDefinition ) throws KernelException + public List compileFunction( Class fcnDefinition ) throws KernelException { try { List procedureMethods = Arrays.stream( fcnDefinition.getDeclaredMethods() ) - .filter( m -> m.isAnnotationPresent( Function.class ) ) + .filter( m -> m.isAnnotationPresent( UserFunction.class ) ) .collect( Collectors.toList() ); if ( procedureMethods.isEmpty() ) @@ -91,7 +91,7 @@ public List compileFunction( Class fcnDefinition ) throws K MethodHandle constructor = constructor( fcnDefinition ); - ArrayList out = new ArrayList<>( procedureMethods.size() ); + ArrayList out = new ArrayList<>( procedureMethods.size() ); for ( Method method : procedureMethods ) { out.add( compileFunction( fcnDefinition, constructor, method ) ); @@ -182,17 +182,17 @@ private ReflectiveProcedure compileProcedure( Class procDefinition, MethodHan return new ReflectiveProcedure( signature, constructor, procedureMethod, outputMapper, setters ); } - private ReflectiveFunction compileFunction( Class procDefinition, MethodHandle constructor, Method method ) + private ReflectiveUserFunction compileFunction( Class procDefinition, MethodHandle constructor, Method method ) throws ProcedureException, IllegalAccessException { - String valueName = method.getAnnotation( Function.class ).value(); - String definedName = method.getAnnotation( Function.class ).name(); + String valueName = method.getAnnotation( UserFunction.class ).value(); + String definedName = method.getAnnotation( UserFunction.class ).name(); QualifiedName procName = extractName( procDefinition, method, valueName, definedName ); if (procName.namespace() == null || procName.namespace().length == 0) { throw new ProcedureException( Status.Procedure.ProcedureRegistrationFailed, - "It is not allowed to define functions in the root namespace please use a namespace, e.g. `@Function(\"org.example.com.%s\")", + "It is not allowed to define functions in the root namespace please use a namespace, e.g. `@UserFunction(\"org.example.com.%s\")", procName.name() ); } List inputSignature = inputSignatureDeterminer.inputTypesFor( method ); @@ -202,15 +202,15 @@ private ReflectiveFunction compileFunction( Class procDefinition, MethodHandl List setters = fieldInjections.setters( procDefinition ); Optional description = description( method ); - Function function = method.getAnnotation( Function.class ); + UserFunction function = method.getAnnotation( UserFunction.class ); Optional deprecated = deprecated( method, function::deprecatedBy, - "Use of @Function(deprecatedBy) without @Deprecated in " + procName ); + "Use of @UserFunction(deprecatedBy) without @Deprecated in " + procName ); - FunctionSignature signature = - new FunctionSignature( procName, inputSignature, valueConverter.type(), deprecated, function.allowed(), description ); + UserFunctionSignature signature = + new UserFunctionSignature( procName, inputSignature, valueConverter.type(), deprecated, function.allowed(), description ); - return new ReflectiveFunction( signature, constructor, procedureMethod, valueConverter, setters ); + return new ReflectiveUserFunction( signature, constructor, procedureMethod, valueConverter, setters ); } private Optional deprecated( Method method, Supplier supplier, String warning ) @@ -438,13 +438,13 @@ public Object[] next() throws ProcedureException } } - private static class ReflectiveFunction extends ReflectiveBase implements CallableFunction + private static class ReflectiveUserFunction extends ReflectiveBase implements CallableUserFunction { private final TypeMappers.NeoValueConverter valueConverter; - private final FunctionSignature signature; + private final UserFunctionSignature signature; - public ReflectiveFunction( FunctionSignature signature, MethodHandle constructor, + public ReflectiveUserFunction( UserFunctionSignature signature, MethodHandle constructor, MethodHandle procedureMethod, TypeMappers.NeoValueConverter outputMapper, List fieldSetters ) { @@ -454,7 +454,7 @@ public ReflectiveFunction( FunctionSignature signature, MethodHandle constructor } @Override - public FunctionSignature signature() + public UserFunctionSignature signature() { return signature; } diff --git a/community/kernel/src/main/java/org/neo4j/procedure/Function.java b/community/kernel/src/main/java/org/neo4j/procedure/UserFunction.java similarity index 99% rename from community/kernel/src/main/java/org/neo4j/procedure/Function.java rename to community/kernel/src/main/java/org/neo4j/procedure/UserFunction.java index a595817edb43..1779fe2929d6 100644 --- a/community/kernel/src/main/java/org/neo4j/procedure/Function.java +++ b/community/kernel/src/main/java/org/neo4j/procedure/UserFunction.java @@ -102,7 +102,7 @@ */ @Target( ElementType.METHOD ) @Retention( RetentionPolicy.RUNTIME ) -public @interface Function +public @interface UserFunction { /** * The namespace and name for the function, as a period-separated diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/constraints/ConstraintIndexCreatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/constraints/ConstraintIndexCreatorTest.java index 4baefc287d2c..5ccc46c5190f 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/constraints/ConstraintIndexCreatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/constraints/ConstraintIndexCreatorTest.java @@ -37,8 +37,8 @@ import org.neo4j.kernel.api.exceptions.schema.ConstraintVerificationFailedKernelException; import org.neo4j.kernel.api.index.IndexDescriptor; import org.neo4j.kernel.api.index.PreexistingIndexEntryConflictException; -import org.neo4j.kernel.api.proc.CallableFunction; import org.neo4j.kernel.api.proc.CallableProcedure; +import org.neo4j.kernel.api.proc.CallableUserFunction; import org.neo4j.kernel.api.security.AccessMode; import org.neo4j.kernel.api.txstate.TransactionState; import org.neo4j.kernel.impl.api.KernelStatement; @@ -196,7 +196,7 @@ public void registerProcedure( CallableProcedure procedure ) } @Override - public void registerFunction( CallableFunction function ) throws ProcedureException + public void registerUserFunction( CallableUserFunction function ) throws ProcedureException { throw new UnsupportedOperationException(); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/MethodSignatureCompilerTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/MethodSignatureCompilerTest.java index 2f25a8d4ee84..4de4f269709e 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/MethodSignatureCompilerTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/MethodSignatureCompilerTest.java @@ -30,9 +30,9 @@ import org.neo4j.kernel.api.exceptions.ProcedureException; import org.neo4j.kernel.api.proc.FieldSignature; import org.neo4j.kernel.api.proc.Neo4jTypes; -import org.neo4j.procedure.Function; import org.neo4j.procedure.Name; import org.neo4j.procedure.Procedure; +import org.neo4j.procedure.UserFunction; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; @@ -80,13 +80,13 @@ public Stream echoWithInvalidType( @Name("name") UnmappableRecor public static class ClassWithFunctionWithSimpleArgs { - @Function + @UserFunction public String echo( String in) { return in; } - @Function + @UserFunction public String echoWithInvalidType( UnmappableRecord in) { return "echo"; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/ReflectiveFunctionTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/ReflectiveUserFunctionTest.java similarity index 86% rename from community/kernel/src/test/java/org/neo4j/kernel/impl/proc/ReflectiveFunctionTest.java rename to community/kernel/src/test/java/org/neo4j/kernel/impl/proc/ReflectiveUserFunctionTest.java index c4325bca9359..26a3472dd0bc 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/ReflectiveFunctionTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/ReflectiveUserFunctionTest.java @@ -34,12 +34,12 @@ import org.neo4j.kernel.api.exceptions.KernelException; import org.neo4j.kernel.api.exceptions.ProcedureException; import org.neo4j.kernel.api.proc.BasicContext; -import org.neo4j.kernel.api.proc.CallableFunction; +import org.neo4j.kernel.api.proc.CallableUserFunction; import org.neo4j.kernel.api.proc.Neo4jTypes; import org.neo4j.logging.Log; import org.neo4j.logging.NullLog; import org.neo4j.procedure.Context; -import org.neo4j.procedure.Function; +import org.neo4j.procedure.UserFunction; import static junit.framework.TestCase.assertEquals; import static org.hamcrest.CoreMatchers.equalTo; @@ -51,9 +51,9 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.neo4j.kernel.api.proc.FunctionSignature.functionSignature; +import static org.neo4j.kernel.api.proc.UserFunctionSignature.functionSignature; -public class ReflectiveFunctionTest +public class ReflectiveUserFunctionTest { @Rule public ExpectedException exception = ExpectedException.none(); @@ -74,7 +74,7 @@ public void shouldInjectLogging() throws KernelException // Given Log log = spy( Log.class ); components.register( Log.class, (ctx) -> log ); - CallableFunction function = procedureCompiler.compileFunction( LoggingFunction.class ).get( 0 ); + CallableUserFunction function = procedureCompiler.compileFunction( LoggingFunction.class ).get( 0 ); // When function.apply( new BasicContext(), new Object[0] ); @@ -90,7 +90,7 @@ public void shouldInjectLogging() throws KernelException public void shouldCompileFunction() throws Throwable { // When - List function = compile( SingleReadOnlyFunction.class ); + List function = compile( SingleReadOnlyFunction.class ); // Then assertEquals( 1, function.size() ); @@ -104,7 +104,7 @@ public void shouldCompileFunction() throws Throwable public void shouldRunSimpleReadOnlyFunction() throws Throwable { // Given - CallableFunction func = compile( SingleReadOnlyFunction.class ).get( 0 ); + CallableUserFunction func = compile( SingleReadOnlyFunction.class ).get( 0 ); // When Object out = func.apply( new BasicContext(), new Object[0] ); @@ -117,7 +117,7 @@ public void shouldRunSimpleReadOnlyFunction() throws Throwable public void shouldIgnoreClassesWithNoFunctions() throws Throwable { // When - List functions = compile( PrivateConstructorButNoFunctions.class ); + List functions = compile( PrivateConstructorButNoFunctions.class ); // Then assertEquals( 0, functions.size() ); @@ -127,9 +127,9 @@ public void shouldIgnoreClassesWithNoFunctions() throws Throwable public void shouldRunClassWithMultipleFunctionsDeclared() throws Throwable { // Given - List compiled = compile( ReflectiveFunctionTest.MultiFunction.class ); - CallableFunction bananaPeople = compiled.get( 0 ); - CallableFunction coolPeople = compiled.get( 1 ); + List compiled = compile( ReflectiveUserFunctionTest.MultiFunction.class ); + CallableUserFunction bananaPeople = compiled.get( 0 ); + CallableUserFunction coolPeople = compiled.get( 1 ); // When Object coolOut = coolPeople.apply( new BasicContext(), new Object[0] ); @@ -211,7 +211,7 @@ public void shouldGiveHelpfulErrorOnContextAnnotatedStaticField() throws Throwab public void shouldAllowOverridingProcedureName() throws Throwable { // When - CallableFunction proc = compile( FunctionWithOverriddenName.class ).get( 0 ); + CallableUserFunction proc = compile( FunctionWithOverriddenName.class ).get( 0 ); // Then assertEquals("org.mystuff.thisisActuallyTheName", proc.signature().name().toString() ); @@ -223,7 +223,7 @@ public void shouldNotAllowOverridingFunctionNameWithoutNamespace() throws Throwa // Expect exception.expect( ProcedureException.class ); exception.expectMessage( "It is not allowed to define functions in the root namespace please use a " + - "namespace, e.g. `@Function(\"org.example.com.singleName\")" ); + "namespace, e.g. `@UserFunction(\"org.example.com.singleName\")" ); // When compile( FunctionWithSingleName.class ).get( 0 ); @@ -233,7 +233,7 @@ public void shouldNotAllowOverridingFunctionNameWithoutNamespace() throws Throwa public void shouldGiveHelpfulErrorOnNullMessageException() throws Throwable { // Given - CallableFunction proc = compile( FunctionThatThrowsNullMsgExceptionAtInvocation.class ).get( 0 ); + CallableUserFunction proc = compile( FunctionThatThrowsNullMsgExceptionAtInvocation.class ).get( 0 ); // Expect exception.expect( ProcedureException.class ); @@ -252,12 +252,12 @@ public void shouldSupportFunctionDeprecation() throws Throwable ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler( new TypeMappers(), components, log ); // When - List funcs = procedureCompiler.compileFunction( FunctionWithDeprecation.class ); + List funcs = procedureCompiler.compileFunction( FunctionWithDeprecation.class ); // Then - verify( log ).warn( "Use of @Function(deprecatedBy) without @Deprecated in org.neo4j.kernel.impl.proc.badFunc" ); + verify( log ).warn( "Use of @UserFunction(deprecatedBy) without @Deprecated in org.neo4j.kernel.impl.proc.badFunc" ); verifyNoMoreInteractions( log ); - for ( CallableFunction func : funcs ) + for ( CallableUserFunction func : funcs ) { String name = func.signature().name().name(); func.apply( new BasicContext(), new Object[0] ); @@ -282,7 +282,7 @@ public static class LoggingFunction @Context public Log log; - @Function + @UserFunction public long logAround() { log.debug( "1" ); @@ -295,7 +295,7 @@ public long logAround() public static class SingleReadOnlyFunction { - @Function + @UserFunction public List listCoolPeople() { return Arrays.asList("Bonnie", "Clyde"); @@ -304,7 +304,7 @@ public List listCoolPeople() public static class FunctionWithVoidOutput { - @Function + @UserFunction public void voidOutput() { } @@ -312,13 +312,13 @@ public void voidOutput() public static class MultiFunction { - @Function + @UserFunction public List listCoolPeople() { return Arrays.asList("Bonnie", "Clyde"); } - @Function + @UserFunction public Map listBananaOwningPeople() { HashMap map = new HashMap<>(); @@ -334,7 +334,7 @@ public WierdConstructorFunction( WierdConstructorFunction wat ) } - @Function + @UserFunction public List listCoolPeople() { return Arrays.asList("Bonnie", "Clyde"); @@ -343,7 +343,7 @@ public List listCoolPeople() public static class FunctionWithInvalidOutput { - @Function + @UserFunction public char[] test( ) { return "Testing".toCharArray(); @@ -355,7 +355,7 @@ public static class FunctionWithStaticContextAnnotatedField @Context public static GraphDatabaseService gdb; - @Function + @UserFunction public Object test( ) { return null; @@ -364,7 +364,7 @@ public Object test( ) public static class FunctionThatThrowsNullMsgExceptionAtInvocation { - @Function + @UserFunction public String throwsAtInvocation( ) { throw new IndexOutOfBoundsException(); @@ -378,7 +378,7 @@ private PrivateConstructorFunction() } - @Function + @UserFunction public List listCoolPeople() { return Arrays.asList("Bonnie", "Clyde"); @@ -400,7 +400,7 @@ public String thisIsNotAFunction() public static class FunctionWithOverriddenName { - @Function("org.mystuff.thisisActuallyTheName") + @UserFunction("org.mystuff.thisisActuallyTheName") public Object somethingThatShouldntMatter() { return null; @@ -410,7 +410,7 @@ public Object somethingThatShouldntMatter() public static class FunctionWithSingleName { - @Function("singleName") + @UserFunction("singleName") public String blahDoesntMatterEither() { return null; @@ -419,27 +419,27 @@ public String blahDoesntMatterEither() public static class FunctionWithDeprecation { - @Function + @UserFunction public Object newFunc() { return null; } @Deprecated - @Function(deprecatedBy = "newFunc") + @UserFunction(deprecatedBy = "newFunc") public String oldFunc() { return null; } - @Function(deprecatedBy = "newFunc") + @UserFunction(deprecatedBy = "newFunc") public Object badFunc() { return null; } } - private List compile( Class clazz ) throws KernelException + private List compile( Class clazz ) throws KernelException { return procedureCompiler.compileFunction( clazz ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/FunctionSignatureTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/UserFunctionSignatureTest.java similarity index 89% rename from community/kernel/src/test/java/org/neo4j/kernel/impl/proc/FunctionSignatureTest.java rename to community/kernel/src/test/java/org/neo4j/kernel/impl/proc/UserFunctionSignatureTest.java index 04d8b70a0987..c3f88043ea56 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/FunctionSignatureTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/UserFunctionSignatureTest.java @@ -23,17 +23,17 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import org.neo4j.kernel.api.proc.FunctionSignature; import org.neo4j.kernel.api.proc.Neo4jTypes; +import org.neo4j.kernel.api.proc.UserFunctionSignature; import static org.junit.Assert.assertEquals; -import static org.neo4j.kernel.api.proc.FunctionSignature.functionSignature; +import static org.neo4j.kernel.api.proc.UserFunctionSignature.functionSignature; -public class FunctionSignatureTest +public class UserFunctionSignatureTest { @Rule public ExpectedException exception = ExpectedException.none(); - private final FunctionSignature signature = + private final UserFunctionSignature signature = functionSignature( "asd" ).in( Neo4jTypes.NTAny ).out( Neo4jTypes.NTAny ).build(); @Test diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/FunctionsTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/UserFunctionsTest.java similarity index 87% rename from community/kernel/src/test/java/org/neo4j/kernel/impl/proc/FunctionsTest.java rename to community/kernel/src/test/java/org/neo4j/kernel/impl/proc/UserFunctionsTest.java index 30e420135fb9..f5e3f86a51da 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/FunctionsTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/proc/UserFunctionsTest.java @@ -29,33 +29,30 @@ import org.neo4j.helpers.collection.Iterables; import org.neo4j.kernel.api.exceptions.ProcedureException; import org.neo4j.kernel.api.proc.BasicContext; -import org.neo4j.kernel.api.proc.CallableFunction; +import org.neo4j.kernel.api.proc.CallableUserFunction; import org.neo4j.kernel.api.proc.Context; -import org.neo4j.kernel.api.proc.FunctionSignature; import org.neo4j.kernel.api.proc.Key; import org.neo4j.kernel.api.proc.Neo4jTypes; -import org.neo4j.procedure.Function; -import org.neo4j.procedure.Mode; -import org.neo4j.procedure.PerformsWrites; +import org.neo4j.kernel.api.proc.UserFunctionSignature; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.Assert.assertThat; -import static org.neo4j.kernel.api.proc.FunctionSignature.functionSignature; import static org.neo4j.kernel.api.proc.Key.key; +import static org.neo4j.kernel.api.proc.UserFunctionSignature.functionSignature; -public class FunctionsTest +public class UserFunctionsTest { @Rule public ExpectedException exception = ExpectedException.none(); private final Procedures procs = new Procedures(); - private final FunctionSignature signature = + private final UserFunctionSignature signature = functionSignature( "org", "myproc" ) .out( Neo4jTypes.NTAny) .build(); - private final CallableFunction function = function( signature ); + private final CallableUserFunction function = function( signature ); @Test public void shouldGetRegisteredProcedure() throws Throwable @@ -76,7 +73,7 @@ public void shouldGetAllRegisteredProcedures() throws Throwable procs.register( function( functionSignature( "org", "myproc3" ).out(Neo4jTypes.NTAny).build() ) ); // Then - List signatures = Iterables.asList( procs.getAllFunctions() ); + List signatures = Iterables.asList( procs.getAllFunctions() ); assertThat( signatures, containsInAnyOrder( functionSignature( "org", "myproc1" ).out(Neo4jTypes.NTAny).build(), functionSignature( "org", "myproc2" ).out(Neo4jTypes.NTAny).build(), @@ -140,7 +137,7 @@ public void shouldMakeContextAvailable() throws Throwable // Given Key someKey = key("someKey", String.class); - procs.register( new CallableFunction.BasicFunction( signature ) + procs.register( new CallableUserFunction.BasicUserFunction( signature ) { @Override public Object apply( Context ctx, Object[] input ) throws ProcedureException @@ -159,9 +156,9 @@ public Object apply( Context ctx, Object[] input ) throws ProcedureException assertThat( result, equalTo("hello, world" ) ); } - private CallableFunction function( FunctionSignature signature ) + private CallableUserFunction function( UserFunctionSignature signature ) { - return new CallableFunction.BasicFunction( signature ) + return new CallableUserFunction.BasicUserFunction( signature ) { @Override public Object apply( Context ctx, Object[] input ) diff --git a/integrationtests/src/test/java/org/neo4j/procedure/FunctionIT.java b/integrationtests/src/test/java/org/neo4j/procedure/UserFunctionIT.java similarity index 97% rename from integrationtests/src/test/java/org/neo4j/procedure/FunctionIT.java rename to integrationtests/src/test/java/org/neo4j/procedure/UserFunctionIT.java index c97222ca0f5d..b802fcfb61b0 100644 --- a/integrationtests/src/test/java/org/neo4j/procedure/FunctionIT.java +++ b/integrationtests/src/test/java/org/neo4j/procedure/UserFunctionIT.java @@ -78,7 +78,7 @@ import static org.neo4j.logging.AssertableLogProvider.inLog; import static org.neo4j.procedure.Mode.WRITE; -public class FunctionIT +public class UserFunctionIT { @Rule public TemporaryFolder plugins = new TemporaryFolder(); @@ -652,25 +652,25 @@ public static class ClassWithFunctions @Context public Log log; - @Function + @UserFunction public long integrationTestMe() { return 1337L; } - @Function + @UserFunction public long simpleArgument( long someValue ) { return someValue; } - @Function + @UserFunction public long nodeListArgument( List nodes ) { return nodes.size(); } - @Function + @UserFunction public long delegatingFunction( long someValue ) { return (long) db @@ -678,7 +678,7 @@ public long delegatingFunction( long someValue ) .next().get( "result" ); } - @Function + @UserFunction public long recursiveSum( long order ) { if ( order == 0L ) @@ -695,63 +695,63 @@ public long recursiveSum( long order ) } } - @Function + @UserFunction public long genericArguments( List> stringList, List>> longList ) { return stringList.size() + longList.size(); } - @Function + @UserFunction public long mapArgument( Map map ) { return map.size(); } - @Function + @UserFunction public Node node( @Name( "id" ) long id ) { return db.getNodeById( id ); } - @Function + @UserFunction public double squareDouble( double value ) { return value * value; } - @Function + @UserFunction public double avgNumberList( List list ) { return list.stream().reduce( ( l, r ) -> l.doubleValue() + r.doubleValue() ).orElse( 0.0d ).doubleValue() / list.size(); } - @Function + @UserFunction public double avgDoubleList( List list ) { return list.stream().reduce( ( l, r ) -> l + r ).orElse( 0.0d ) / list.size(); } - @Function + @UserFunction public long squareLong( long value ) { return value * value; } - @Function + @UserFunction public long throwsExceptionInStream() { throw new RuntimeException( "Kaboom" ); } - @Function + @UserFunction public long indexOutOfBounds() { int[] ints = {1, 2, 3}; return ints[4]; } - @Function + @UserFunction public List listCoolPeopleInDatabase() { return db.findNodes( label( "Person" ) ) @@ -760,7 +760,7 @@ public List listCoolPeopleInDatabase() .collect( Collectors.toList() ); } - @Function + @UserFunction public long logAround() { log.debug( "1" ); @@ -770,19 +770,19 @@ public long logAround() return 1337L; } - @Function + @UserFunction public Node readOnlyTryingToWrite() { return db.createNode(); } - @Function + @UserFunction public Node readOnlyCallingWriteFunction() { return (Node) db.execute( "RETURN org.neo4j.procedure.writingFunction() AS node" ).next().get("node"); } - @Function + @UserFunction public long readOnlyCallingWriteProcedure() { db.execute( "CALL org.neo4j.procedure.writingProcedure()" ); @@ -795,14 +795,14 @@ public void writingProcedure() db.createNode(); } - @Function + @UserFunction public String shutdown() { db.shutdown(); return "oh no!"; } - @Function + @UserFunction public String unsupportedFunction() { jobs.submit( () -> { @@ -820,7 +820,7 @@ public String unsupportedFunction() return "why!?"; } - @Function + @UserFunction public Path nodePaths( Node node ) { return (Path) db @@ -830,13 +830,13 @@ public Path nodePaths( Node node ) } @Description( "This is a description" ) - @Function + @UserFunction public Node nodeWithDescription( Node node ) { return node; } - @Function + @UserFunction public String readOnlyTryingToWriteSchema() { db.execute( "CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE" );