Skip to content

Commit

Permalink
Clarification that regex is custom predicate #294 (#296)
Browse files Browse the repository at this point in the history
Signed-off-by: Dwitry dwitry@users.noreply.github.com
  • Loading branch information
dwitry committed Jun 28, 2019
1 parent 5b5dd3e commit 66bcede
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void continueElements() {
@Test
public void translate() {
assertThatThrownBy(() -> g.cypher("RETURN toupper('test')", "cosmosdb"))
.hasMessageContaining("Custom functions and predicates are not supported: cypherToUpper");
.hasMessageContaining("Custom functions and predicates are not supported on target implementation: cypherToUpper");
}


Expand Down
2 changes: 2 additions & 0 deletions tinkerpop/cypher-gremlin-extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ If extensions are installed on a target server and translation happens on the cl
Functions that are present in Cypher but not in Gremlin:

* Type Conversion [functions](https://neo4j.com/docs/cypher-manual/current/functions/scalar/): `toString`, `toBoolean`, `toInteger`, `toFloat`
* Type [predicates](https://github.com/opencypher/cypher-for-gremlin/tree/master/tinkerpop/cypher-gremlin-extensions#queries-that-require-type-information): `isString`, `isRelationship`, `isNode`
* [String functions](https://neo4j.com/docs/cypher-manual/current/functions/string/): `reverse`, `substring`, `trim`, `toUpper`, `toLower`...
* [Regex predicate](https://neo4j.com/docs/cypher-manual/current/clauses/where/#query-where-regex): `regex`
* Percentile functions: [percentileCont](https://neo4j.com/docs/cypher-manual/current/functions/aggregating/#functions-percentilecont), [percentileDisc](https://neo4j.com/docs/cypher-manual/current/functions/aggregating/#functions-percentiledisc)
* [round](https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-round) function

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ object NoCustomFunctions extends GremlinPostCondition {
})(steps).sorted.distinct

if (all.nonEmpty) {
Some(s"Custom functions and predicates are not supported: ${all.mkString(", ")}")
Some(
s"Custom functions and predicates are not supported on target implementation: ${all.mkString(", ")}. " +
"Consider installing Extensions to Gremlin to enable full support for Cypher functionality: " +
"https://github.com/opencypher/cypher-for-gremlin/tree/master/tinkerpop/cypher-gremlin-extensions")
} else {
None
}
Expand All @@ -50,6 +53,7 @@ object NoCustomFunctions extends GremlinPostCondition {
case _: IsNode => Some("cypherIsNode")
case _: IsString => Some("cypherIsString")
case _: IsRelationship => Some("cypherIsRelationship")
case _: RegexMatch => Some("cypherRegex")
case _ => None
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ class NoCustomFunctionsTest {
@Test
def predicates(): Unit = {
val ast = CypherAst.parse("""MATCH (u:User)
|WHERE u.name =~ 'Tim.*'
|WITH {key: u} AS nodes
|DELETE nodes.key""".stripMargin)
val translator = Translator.builder.gremlinGroovy.build(flavor)

assertThatThrownBy(() => ast.buildTranslation(translator))
.hasMessageContaining("cypherIsNode")
.hasMessageContaining("cypherIsNode, cypherRegex")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TranslatorBuilderTest {
() =>
parse("RETURN toupper('test')")
.buildTranslation(dslBuilder))
.hasMessageContaining("Custom functions and predicates are not supported: cypherToUpper")
.hasMessageContaining("Custom functions and predicates are not supported on target implementation: cypherToUpper")

val steps = parse("MATCH (n) RETURN n.name")
.buildTranslation(dslBuilder)
Expand Down Expand Up @@ -77,7 +77,7 @@ class TranslatorBuilderTest {
() =>
parse("RETURN toupper('test')")
.buildTranslation(dslBuilder))
.hasMessageContaining("Custom functions and predicates are not supported: cypherToUpper")
.hasMessageContaining("Custom functions and predicates are not supported on target implementation: cypherToUpper")

val steps = parse("MATCH (n) WHERE n.age=$age RETURN count(n)", Map("age" -> 25).asJava)
.buildTranslation(dslBuilder)
Expand Down Expand Up @@ -115,7 +115,7 @@ class TranslatorBuilderTest {
() =>
parse("RETURN toupper('test')")
.buildTranslation(dslBuilder))
.hasMessageContaining("Custom functions and predicates are not supported: cypherToUpper")
.hasMessageContaining("Custom functions and predicates are not supported on target implementation: cypherToUpper")

assertThatThrownBy(
() =>
Expand All @@ -140,7 +140,7 @@ class TranslatorBuilderTest {
() =>
parse("RETURN toupper('test')")
.buildTranslation(dslBuilder))
.hasMessageContaining("Custom functions and predicates are not supported: cypherToUpper")
.hasMessageContaining("Custom functions and predicates are not supported on target implementation: cypherToUpper")

val steps = parse("MATCH (n) RETURN n.name ORDER BY n.name")
.buildTranslation(dslBuilder)
Expand All @@ -160,7 +160,7 @@ class TranslatorBuilderTest {
() =>
parse("RETURN toupper('test')")
.buildTranslation(dslBuilder))
.hasMessageContaining("Custom functions and predicates are not supported: cypherToUpper")
.hasMessageContaining("Custom functions and predicates are not supported on target implementation: cypherToUpper")

val steps = parse("MATCH (n) RETURN n.name")
.buildTranslation(dslBuilder)
Expand All @@ -179,7 +179,7 @@ class TranslatorBuilderTest {
() =>
parse("RETURN toupper('test')")
.buildTranslation(dslBuilder))
.hasMessageContaining("Custom functions and predicates are not supported: cypherToUpper")
.hasMessageContaining("Custom functions and predicates are not supported on target implementation: cypherToUpper")

val steps = parse("MATCH (n) RETURN n.name")
.buildTranslation(dslBuilder)
Expand All @@ -198,7 +198,7 @@ class TranslatorBuilderTest {
() =>
parse("RETURN toupper('test')")
.buildTranslation(dslBuilder))
.hasMessageContaining("Custom functions and predicates are not supported: cypherToUpper")
.hasMessageContaining("Custom functions and predicates are not supported on target implementation: cypherToUpper")

val steps = parse("MATCH (n) RETURN n.name")
.buildTranslation(dslBuilder)
Expand Down

0 comments on commit 66bcede

Please sign in to comment.