From f85d87b300e7c72e1afdc89b49710396819c3ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9C=84=E7=A3=8A?= Date: Sun, 24 Sep 2023 19:58:45 +0800 Subject: [PATCH] sort query results --- flex/tests/hqps/queries/movie/query11.cypher | 3 +- flex/tests/hqps/queries/movie/query12.cypher | 2 +- flex/tests/hqps/queries/movie/query13.cypher | 2 +- flex/tests/hqps/queries/movie/query15.cypher | 3 +- flex/tests/hqps/queries/movie/query3.cypher | 2 +- flex/tests/hqps/queries/movie/query4.cypher | 3 +- flex/tests/hqps/queries/movie/query5.cypher | 3 +- flex/tests/hqps/queries/movie/query6.cypher | 2 +- flex/tests/hqps/queries/movie/query7.cypher | 3 +- .../integration/suite/ldbc/MovieQueries.java | 110 ++++++++++-------- 10 files changed, 77 insertions(+), 56 deletions(-) diff --git a/flex/tests/hqps/queries/movie/query11.cypher b/flex/tests/hqps/queries/movie/query11.cypher index dce31d22c22c..c1ddc6367be3 100644 --- a/flex/tests/hqps/queries/movie/query11.cypher +++ b/flex/tests/hqps/queries/movie/query11.cypher @@ -1,2 +1,3 @@ MATCH (tom:Person {name: 'Tom Hanks'})-[r:ACTED_IN]->(movie:Movie) -RETURN tom.id AS personId, movie.title as movieTitle, movie.released as movieReleased; \ No newline at end of file +WITH movie.title as movieTitle, movie.released as movieReleased +return movieTitle, movieReleased ORDER BY movieReleased DESC, movieTitle ASC LIMIT 10 \ No newline at end of file diff --git a/flex/tests/hqps/queries/movie/query12.cypher b/flex/tests/hqps/queries/movie/query12.cypher index 5f7f64a02c7a..5874a1775b31 100644 --- a/flex/tests/hqps/queries/movie/query12.cypher +++ b/flex/tests/hqps/queries/movie/query12.cypher @@ -1,2 +1,2 @@ MATCH (tom:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(:Movie)<-[:ACTED_IN]-(coActor:Person) -RETURN coActor.name; \ No newline at end of file +WITH DISTINCT coActor.name AS coActorName ORDER By coActorName ASC LIMIT 10 return coActorName; \ No newline at end of file diff --git a/flex/tests/hqps/queries/movie/query13.cypher b/flex/tests/hqps/queries/movie/query13.cypher index 90b890ab0899..11dcdc709eee 100644 --- a/flex/tests/hqps/queries/movie/query13.cypher +++ b/flex/tests/hqps/queries/movie/query13.cypher @@ -1,4 +1,4 @@ MATCH (tom:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(movie1:Movie)<-[:ACTED_IN]-(coActor:Person)-[:ACTED_IN]->(movie2:Movie)<-[:ACTED_IN]-(coCoActor:Person) WHERE tom <> coCoActor AND NOT (tom)-[:ACTED_IN]->(:Movie)<-[:ACTED_IN]-(coCoActor) -RETURN coCoActor.name \ No newline at end of file +RETURN coCoActor.name ORDER BY coCoActor.name ASC LIMIT 10; \ No newline at end of file diff --git a/flex/tests/hqps/queries/movie/query15.cypher b/flex/tests/hqps/queries/movie/query15.cypher index d94b9afcd102..a219dbd080a5 100644 --- a/flex/tests/hqps/queries/movie/query15.cypher +++ b/flex/tests/hqps/queries/movie/query15.cypher @@ -1,3 +1,4 @@ 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.name AS actorName, movie1.title AS actedInMovie, coActor.name AS coActorName, movie2.title AS coActorActivedInMovie, cruise.name AS coCoActorName; \ No newline at end of file +RETURN tom.name AS actorName, movie1.title AS movie1Title, coActor.name AS coActorName, movie2.title AS movie2Title, cruise.name AS coCoActorName +ORDER BY movie1Title, movie2Title LIMIT 10; \ No newline at end of file diff --git a/flex/tests/hqps/queries/movie/query3.cypher b/flex/tests/hqps/queries/movie/query3.cypher index 199dd3678564..76607e801600 100644 --- a/flex/tests/hqps/queries/movie/query3.cypher +++ b/flex/tests/hqps/queries/movie/query3.cypher @@ -1 +1 @@ -MATCH (people:Person) RETURN people.name LIMIT 10; \ No newline at end of file +MATCH (people:Person) RETURN people.name ORDER BY people.name ASC LIMIT 10; \ No newline at end of file diff --git a/flex/tests/hqps/queries/movie/query4.cypher b/flex/tests/hqps/queries/movie/query4.cypher index 5f708cd4c464..cb06f0614b49 100644 --- a/flex/tests/hqps/queries/movie/query4.cypher +++ b/flex/tests/hqps/queries/movie/query4.cypher @@ -1 +1,2 @@ -MATCH (nineties:Movie) WHERE nineties.released >= 1990 AND nineties.released < 2000 RETURN nineties.title; \ No newline at end of file +MATCH (nineties:Movie) WHERE nineties.released >= 1990 AND nineties.released < 2000 RETURN nineties.title +ORDER BY nineties.title DESC LIMIT 10; \ No newline at end of file diff --git a/flex/tests/hqps/queries/movie/query5.cypher b/flex/tests/hqps/queries/movie/query5.cypher index 792f2957234f..7565a94194df 100644 --- a/flex/tests/hqps/queries/movie/query5.cypher +++ b/flex/tests/hqps/queries/movie/query5.cypher @@ -1,2 +1,3 @@ MATCH (tom:Person {name: "Tom Hanks"})-[:ACTED_IN]->(tomHanksMovies) -RETURN tom.born AS bornYear,tomHanksMovies.tagline AS movieTagline, tomHanksMovies.title AS movieTitle, tomHanksMovies.released AS releaseYear; \ No newline at end of file +RETURN tom.born AS bornYear,tomHanksMovies.tagline AS movieTagline, tomHanksMovies.title AS movieTitle, tomHanksMovies.released AS releaseYear +ORDER BY releaseYear DESC, movieTitle ASC LIMIT 10; \ No newline at end of file diff --git a/flex/tests/hqps/queries/movie/query6.cypher b/flex/tests/hqps/queries/movie/query6.cypher index d7efbdec2ca3..dfa4e2746886 100644 --- a/flex/tests/hqps/queries/movie/query6.cypher +++ b/flex/tests/hqps/queries/movie/query6.cypher @@ -1,2 +1,2 @@ MATCH (cloudAtlas:Movie {title: "Cloud Atlas"})<-[:DIRECTED]-(directors) -RETURN directors.name; \ No newline at end of file +RETURN directors.name ORDER BY directors.name ASC LIMIT 10; \ No newline at end of file diff --git a/flex/tests/hqps/queries/movie/query7.cypher b/flex/tests/hqps/queries/movie/query7.cypher index 8fe4d19805dc..d0996e501c40 100644 --- a/flex/tests/hqps/queries/movie/query7.cypher +++ b/flex/tests/hqps/queries/movie/query7.cypher @@ -1,2 +1,3 @@ MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(coActors) -RETURN m.title AS movieTitle, m.released AS releasedYear, coActors.name AS coActor \ No newline at end of file +RETURN m.title AS movieTitle, m.released AS releasedYear, coActors.name AS coActor +ORDER BY m.released DESC, movieTitle ASC LIMIT 10; \ No newline at end of file diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/MovieQueries.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/MovieQueries.java index fcd596889f86..4f0d22bcfe96 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/MovieQueries.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/MovieQueries.java @@ -28,44 +28,33 @@ public static QueryContext get_movie_query3_test() { String query = "MATCH (people:Person) RETURN people.name LIMIT 10;"; List 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\"}>"); + "Record<{people.name: \"Aaron Sorkin\"}>", + "Record<{people.name: \"Al Pacino\"}>", + "Record<{people.name: \"Angela Scope\"}>", + "Record<{people.name: \"Annabella Sciorra\"}>", + "Record<{people.name: \"Anthony Edwards\"}>", + "Record<{people.name: \"Audrey Tautou\"}>", + "Record<{people.name: \"Ben Miles\"}>", + "Record<{people.name: \"Bill Paxton\"}>", + "Record<{people.name: \"Bill Pullman\"}>", + "Record<{people.name: \"Billy Crystal\"}>"); 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;"; + "MATCH (nineties:Movie) WHERE nineties.released >= 1990 AND nineties.released < 2000 RETURN nineties.title\n" + + "ORDER BY nineties.title DESC LIMIT 10;"; List 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\"}>"); + Arrays.asList(); 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;"; + + "RETURN tom.born AS bornYear,tomHanksMovies.tagline AS movieTagline, tomHanksMovies.title AS movieTitle, tomHanksMovies.released AS releaseYear\n" + + "ORDER BY releaseYear DESC, movieTitle ASC LIMIT 10;"; List expected = Arrays.asList(); return new QueryContext(query, expected); } @@ -73,16 +62,20 @@ public static QueryContext get_movie_query5_test() { public static QueryContext get_movie_query6_test() { String query = "MATCH (cloudAtlas:Movie {title: \"Cloud Atlas\"})<-[:DIRECTED]-(directors)\n" - + "RETURN directors.name;"; - List expected = Arrays.asList(); + + "RETURN directors.name ORDER BY directors.name ASC LIMIT 10;"; + List expected = Arrays.asList( + "Record<{directors.name: \"Lana Wachowski\"}>", + "Record<{directors.name: \"Lilly Wachowski\"}>", + "Record<{directors.name: \"Tom Tykwer\"}>" + ); 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"; + + "RETURN m.title AS movieTitle, m.released AS releasedYear, coActors.name AS coActor\n" + + "ORDER BY m.released DESC, movieTitle ASC LIMIT 10;"; List expected = Arrays.asList(); return new QueryContext(query, expected); } @@ -117,29 +110,49 @@ public static QueryContext get_movie_query10_test() { 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;"; + + "WITH movie.title as movieTitle, movie.released as movieReleased\n" + + "return movieTitle, movieReleased ORDER BY movieReleased DESC, movieTitle ASC LIMIT 10"; List 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 expected = Arrays.asList(); + "MATCH (tom:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(:Movie)<-[:ACTED_IN]-(coActor:Person)\n" + + "WITH DISTINCT coActor.name AS coActorName ORDER By coActorName ASC LIMIT 10 return coActorName;"; + List expected = Arrays.asList( + "Record<{name: \"Audrey Tautou\"}>", + "Record<{name: \"Bill Paxton\"}>", + "Record<{name: \"Bill Pullman\"}>", + "Record<{name: \"Bonnie Hunt\"}>", + "Record<{name: \"Charlize Theron\"}>", + "Record<{name: \"Dave Chappelle\"}>", + "Record<{name: \"David Morse\"}>", + "Record<{name: \"Ed Harris\"}>", + "Record<{name: \"Gary Sinise\"}>", + "Record<{name: \"Geena Davis\"}>" + ); 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" + "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 expected = Arrays.asList(); + + "RETURN coCoActor.name ORDER BY coCoActor.name ASC LIMIT 10;"; + List expected = Arrays.asList( + "Record<{coCoActor.name: \"Aaron Sorkin\"}>", + "Record<{coCoActor.name: \"Al Pacino\"}>", + "Record<{coCoActor.name: \"Anthony Edwards\"}>", + "Record<{coCoActor.name: \"Anthony Edwards\"}>", + "Record<{coCoActor.name: \"Anthony Edwards\"}>", + "Record<{coCoActor.name: \"Ben Miles\"}>", + "Record<{coCoActor.name: \"Billy Crystal\"}>", + "Record<{coCoActor.name: \"Billy Crystal\"}>", + "Record<{coCoActor.name: \"Billy Crystal\"}>", + "Record<{coCoActor.name: \"Bruno Kirby\"}>" + ); return new QueryContext(query, expected); } @@ -152,19 +165,22 @@ public static QueryContext get_movie_query14_test() { + "RETURN coCoActor.name, count(coCoActor) as frequency\n" + "ORDER BY frequency DESC\n" + "LIMIT 5;"; - List expected = Arrays.asList(); + List expected = Arrays.asList( + "Record<{coCoActor.name: \"Tom Cruise\", frequency: 5}>", + "Record<{coCoActor.name: \"Zach Grenier\", frequency: 5}>", + "Record<{coCoActor.name: \"Cuba Gooding Jr.\", frequency: 4}>", + "Record<{coCoActor.name: \"Keanu Reeves\", frequency: 4}>", + "Record<{coCoActor.name: \"Jack Nicholson\", frequency: 3}>" + ); 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" + "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;"; + + "RETURN tom.name AS actorName, movie1.title AS movie1Title, coActor.name AS coActorName, movie2.title AS movie2Title, cruise.name AS coCoActorName\n" + + "ORDER BY movie1Title, movie2Title LIMIT 10;"; List expected = Arrays.asList(); return new QueryContext(query, expected); }