-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3b7f69
commit f972ed7
Showing
15 changed files
with
294 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
MATCH (tom:Person) WHERE tom.name = "Tom Hanks" RETURN tom.id AS personId, tom.born AS bornYear,tom.name AS personName; | ||
MATCH (tom:Person) WHERE tom.name = "Tom Hanks" RETURN tom.born AS bornYear,tom.name AS personName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
MATCH p=shortestPath( | ||
(bacon:Person {name:"Kevin Bacon"})-[*]-(meg:Person {name:"Meg Ryan"}) | ||
) | ||
RETURN p | ||
RETURN p; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
MATCH (tom:Person {name: 'Tom Hanks'})-[r:ACTED_IN]->(movie:Movie) | ||
RETURN tom.id AS personId, movie.title as movieTitle, movie.release as movieReleased; | ||
RETURN tom.id AS personId, movie.title as movieTitle, movie.released as movieReleased; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
MATCH (tom:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(:Movie)<-[:ACTED_IN]-(coActor:Person) | ||
RETURN coActor.name | ||
RETURN coActor.name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
MATCH (tom:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(movie1:Movie)<-[:ACTED_IN]-(coActor:Person)-[:ACTED_IN]->(movie2:Movie)<-[:ACTED_IN]-(cruise:Person {name: 'Tom Cruise'}) | ||
WHERE NOT (tom)-[:ACTED_IN]->(:Movie)<-[:ACTED_IN]-(cruise) | ||
RETURN tom, movie1, coActor, movie2, cruise | ||
RETURN tom.name AS actorName, movie1.title AS actedInMovie, coActor.name AS coActorName, movie2.title AS coActorActivedInMovie, cruise.name AS coCoActorName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
MATCH (cloudAtlas:Movie {title: "Cloud Atlas"}) RETURN cloudAtlas.tagline AS tagline, cloudAtlas.release AS releasedYear,cloudAtlas.title AS tile; | ||
MATCH (cloudAtlas:Movie {title: "Cloud Atlas"}) RETURN cloudAtlas.tagline AS tagline, cloudAtlas.released AS releasedYear,cloudAtlas.title AS title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
MATCH (nineties:Movie) WHERE nineties.release > 1990 AND nineties.release < 2000 RETURN nineties.title | ||
MATCH (nineties:Movie) WHERE nineties.released >= 1990 AND nineties.released < 2000 RETURN nineties.title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
MATCH (tom:Person {name: "Tom Hanks"})-[:ACTED_IN]->(tomHanksMovies) | ||
RETURN tom.id AS personId, tom.born AS bornYear, tomHanksMovies.title AS movieTitle, tomHanksMovies.release AS releaseYear; | ||
RETURN tom.born AS bornYear,tomHanksMovies.tagline AS movieTagline, tomHanksMovies.title AS movieTitle, tomHanksMovies.released AS releaseYear; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(coActors) | ||
RETURN m.title AS movieTitle, m.release AS releasedYear, coActors.name AS coActor | ||
RETURN m.title AS movieTitle, m.released AS releasedYear, coActors.name AS coActor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
...iler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/MovieQueries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
package com.alibaba.graphscope.cypher.integration.suite.ldbc; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class MovieQueries { | ||
public static QueryContext get_movie_query1_test() { | ||
String query = "MATCH (tom:Person) WHERE tom.name = \"Tom Hanks\" RETURN tom.born AS bornYear,tom.name AS personName;"; | ||
List<String> expected = Arrays.asList( | ||
"Record<{bornYear: 1956, personName: \"Tom Hanks\"}>" | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query2_test(){ | ||
String query = "MATCH (cloudAtlas:Movie {title: \"Cloud Atlas\"}) RETURN cloudAtlas.tagline AS tagLine, cloudAtlas.release AS releasedYear,cloudAtlas.title AS title;"; | ||
List<String> expected = Arrays.asList( | ||
"Record<{tagline: \"Everything is connected\", releasedYear: 2012, title: \"Cloud Atlas\"}>" | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query3_test(){ | ||
String query = "MATCH (people:Person) RETURN people.name LIMIT 10;"; | ||
List<String> expected = Arrays.asList( | ||
"Record<{people.name: \"Keanu Reeves\"}>", | ||
"Record<{people.name: \"Carrie-Anne Moss\"}>", | ||
"Record<{people.name: \"Laurence Fishburne\"}>", | ||
"Record<{people.name: \"Hugo Weaving\"}>", | ||
"Record<{people.name: \"Lilly Wachowski\"}>", | ||
"Record<{people.name: \"Lana Wachowski\"}>", | ||
"Record<{people.name: \"Joel Silver\"}>", | ||
"Record<{people.name: \"Emil Eifrem\"}>", | ||
"Record<{people.name: \"Charlize Theron\"}>", | ||
"Record<{people.name: \"Al Pacino\"}>" | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query4_test(){ | ||
String query = "MATCH (nineties:Movie) WHERE nineties.released >= 1990 AND nineties.released < 2000 RETURN nineties.title LIMIT 10;"; | ||
List<String> expected = Arrays.asList( | ||
"Record<{nineties.title: \"The Matrix\"}>", | ||
"Record<{nineties.title: \"The Devil's Advocate\"}>", | ||
"Record<{nineties.title: \"A Few Good Men\"}>", | ||
"Record<{nineties.title: \"As Good as It Gets\"}>", | ||
"Record<{nineties.title: \"What Dreams May Come\"}>", | ||
"Record<{nineties.title: \"Snow Falling on Cedars\"}>", | ||
"Record<{nineties.title: \"You've Got Mail\"}>", | ||
"Record<{nineties.title: \"Sleepless in Seattle\"}>", | ||
"Record<{nineties.title: \"Joe Versus the Volcano\"}>", | ||
"Record<{nineties.title: \"When Harry Met Sally\"}>" | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
|
||
public static QueryContext get_movie_query5_test(){ | ||
String query = "MATCH (tom:Person {name: \"Tom Hanks\"})-[:ACTED_IN]->(tomHanksMovies)\n" | ||
+ "RETURN tom.born AS bornYear, tomHanksMovies.tagline AS movieTagline, tomHanksMovies.title AS movieTitle, tomHanksMovies.released AS releaseYear;"; | ||
List<String> expected = Arrays.asList( | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query6_test(){ | ||
String query = "MATCH (cloudAtlas:Movie {title: \"Cloud Atlas\"})<-[:DIRECTED]-(directors)\n" | ||
+ "RETURN directors.name;"; | ||
List<String> expected = Arrays.asList( | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query7_test(){ | ||
String query = "MATCH (tom:Person {name:\"Tom Hanks\"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(coActors)\n" | ||
+ "RETURN m.title AS movieTitle, m.released AS releasedYear, coActors.name AS coActor"; | ||
List<String> expected = Arrays.asList( | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query8_test(){ | ||
String query = "MATCH (people:Person)-[relatedTo]-(:Movie {title: \"Cloud Atlas\"})\n" | ||
+ "RETURN people.name, type(relatedTo), relatedTo"; | ||
List<String> expected = Arrays.asList( | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query9_test(){ | ||
String query = "MATCH (bacon:Person {name:\"Kevin Bacon\"})-[*1..3]-(hollywood)\n" | ||
+ "RETURN DISTINCT bacon, hollywood"; | ||
List<String> expected = Arrays.asList( | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query10_test(){ | ||
String query = "MATCH p=shortestPath(\n" | ||
+ " (bacon:Person {name:\"Kevin Bacon\"})-[*]-(meg:Person {name:\"Meg Ryan\"})\n" | ||
+ ")\n" | ||
+ "RETURN p;"; | ||
List<String> expected = Arrays.asList( | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query11_test(){ | ||
String query = "MATCH (tom:Person {name: 'Tom Hanks'})-[r:ACTED_IN]->(movie:Movie)\n" | ||
+ "RETURN tom.id AS personId, movie.title as movieTitle, movie.released as movieReleased;"; | ||
List<String> expected = Arrays.asList( | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query12_test(){ | ||
String query = "MATCH (tom:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(:Movie)<-[:ACTED_IN]-(coActor:Person)\n" | ||
+ "RETURN coActor.name;"; | ||
List<String> expected = Arrays.asList( | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query13_test(){ | ||
String query = "MATCH (tom:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(movie1:Movie)<-[:ACTED_IN]-(coActor:Person)-[:ACTED_IN]->(movie2:Movie)<-[:ACTED_IN]-(coCoActor:Person)\n" | ||
+ "WHERE tom <> coCoActor\n" | ||
+ "AND NOT (tom)-[:ACTED_IN]->(:Movie)<-[:ACTED_IN]-(coCoActor)\n" | ||
+ "RETURN coCoActor.name"; | ||
List<String> expected = Arrays.asList( | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query14_test(){ | ||
String query = "MATCH (tom:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(movie1:Movie)<-[:ACTED_IN]-(coActor:Person)-[:ACTED_IN]->(movie2:Movie)<-[:ACTED_IN]-(coCoActor:Person)\n" | ||
+ "WHERE tom <> coCoActor\n" | ||
+ "AND NOT (tom)-[:ACTED_IN]->(:Movie)<-[:ACTED_IN]-(coCoActor)\n" | ||
+ "RETURN coCoActor.name, count(coCoActor) as frequency\n" | ||
+ "ORDER BY frequency DESC\n" | ||
+ "LIMIT 5;"; | ||
List<String> expected = Arrays.asList( | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
|
||
public static QueryContext get_movie_query15_test(){ | ||
String query = "MATCH (tom:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(movie1:Movie)<-[:ACTED_IN]-(coActor:Person)-[:ACTED_IN]->(movie2:Movie)<-[:ACTED_IN]-(cruise:Person {name: 'Tom Cruise'})\n" | ||
+ "WHERE NOT (tom)-[:ACTED_IN]->(:Movie)<-[:ACTED_IN]-(cruise)\n" | ||
+ "RETURN tom.name AS actorName, movie1.title AS actedInMovie, coActor.name AS coActorName, movie2.title AS coActorActivedInMovie, cruise.name AS coCoActorName;"; | ||
List<String> expected = Arrays.asList( | ||
); | ||
return new QueryContext(query, expected); | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
...ine/compiler/src/test/java/com/alibaba/graphscope/cypher/integration/movie/MovieTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package com.alibaba.graphscope.cypher.integration.movie; | ||
|
||
import com.alibaba.graphscope.cypher.integration.suite.ldbc.MovieQueries; | ||
import com.alibaba.graphscope.cypher.integration.suite.ldbc.QueryContext; | ||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.neo4j.driver.GraphDatabase; | ||
import org.neo4j.driver.Result; | ||
import org.neo4j.driver.Session; | ||
|
||
public class MovieTest { | ||
|
||
private static Session session; | ||
|
||
@BeforeClass | ||
public static void beforeClass() { | ||
String neo4jServerUrl = | ||
System.getProperty("neo4j.bolt.server.url", "neo4j://localhost:7687"); | ||
session = GraphDatabase.driver(neo4jServerUrl).session(); | ||
} | ||
|
||
@Test | ||
public void run_movie_query1_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query1_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
|
||
@Test | ||
public void run_movie_query2_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query2_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
@Test | ||
public void run_movie_query3_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query3_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
@Test | ||
public void run_movie_query4_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query4_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
@Test | ||
public void run_movie_query5_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query5_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
@Test | ||
public void run_movie_query6_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query6_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
@Test | ||
public void run_movie_query7_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query7_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
@Test | ||
public void run_movie_query11_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query11_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
@Test | ||
public void run_movie_query12_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query12_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
@Test | ||
public void run_movie_query13_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query13_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
@Test | ||
public void run_movie_query14_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query14_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
@Test | ||
public void run_movie_query15_test() { | ||
QueryContext testQuery = MovieQueries.get_movie_query15_test(); | ||
Result result = session.run(testQuery.getQuery()); | ||
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); | ||
} | ||
|
||
@AfterClass | ||
public static void afterClass() { | ||
if (session != null) { | ||
session.close(); | ||
} | ||
} | ||
} |