LDBC queries checked
Summary: - checked existing queries and added new ones - minor changes to LDBC setup Reviewers: teon.banek, buda Reviewed By: buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D737
This commit is contained in:
parent
7294f7812e
commit
21550d3bb1
@ -6,7 +6,8 @@ import sys
|
|||||||
from neo4j.v1 import GraphDatabase, basic_auth
|
from neo4j.v1 import GraphDatabase, basic_auth
|
||||||
|
|
||||||
# Initialize driver and create session.
|
# Initialize driver and create session.
|
||||||
driver = GraphDatabase.driver('bolt://localhost:7687',
|
port = sys.argv[2] if len(sys.argv) > 2 else '7687'
|
||||||
|
driver = GraphDatabase.driver('bolt://localhost:%s' % port,
|
||||||
auth=basic_auth('', ''),
|
auth=basic_auth('', ''),
|
||||||
encrypted=False)
|
encrypted=False)
|
||||||
session = driver.session()
|
session = driver.session()
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
Person,Country,Year
|
||||||
|
30786325583618,Laos,2010
|
@ -0,0 +1,2 @@
|
|||||||
|
Person1,Person2
|
||||||
|
17592186055119,8796093025131
|
@ -0,0 +1,3 @@
|
|||||||
|
person_id: 17592186052613
|
||||||
|
message.creationDate <= 1354060800000
|
||||||
|
limit 20
|
@ -0,0 +1,2 @@
|
|||||||
|
person_id, messageX_createionDate, duration, countryX_name, countryY_name
|
||||||
|
17592186055119,1306886400000,42,Laos,Scotland
|
@ -0,0 +1,2 @@
|
|||||||
|
person_id, post_creationDate, duration
|
||||||
|
21990232559429, 1335830400000, 1e10
|
@ -0,0 +1,2 @@
|
|||||||
|
person_id, membership_joinDate
|
||||||
|
8796093030404, 1347062400000
|
@ -0,0 +1,2 @@
|
|||||||
|
Person_id|Tag
|
||||||
|
30786325583618|Angola
|
@ -0,0 +1,2 @@
|
|||||||
|
Person_id
|
||||||
|
17592186053137
|
@ -0,0 +1,2 @@
|
|||||||
|
Person_id
|
||||||
|
24189255818757
|
@ -0,0 +1,2 @@
|
|||||||
|
Person_id, message_creationDate
|
||||||
|
13194139542834, 1324080000000
|
13
tests/public_benchmark/ldbc/test_cases/queries/query_11.cyp
Normal file
13
tests/public_benchmark/ldbc/test_cases/queries/query_11.cyp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
MATCH (person:Person {id:"30786325583618"})-[:KNOWS*1..2]-(friend:Person)
|
||||||
|
WHERE not(person=friend)
|
||||||
|
WITH DISTINCT friend
|
||||||
|
MATCH (friend)-[worksAt:WORK_AT]->(company:Organisation)-[:IS_LOCATED_IN]->(:Place {name:"Laos"})
|
||||||
|
WHERE worksAt.workFrom < 2010
|
||||||
|
RETURN
|
||||||
|
friend.id AS friendId,
|
||||||
|
friend.firstName AS friendFirstName,
|
||||||
|
friend.lastName AS friendLastName,
|
||||||
|
company.name AS companyName,
|
||||||
|
worksAt.workFrom AS workFromYear
|
||||||
|
ORDER BY workFromYear ASC, tointeger(friendId) ASC, companyName DESC
|
||||||
|
LIMIT 20;
|
13
tests/public_benchmark/ldbc/test_cases/queries/query_11.oc
Normal file
13
tests/public_benchmark/ldbc/test_cases/queries/query_11.oc
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
MATCH (person:Person {id:"30786325583618"})-[:KNOWS*1..2]-(friend:Person)
|
||||||
|
WHERE not(person=friend)
|
||||||
|
WITH DISTINCT friend
|
||||||
|
MATCH (friend)-[worksAt:WORK_AT]->(company:Organisation)-[:IS_LOCATED_IN]->(:Place {name:"Laos"})
|
||||||
|
WHERE worksAt.workFrom < 2010
|
||||||
|
RETURN
|
||||||
|
friend.id AS friendId,
|
||||||
|
friend.firstName AS friendFirstName,
|
||||||
|
friend.lastName AS friendLastName,
|
||||||
|
company.name AS companyName,
|
||||||
|
worksAt.workFrom AS workFromYear
|
||||||
|
ORDER BY workFromYear ASC, tointeger(friendId) ASC, companyName DESC
|
||||||
|
LIMIT 20;
|
@ -0,0 +1,7 @@
|
|||||||
|
MATCH (person1:Person {id:"17592186055119"}), (person2:Person {id:"8796093025131"})
|
||||||
|
OPTIONAL MATCH path = shortestPath((person1)-[:KNOWS*..15]-(person2))
|
||||||
|
RETURN
|
||||||
|
CASE path IS NULL
|
||||||
|
WHEN true THEN -1
|
||||||
|
ELSE length(path)
|
||||||
|
END AS pathLength;
|
@ -0,0 +1,7 @@
|
|||||||
|
MATCH (person1:Person {id:"17592186055119"}), (person2:Person {id:"8796093025131"})
|
||||||
|
OPTIONAL MATCH (person1)-bfs[r](a, b | type(a) = "KNOWS", 15)-(person2)
|
||||||
|
RETURN
|
||||||
|
CASE r IS NULL
|
||||||
|
WHEN true THEN -1
|
||||||
|
ELSE size(r) + 1
|
||||||
|
END AS pathLength;
|
14
tests/public_benchmark/ldbc/test_cases/queries/query_2.cyp
Normal file
14
tests/public_benchmark/ldbc/test_cases/queries/query_2.cyp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
MATCH (:Person {id:"17592186052613"})-[:KNOWS]-(friend:Person)<-[:HAS_CREATOR]-(message)
|
||||||
|
WHERE message.creationDate <= 1354060800000 AND (message:Post OR message:Comment)
|
||||||
|
RETURN
|
||||||
|
friend.id AS personId,
|
||||||
|
friend.firstName AS personFirstName,
|
||||||
|
friend.lastName AS personLastName,
|
||||||
|
message.id AS messageId,
|
||||||
|
CASE exists(message.content)
|
||||||
|
WHEN true THEN message.content
|
||||||
|
ELSE message.imageFile
|
||||||
|
END AS messageContent,
|
||||||
|
message.creationDate AS messageDate
|
||||||
|
ORDER BY messageDate DESC, toInt(messageId) ASC
|
||||||
|
LIMIT 20;
|
14
tests/public_benchmark/ldbc/test_cases/queries/query_2.oc
Normal file
14
tests/public_benchmark/ldbc/test_cases/queries/query_2.oc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
MATCH (:Person {id:"17592186052613"})-[:KNOWS]-(friend:Person)<-[:HAS_CREATOR]-(message)
|
||||||
|
WHERE message.creationDate <= 1354060800000 AND (message:Post OR message:Comment)
|
||||||
|
RETURN
|
||||||
|
friend.id AS personId,
|
||||||
|
friend.firstName AS personFirstName,
|
||||||
|
friend.lastName AS personLastName,
|
||||||
|
message.id AS messageId,
|
||||||
|
CASE message.content is not null
|
||||||
|
WHEN true THEN message.content
|
||||||
|
ELSE message.imageFile
|
||||||
|
END AS messageContent,
|
||||||
|
message.creationDate AS messageDate
|
||||||
|
ORDER BY messageDate DESC, tointeger(messageId) ASC
|
||||||
|
LIMIT 20;
|
29
tests/public_benchmark/ldbc/test_cases/queries/query_3.cyp
Normal file
29
tests/public_benchmark/ldbc/test_cases/queries/query_3.cyp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
MATCH (person:Person {id:"17592186055119"})-[:KNOWS*1..2]-(friend:Person)<-[:HAS_CREATOR]-(messageX),
|
||||||
|
(messageX)-[:IS_LOCATED_IN]->(countryX:Place)
|
||||||
|
WHERE
|
||||||
|
not(person=friend)
|
||||||
|
AND not((friend)-[:IS_LOCATED_IN]->()-[:IS_PART_OF]->(countryX))
|
||||||
|
AND countryX.name="Laos" AND messageX.creationDate>=1306886400000
|
||||||
|
AND messageX.creationDate<1306886400042
|
||||||
|
WITH friend, count(DISTINCT messageX) AS xCount
|
||||||
|
MATCH (friend)<-[:HAS_CREATOR]-(messageY)-[:IS_LOCATED_IN]->(countryY:Place)
|
||||||
|
WHERE
|
||||||
|
countryY.name="Scotland"
|
||||||
|
AND not((friend)-[:IS_LOCATED_IN]->()-[:IS_PART_OF]->(countryY))
|
||||||
|
AND messageY.creationDate>={4}
|
||||||
|
AND messageY.creationDate<{5}
|
||||||
|
WITH
|
||||||
|
friend.id AS friendId,
|
||||||
|
friend.firstName AS friendFirstName,
|
||||||
|
friend.lastName AS friendLastName,
|
||||||
|
xCount,
|
||||||
|
count(DISTINCT messageY) AS yCount
|
||||||
|
RETURN
|
||||||
|
friendId,
|
||||||
|
friendFirstName,
|
||||||
|
friendLastName,
|
||||||
|
xCount,
|
||||||
|
yCount,
|
||||||
|
xCount + yCount AS xyCount
|
||||||
|
ORDER BY xyCount DESC, toInt(friendId) ASC
|
||||||
|
LIMIT 10;
|
@ -1,11 +1,11 @@
|
|||||||
MATCH (person:Person {id:"21990232559429"})-[:KNOWS]-(:Person)<-[:HAS_CREATOR]-(post:Post)-[:HAS_TAG]->(tag:Tag)
|
MATCH (person:Person {id:"21990232559429"})-[:KNOWS]-(:Person)<-[:HAS_CREATOR]-(post:Post)-[:HAS_TAG]->(tag:Tag)
|
||||||
WHERE post.creationDate >= toInt(1335830400000) AND post.creationDate < toInt(1339027200000)
|
WHERE post.creationDate >= 1335830400000 AND post.creationDate < 1345830400000
|
||||||
OPTIONAL MATCH (tag)<-[:HAS_TAG]-(oldPost:Post)-[:HAS_CREATOR]->(:Person)-[:KNOWS]-(person)
|
OPTIONAL MATCH (tag)<-[:HAS_TAG]-(oldPost:Post)-[:HAS_CREATOR]->(:Person)-[:KNOWS]-(person)
|
||||||
WHERE oldPost.creationDate < toInt(1335830400000)
|
WHERE oldPost.creationDate < 1335830400000
|
||||||
WITH tag, post, length(collect(oldPost)) AS oldPostCount
|
WITH tag, post, length(collect(oldPost)) AS oldPostCount
|
||||||
WHERE oldPostCount=0
|
WHERE oldPostCount=0
|
||||||
RETURN
|
RETURN
|
||||||
tag.name AS tagName,
|
tag.name AS tagName,
|
||||||
length(collect(post)) AS postCount
|
length(collect(post)) AS postCount
|
||||||
ORDER BY postCount DESC, tagName ASC
|
ORDER BY postCount DESC, tagName ASC
|
||||||
LIMIT toInt(10);
|
LIMIT 10;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
MATCH (person:Person {id:"21990232559429"})-[:KNOWS]-(:Person)<-[:HAS_CREATOR]-(post:Post)-[:HAS_TAG]->(tag:Tag)
|
MATCH (person:Person {id:"21990232559429"})-[:KNOWS]-(:Person)<-[:HAS_CREATOR]-(post:Post)-[:HAS_TAG]->(tag:Tag)
|
||||||
WHERE post.creationDate >= 1335830400000 AND post.creationDate < 1339027200000
|
WHERE post.creationDate >= 1335830400000 AND post.creationDate < 1345830400000
|
||||||
OPTIONAL MATCH (tag)<-[:HAS_TAG]-(oldPost:Post)-[:HAS_CREATOR]->(:Person)-[:KNOWS]-(person)
|
OPTIONAL MATCH (tag)<-[:HAS_TAG]-(oldPost:Post)-[:HAS_CREATOR]->(:Person)-[:KNOWS]-(person)
|
||||||
WHERE oldPost.creationDate < 1335830400000
|
WHERE oldPost.creationDate < 1335830400000
|
||||||
WITH tag, post, size(collect(oldPost)) AS oldPostCount
|
WITH tag, post, size(collect(oldPost)) AS oldPostCount
|
||||||
|
14
tests/public_benchmark/ldbc/test_cases/queries/query_6.cyp
Normal file
14
tests/public_benchmark/ldbc/test_cases/queries/query_6.cyp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
MATCH
|
||||||
|
(person:Person {id:"30786325583618"})-[:KNOWS*1..2]-(friend:Person),
|
||||||
|
(friend)<-[:HAS_CREATOR]-(friendPost:Post)-[:HAS_TAG]->(knownTag:Tag {name:"Angola"})
|
||||||
|
WHERE not(person=friend)
|
||||||
|
MATCH (friendPost)-[:HAS_TAG]->(commonTag:Tag)
|
||||||
|
WHERE not(commonTag=knownTag)
|
||||||
|
WITH DISTINCT commonTag, knownTag, friend
|
||||||
|
MATCH (commonTag)<-[:HAS_TAG]-(commonPost:Post)-[:HAS_TAG]->(knownTag)
|
||||||
|
WHERE (commonPost)-[:HAS_CREATOR]->(friend)
|
||||||
|
RETURN
|
||||||
|
commonTag.name AS tagName,
|
||||||
|
count(commonPost) AS postCount
|
||||||
|
ORDER BY postCount DESC, tagName ASC
|
||||||
|
LIMIT 20;
|
16
tests/public_benchmark/ldbc/test_cases/queries/query_6.oc
Normal file
16
tests/public_benchmark/ldbc/test_cases/queries/query_6.oc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
MATCH
|
||||||
|
(person:Person {id:"30786325583618"})-[:KNOWS*1..2]-(friend:Person),
|
||||||
|
(friend)<-[:HAS_CREATOR]-(friendPost:Post)-[:HAS_TAG]->(knownTag:Tag {name:"Angola"})
|
||||||
|
WHERE not(person=friend)
|
||||||
|
MATCH (friendPost)-[:HAS_TAG]->(commonTag:Tag)
|
||||||
|
WHERE not(commonTag=knownTag)
|
||||||
|
WITH DISTINCT commonTag, knownTag, friend
|
||||||
|
MATCH (commonTag)<-[:HAS_TAG]-(commonPost:Post)-[:HAS_TAG]->(knownTag)
|
||||||
|
OPTIONAL MATCH (commonPost)-[cpCreator:HAS_CREATOR]->(friend)
|
||||||
|
WITH commonTag, commonPost
|
||||||
|
WHERE cpCreator is not null
|
||||||
|
RETURN
|
||||||
|
commonTag.name AS tagName,
|
||||||
|
count(commonPost) AS postCount
|
||||||
|
ORDER BY postCount DESC, tagName ASC
|
||||||
|
LIMIT 20;
|
21
tests/public_benchmark/ldbc/test_cases/queries/query_7.cyp
Normal file
21
tests/public_benchmark/ldbc/test_cases/queries/query_7.cyp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MATCH (person:Person {id:"17592186053137"})<-[:HAS_CREATOR]-(message)<-[like:LIKES]-(liker:Person)
|
||||||
|
WITH liker, message, like.creationDate AS likeTime, person
|
||||||
|
ORDER BY likeTime DESC, toInt(message.id) ASC
|
||||||
|
WITH
|
||||||
|
liker,
|
||||||
|
head(collect({msg: message, likeTime: likeTime})) AS latestLike,
|
||||||
|
person
|
||||||
|
RETURN
|
||||||
|
liker.id AS personId,
|
||||||
|
liker.firstName AS personFirstName,
|
||||||
|
liker.lastName AS personLastName,
|
||||||
|
latestLike.likeTime AS likeTime,
|
||||||
|
latestLike.msg.id AS messageId,
|
||||||
|
CASE exists(latestLike.msg.content)
|
||||||
|
WHEN true THEN latestLike.msg.content
|
||||||
|
ELSE latestLike.msg.imageFile
|
||||||
|
END AS messageContent,
|
||||||
|
latestLike.likeTime - latestLike.msg.creationDate AS latencyAsMilli,
|
||||||
|
not((liker)-[:KNOWS]-(person)) AS isNew
|
||||||
|
ORDER BY likeTime DESC, toInt(personId) ASC
|
||||||
|
LIMIT 10;
|
23
tests/public_benchmark/ldbc/test_cases/queries/query_7.oc
Normal file
23
tests/public_benchmark/ldbc/test_cases/queries/query_7.oc
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
MATCH (person:Person {id:"17592186053137"})<-[:HAS_CREATOR]-(message)<-[like:LIKES]-(liker:Person)
|
||||||
|
WITH liker, message, like.creationDate AS likeTime, person
|
||||||
|
ORDER BY likeTime DESC, tointeger(message.id) ASC
|
||||||
|
WITH
|
||||||
|
liker,
|
||||||
|
collect(message)[0] AS latestLike_msg,
|
||||||
|
collect(likeTime)[0] AS latestLike_time,
|
||||||
|
person
|
||||||
|
OPTIONAL MATCH (liker)-[liker_knows_person:KNOWS]-(person)
|
||||||
|
RETURN
|
||||||
|
liker.id AS personId,
|
||||||
|
liker.firstName AS personFirstName,
|
||||||
|
liker.lastName AS personLastName,
|
||||||
|
latestLike_time AS likeTime,
|
||||||
|
latestLike_msg.id AS messageId,
|
||||||
|
CASE latestLike_msg.content is not null
|
||||||
|
WHEN true THEN latestLike_msg.content
|
||||||
|
ELSE latestLike_msg.imageFile
|
||||||
|
END AS messageContent,
|
||||||
|
latestLike_time - latestLike_msg.creationDate AS latencyAsMilli,
|
||||||
|
liker_knows_person is null AS isNew
|
||||||
|
ORDER BY likeTime DESC, tointeger(personId) ASC
|
||||||
|
LIMIT 10;
|
@ -5,7 +5,7 @@ RETURN DISTINCT
|
|||||||
friend.firstName AS personFirstName,
|
friend.firstName AS personFirstName,
|
||||||
friend.lastName AS personLastName,
|
friend.lastName AS personLastName,
|
||||||
message.id AS messageId,
|
message.id AS messageId,
|
||||||
CASE message.content IS null
|
CASE message.content IS not null
|
||||||
WHEN true THEN message.content
|
WHEN true THEN message.content
|
||||||
ELSE message.imageFile
|
ELSE message.imageFile
|
||||||
END AS messageContent,
|
END AS messageContent,
|
||||||
|
Loading…
Reference in New Issue
Block a user