diff --git a/tck_engine/tests/memgraph_V1/features/aggregations.feature b/tck_engine/tests/memgraph_V1/features/aggregations.feature index ba71cf6ba..1d9ab75e2 100644 --- a/tck_engine/tests/memgraph_V1/features/aggregations.feature +++ b/tck_engine/tests/memgraph_V1/features/aggregations.feature @@ -222,3 +222,31 @@ Feature: Aggregations | n | a.x | | 3 | 0 | | 4 | 1 | + + Scenario: Collect test 01: + Given an empty graph + And having executed + """ + CREATE (a{x: 0}), (b{x: True}), (c{x: 'asdf'}) + """ + When executing query: + """ + MATCH (a) RETURN collect(a.x) AS n + """ + Then the result should be (ignoring element order for lists) + | n | + | [0, true, 'asdf'] | + + Scenario: Collect test 02: + Given an empty graph + And having executed + """ + CREATE (a{x: 0}), (b{x: True}), (c{x: 'asdf'}), (d{x: null}) + """ + When executing query: + """ + MATCH (a) RETURN collect(a.x) AS n + """ + Then the result should be (ignoring element order for lists) + | n | + | [0, true, 'asdf'] | diff --git a/tck_engine/tests/memgraph_V1/features/functions.feature b/tck_engine/tests/memgraph_V1/features/functions.feature index 50ebba986..ec92bb97e 100644 --- a/tck_engine/tests/memgraph_V1/features/functions.feature +++ b/tck_engine/tests/memgraph_V1/features/functions.feature @@ -373,3 +373,244 @@ Feature: Functions | 0.8438539587324921 | | null | | -0.2921388087338362 | + + Scenario: Sign test: + When executing query: + """ + RETURN SIGN(null) AS n, SIGN(123) AS a, SIGN(0) AS b, SIGN(1.23) AS c, + SIGN(-123) AS d, SIGN(-1.23) AS e, SIGN(-0.00) AS f + """ + Then the result should be: + | n | a | b | c | d | e | f | + | null | 1 | 0 | 1 | -1 | -1 | 0 | + + Scenario: Tan test: + When executing query: + """ + RETURN TAN(null) AS n, TAN(123) AS a, TAN(-2.5) AS b, TAN(1.23) AS c + """ + Then the result should be: + | n | a | b | c | + | null | 0.5179274715856552 | 0.7470222972386603 | 2.819815734268152 | + + Scenario: Atan test: + When executing query: + """ + RETURN ATAN(null) AS n, ATAN(1.23) AS a, ATAN(123) AS b, ATAN(0) AS c + """ + Then the result should be: + | n | a | b | c | + | null | 0.8881737743776796 | 1.5626664246149526 | 0.0 | + + Scenario: Atan2 test: + When executing query: + """ + RETURN ATAN2(1, null) AS n, ATAN2(0, 0) AS a, ATAN2(2, 3) AS b, ATAN2(1.5, 2.5) AS c + """ + Then the result should be: + | n | a | b | c | + | null | 0.0 | 0.5880026035475675 | 0.5404195002705842 | + + Scenario: Asin test: + When executing query: + """ + RETURN ASIN(null) AS n, ASIN(1.23) AS a, ASIN(0.48) AS b, ASIN(-0.25) AS c + """ + Then the result should be: + | n | a | b | c | + | null | nan | 0.5006547124045881 | -0.25268025514207865 | + + Scenario: Acos test: + When executing query: + """ + RETURN ACOS(null) AS n, ACOS(1.23) AS a, ACOS(0.48) AS b, ACOS(-0.25) AS c + """ + Then the result should be: + | n | a | b | c | + | null | nan | 1.0701416143903084 | 1.8234765819369754 | + + Scenario: Round test: + When executing query: + """ + RETURN ROUND(null) AS n, ROUND(1.49999) AS a, ROUND(-1.5) AS b, ROUND(-1.51) AS c, + ROUND(1.5) as d + """ + Then the result should be: + | n | a | b | c | d | + | null | 1.0 | -2.0 | -2.0 | 2.0 | + + Scenario: Floor test: + When executing query: + """ + RETURN FLOOR(null) AS n, FLOOR(1.49999) AS a, FLOOR(-1.5) AS b, FLOOR(-1.51) AS c, + FLOOR(1.00) as d + """ + Then the result should be: + | n | a | b | c | d | + | null | 1.0 | -2.0 | -2.0 | 1.0 | + + Scenario: Ceil test: + When executing query: + """ + RETURN CEIL(null) AS n, CEIL(1.49999) AS a, CEIL(-1.5) AS b, CEIL(-1.51) AS c, + CEIL(1.00) as d + """ + Then the result should be: + | n | a | b | c | d | + | null | 2.0 | -1.0 | -1.0 | 1.0 | + + Scenario: Tail test: + When executing query: + """ + RETURN TAIL(null) AS n, TAIL([[1, 2], 3, 4]) AS a, TAIL([1, [2, 3, 4]]) AS b + """ + Then the result should be: + | n | a | b | + | null | [3, 4] | [[2, 3, 4]] | + + Scenario: Range test: + When executing query: + """ + RETURN RANGE(1, 3) AS a, RANGE(1, 5, 2) AS b, RANGE(1, -1) AS c, + RANGE(1, -1, -3) as d + """ + Then the result should be: + | a | b | c | d | + | [1, 2, 3] | [1, 3, 5] | [] | [1] | + + Scenario: Size test: + When executing query: + """ + RETURN SIZE(null) AS n, SIZE([[1, 2], 3, 4]) AS a, SIZE([1, [2, 3, 4]]) AS b + """ + Then the result should be: + | n | a | b | + | null | 3 | 2 | + + Scenario: Last test: + When executing query: + """ + RETURN LAST(null) AS n, LAST([[1, 2], 3, 4]) AS a, LAST([1, [2, 3, 4]]) AS b + """ + Then the result should be: + | n | a | b | + | null | 4 | [2, 3, 4] | + + Scenario: Head test: + When executing query: + """ + RETURN HEAD(null) AS n, HEAD([[1, 2], 3, 4]) AS a, HEAD([1, [2, 3, 4]]) AS b + """ + Then the result should be: + | n | a | b | + | null | [1, 2] | 1 | + + Scenario: Labels test: + Given an empty graph + And having executed: + """ + CREATE(:x:y:z), (), (:a:b) + """ + When executing query: + """ + MATCH(n) RETURN LABELS(n) AS l + """ + Then the result should be: + | l | + | [] | + | ['x', 'y', 'z'] | + | ['a', 'b'] | + + Scenario: Type test: + Given an empty graph + And having executed: + """ + CREATE(a), (b), (c), (a)-[:A]->(b), (a)-[:B]->(c), (b)-[:C]->(c) + """ + When executing query: + """ + MATCH ()-[r]->() RETURN TYPE(r) AS t + """ + Then the result should be: + | t | + | 'A' | + | 'B' | + | 'C' | + + Scenario: Properties test1: + Given an empty graph + And having executed: + """ + CREATE(a), (b), (c), (a)-[:A{a: null}]->(b), (a)-[:B{b: true}]->(c), + (b)-[:C{c: 123}]->(c) + """ + When executing query: + """ + MATCH ()-[r]->() RETURN PROPERTIES(r) AS p + """ + Then the result should be: + | p | + | {b: true} | + | {} | + | {c: 123} | + + Scenario: Properties test2: + Given an empty graph + And having executed: + """ + CREATE({a: 'x'}), ({n: 1.1}), () + """ + When executing query: + """ + MATCH(n) RETURN PROPERTIES(n) AS p + """ + Then the result should be: + | p | + | {} | + | {a: 'x'} | + | {n: 1.1} | + + Scenario: Coalesce test: + When executing query: + """ + RETURN COALESCE(null) AS n, COALESCE([null, null]) AS a, + COALESCE(null, null, 1, 2, 3) AS b + """ + Then the result should be: + | n | a | b | + | null | [null, null] | 1 | + + Scenario: Endnode test: + Given an empty graph + And having executed: + """ + CREATE(a:x), (b:y), (c:z), (a)-[:A]->(b), (b)-[:B]->(c), (c)-[:C]->(b) + """ + When executing query: + """ + MATCH ()-[r]->() RETURN ENDNODE(r) AS n, ENDNODE(r):z AS a, ENDNODE(r):y AS b + """ + Then the result should be: + | n | a | b | + | (:z) | true | false | + | (:y) | false | true | + | (:y) | false | true | + + Scenario: Keys test: + Given an empty graph + And having executed: + """ + CREATE (n{true: 123, a: null, b: 'x', null: 1}) RETURN KEYS(n) AS a + """ + Then the result should be (ignoring element order for lists) + | a | + | ['true', 'null', 'b'] | + + Scenario: Pi test: + When executing query: + """ + RETURN PI() as n + """ + Then the result should be: + | n | + | 3.141592653589793 | diff --git a/tck_engine/tests/memgraph_V1/features/list_operations.feature b/tck_engine/tests/memgraph_V1/features/list_operations.feature new file mode 100644 index 000000000..4c71be35c --- /dev/null +++ b/tck_engine/tests/memgraph_V1/features/list_operations.feature @@ -0,0 +1,225 @@ +Feature: List operators + + Scenario: In test1 + When executing query: + """ + WITH [1, 2, 3, 4] AS l + RETURN 3 IN l as in + """ + Then the result should be: + | in | + | true | + + Scenario: In test2 + When executing query: + """ + WITH [1, '2', 3, 4] AS l + RETURN 2 IN l as in + """ + Then the result should be: + | in | + | false | + + Scenario: In test4 + When executing query: + """ + WITH [1, [2, 3], 4] AS l + RETURN [3, 2] IN l as in + """ + Then the result should be: + | in | + | false | + + Scenario: In test5 + When executing query: + """ + WITH [[1, 2], 3, 4] AS l + RETURN 1 IN l as in + """ + Then the result should be: + | in | + | false | + + Scenario: In test6 + When executing query: + """ + WITH [1, [[2, 3], 4]] AS l + RETURN [[2, 3], 4] IN l as in + """ + Then the result should be: + | in | + | true | + + Scenario: In test7 + When executing query: + """ + WITH [1, [[2, 3], 4]] AS l + RETURN [1, [[2, 3], 4]] IN l as in + """ + Then the result should be: + | in | + | false | + + + + Scenario: Index test1 + When executing query: + """ + WITH [1, 2, 3, 4] AS l + RETURN l[2] as in + """ + Then the result should be: + | in | + | 3 | + + Scenario: Index test2 + When executing query: + """ + WITH [1, 2, 3, 4] AS l + RETURN l[-2] as in + """ + Then the result should be: + | in | + | 3 | + + Scenario: Index test3 + When executing query: + """ + WITH [1, 2, 3, 4] AS l + RETURN l[2][0] as in + """ + Then an error should be raised + + Scenario: Index test4 + When executing query: + """ + WITH [1, 2, [3], 4] AS l + RETURN l[2][0] as in + """ + Then the result should be: + | in | + | 3 | + + Scenario: Index test5 + When executing query: + """ + WITH [[1, [2, [3]]], 4] AS l + RETURN l[0][1][1][0] as in + """ + Then the result should be: + | in | + | 3 | + + + Scenario: Slice test1 + When executing query: + """ + WITH [1, 2, 3, 4] AS l + RETURN l[0..2] as in + """ + Then the result should be, in order: + | in | + | [1, 2] | + + Scenario: Slice test2 + When executing query: + """ + WITH [1, 2, 3, 4] AS l + RETURN l[-2..5] as in + """ + Then the result should be, in order: + | in | + | [3, 4] | + + Scenario: Slice test3 + When executing query: + """ + WITH [1, 2, 3, 4] AS l + RETURN l[-2..4] as in + """ + Then the result should be, in order: + | in | + | [3, 4] | + + Scenario: Slice test4 + When executing query: + """ + WITH [1, 2, 3, 4] AS l + RETURN l[-1..4] as in + """ + Then the result should be, in order: + | in | + | [4] | + + Scenario: Slice test5 + When executing query: + """ + WITH [1, 2, 3, 4] AS l + RETURN l[-2..-2] as in + """ + Then the result should be, in order: + | in | + | [] | + + Scenario: Slice test6 + When executing query: + """ + WITH [1, 2, 3, 4] AS l + RETURN l[4..-2] as in + """ + Then the result should be, in order: + | in | + | [] | + + + Scenario: Concatenate test1 + When executing query: + """ + WITH [1, 2, 3, 4] AS l1, [5, 6, 7] AS l2 + RETURN l1+l2 as in + """ + Then the result should be, in order: + | in | + | [1, 2, 3, 4, 5, 6, 7] | + + Scenario: Concatenate test2 + When executing query: + """ + WITH [[1, [2]]] AS l1, [[[3], 4]] AS l2 + RETURN l1+l2 as in + """ + Then the result should be, in order: + | in | + | [[1, [2]], [[3], 4]] | + + Scenario: Concatenate test3 + When executing query: + """ + WITH [1, 2, 3, 4] AS l1, NULL AS l2 + RETURN l1+l2 as in + """ + Then the result should be, in order: + | in | + | null | + + Scenario: Concatenate test4 + When executing query: + """ + WITH [] AS l1, [] AS l2 + RETURN l1+l2 as in + """ + Then the result should be, in order: + | in | + | [] | + + Scenario: Unwind test + When executing query: + """ + UNWIND [ [[1], 2], [3], 4] as l + RETURN l + """ + Then the result should be: + | l | + | [[1], 2] | + | [3] | + | 4 | diff --git a/tck_engine/tests/memgraph_V1/features/match.feature b/tck_engine/tests/memgraph_V1/features/match.feature index 3ea091f93..4713fdcba 100644 --- a/tck_engine/tests/memgraph_V1/features/match.feature +++ b/tck_engine/tests/memgraph_V1/features/match.feature @@ -303,3 +303,106 @@ Feature: Match | n | | (:Person {age: 20}) | | (:Person :Student {age: 20}) | + + Scenario: Test match with order by + Given an empty graph + And having executed: + """ + CREATE({a: 1}), ({a: 2}), ({a: 3}), ({a: 4}), ({a: 5}) + """ + When executing query: + """ + MATCH (n) RETURN n.a ORDER BY n.a + """ + Then the result should be, in order: + | n.a | + | 1 | + | 2 | + | 3 | + | 4 | + | 5 | + + Scenario: Test match with order by and skip + Given an empty graph + And having executed: + """ + CREATE({a: 1}), ({a: 2}), ({a: 3}), ({a: 4}), ({a: 5}) + """ + When executing query: + """ + MATCH (n) RETURN n.a ORDER BY n.a SKIP 3 + """ + Then the result should be, in order: + | n.a | + | 4 | + | 5 | + + Scenario: Test match with order by and limit + Given an empty graph + And having executed: + """ + CREATE({a: 1}), ({a: 2}), ({a: 3}), ({a: 4}), ({a: 5}) + """ + When executing query: + """ + MATCH (n) RETURN n.a ORDER BY n.a LIMIT 2 + """ + Then the result should be, in order: + | n.a | + | 1 | + | 2 | + + Scenario: Test match with order by, skip and limit + Given an empty graph + And having executed: + """ + CREATE({a: 1}), ({a: 2}), ({a: 3}), ({a: 4}), ({a: 5}) + """ + When executing query: + """ + MATCH (n) RETURN n.a ORDER BY n.a SKIP 2 LIMIT 2 + """ + Then the result should be, in order: + | n.a | + | 3 | + | 4 | + + Scenario: Test match with order by and skip + Given an empty graph + And having executed: + """ + CREATE({a: 1}), ({a: 2}), ({a: 3}), ({a: 4}), ({a: 5}) + """ + When executing query: + """ + MATCH (n) RETURN n.a ORDER BY n.a SKIP 6 + """ + Then the result should be empty + + Scenario: Test match with order by and limit + Given an empty graph + And having executed: + """ + CREATE({a: 1}), ({a: 2}), ({a: 3}), ({a: 4}), ({a: 5}) + """ + When executing query: + """ + MATCH (n) RETURN n.a ORDER BY n.a LIMIT 0 + """ + Then the result should be empty + + Scenario: Test distinct + Given an empty graph + And having executed: + """ + CREATE({a: 1}), ({a: 4}), ({a: 3}), ({a: 1}), ({a: 4}) + """ + When executing query: + """ + MATCH (n) RETURN DISTINCT n.a + """ + Then the result should be: + | n.a | + | 1 | + | 3 | + | 4 | diff --git a/tck_engine/tests/memgraph_V1/features/memgraph.feature b/tck_engine/tests/memgraph_V1/features/memgraph.feature index 6fa071904..a1456cfa5 100644 --- a/tck_engine/tests/memgraph_V1/features/memgraph.feature +++ b/tck_engine/tests/memgraph_V1/features/memgraph.feature @@ -34,3 +34,24 @@ Feature: Memgraph only tests (queries in which we choose to be incompatible with CREATE(a:A), (b:B), (c:C), (a)-[:T]->(b) WITH a DETACH DELETE a WITH a MATCH()-[r:T]->() RETURN r """ Then an error should be raised + + Scenario: In test3 + When executing query: + """ + WITH [[1], 2, 3, 4] AS l + RETURN 1 IN l as in + """ + Then the result should be: + | in | + | false | + + Scenario: In test8 + When executing query: + """ + WITH [[[[1]]], 2, 3, 4] AS l + RETURN 1 IN l as in + """ + Then the result should be: + | in | + | false | + diff --git a/tck_engine/tests/memgraph_V1/features/merge.feature b/tck_engine/tests/memgraph_V1/features/merge.feature new file mode 100644 index 000000000..75d4b3573 --- /dev/null +++ b/tck_engine/tests/memgraph_V1/features/merge.feature @@ -0,0 +1,420 @@ +Feature: Merge feature + + Scenario: Merge node test01 + Given an empty graph + And having executed: + """ + CREATE (:X{a: 1}) + """ + And having executed: + """ + MERGE(n:X) + """ + When executing query: + """ + MATCH(n) RETURN n + """ + Then the result should be: + | n | + | (:X{a: 1}) | + + Scenario: Merge node test02 + Given an empty graph + And having executed: + """ + CREATE (:X) + """ + And having executed: + """ + MERGE(n:X:Y) + """ + When executing query: + """ + MATCH(n) RETURN n + """ + Then the result should be: + | n | + | (:X) | + | (:X:Y) | + + Scenario: Merge node test03 + Given an empty graph + And having executed: + """ + CREATE (:Y{a: 1}) + """ + And having executed: + """ + MERGE(n:X) + """ + When executing query: + """ + MATCH(n) RETURN n + """ + Then the result should be: + | n | + | (:X) | + | (:Y{a: 1}) | + + Scenario: Merge node test04 + Given an empty graph + And having executed: + """ + CREATE ({a: 1, b: 2}) + """ + And having executed: + """ + MERGE(n{a: 1, b: 2}) + """ + When executing query: + """ + MATCH(n) RETURN n + """ + Then the result should be: + | n | + | ({a: 1, b: 2}) | + + Scenario: Merge node test05 + Given an empty graph + And having executed: + """ + CREATE ({a: 2}) + """ + And having executed: + """ + MERGE(n{a: 1, b:2}) + """ + When executing query: + """ + MATCH(n) RETURN n + """ + Then the result should be: + | n | + | ({a: 2}) | + | ({a: 1, b: 2}) | + + Scenario: Merge node test06 + Given an empty graph + And having executed: + """ + CREATE ({a: 2}) + """ + And having executed: + """ + MERGE(n{a: 2, b: 2}) + """ + When executing query: + """ + MATCH(n) RETURN n + """ + Then the result should be: + | n | + | ({a: 2}) | + | ({a: 2, b: 2}) | + + Scenario: Merge node test07 + Given an empty graph + And having executed: + """ + CREATE ({a: 2}) + """ + And having executed: + """ + MERGE(n:A{a: 2}) + """ + When executing query: + """ + MATCH(n) RETURN n + """ + Then the result should be: + | n | + | (:A{a: 2}) | + | ({a: 2}) | + + Scenario: Merge node test08 + Given an empty graph + And having executed: + """ + CREATE (:A:B{a: 2, b: 1}) + """ + And having executed: + """ + MERGE(n:A{a: 2}) + """ + When executing query: + """ + MATCH(n) RETURN n + """ + Then the result should be: + | n | + | (:A:B{a: 2, b: 1}) | + + Scenario: Merge node test09 + Given an empty graph + And having executed: + """ + CREATE (:A{a: 2}), (:A{a: 2}), (:A{a: 1}) + """ + And having executed: + """ + MATCH(n:A) + MERGE(m:B{x: n.a}) + """ + When executing query: + """ + MATCH(n:B) RETURN * + """ + Then the result should be: + | n | + | (:B{x: 1}) | + | (:B{x: 2}) | + + Scenario: Merge relationship test01 + Given an empty graph + And having executed: + """ + CREATE (a), (b), (a)-[:X]->(b) + """ + And having executed: + """ + MATCH (a)--(b) + MERGE ((a)-[r:X]-(b)) + """ + When executing query: + """ + MATCH ()-[r]->() RETURN * + """ + Then the result should be: + | r | + | [:X] | + + Scenario: Merge relationship test02 + Given an empty graph + And having executed: + """ + CREATE (a), (b), (a)-[:X]->(b) + """ + And having executed: + """ + MATCH (a)--(b) + MERGE ((a)-[r:Y]-(b)) + """ + When executing query: + """ + MATCH ()-[r]->() RETURN * + """ + Then the result should be: + | r | + | [:X] | + | [:Y] | + + Scenario: Merge relationship test03 + Given an empty graph + And having executed: + """ + CREATE (a), (b), (a)-[:X{a: 1}]->(b) + """ + And having executed: + """ + MATCH (a)--(b) + MERGE ((a)-[r:X{a: 1}]-(b)) + """ + When executing query: + """ + MATCH ()-[r]->() RETURN * + """ + Then the result should be: + | r | + | [:X{a: 1}] | + + Scenario: Merge relationship test04 + Given an empty graph + And having executed: + """ + CREATE (a), (b), (a)-[:X{a: 1}]->(b) + """ + And having executed: + """ + MATCH (a)--(b) + MERGE ((a)-[r:X{a: 2}]-(b)) + """ + When executing query: + """ + MATCH ()-[r]->() RETURN * + """ + Then the result should be: + | r | + | [:X{a: 1}] | + | [:X{a: 2}] | + + Scenario: Merge relationship test05 + Given an empty graph + And having executed: + """ + CREATE (a), (b), (a)-[:X{a: 1}]->(b) + """ + And having executed: + """ + MATCH (a)--(b) + MERGE ((a)-[r:Y{a: 1}]-(b)) + """ + When executing query: + """ + MATCH ()-[r]->() RETURN * + """ + Then the result should be: + | r | + | [:X{a: 1}] | + | [:Y{a: 1}] | + + Scenario: Merge relationship test06 + Given an empty graph + And having executed: + """ + CREATE (a:A{a: 1}), (b:B{b: 1}), (c:C), (a)-[:X]->(c), (c)<-[:Y]-(b) + """ + And having executed: + """ + MERGE (:A)-[:X]->(:C)<-[:Y]-(:B) + """ + When executing query: + """ + MATCH (a)-[r]->(b) RETURN * + """ + Then the result should be: + | a | r | b | + | (:A{a: 1}) | [:X] | (:C) | + | (:B{b: 1}) | [:Y] | (:C) | + + Scenario: Merge relationship test07 + Given an empty graph + And having executed: + """ + CREATE (a:A{a: 1}), (b:B{b: 1}), (c:C), (a)-[:X{x: 1}]->(c), (c)<-[:Y{y: 1}]-(b) + """ + And having executed: + """ + MERGE (:A)-[:X]->(:D)<-[:Y]-(:B) + """ + When executing query: + """ + MATCH (a)-[r]->(b) RETURN * + """ + Then the result should be: + | a | r | b | + | (:A) | [:X] | (:D) | + | (:B) | [:Y] | (:D) | + | (:A{a: 1}) | [:X{x: 1}] | (:C) | + | (:B{b: 1}) | [:Y{y: 1}] | (:C) | + + Scenario: Merge relationship test08 + Given an empty graph + And having executed: + """ + CREATE (a:A:X), (b:B:Y) + """ + And having executed: + """ + MATCH (a:A), (b:B) + MERGE (a)-[:R]-(b) + """ + When executing query: + """ + MATCH (a)-[r]-(b) RETURN * + """ + Then the result should be: + | a | r | b | + | (:A:X) | [:R] | (:B:Y) | + | (:B:Y) | [:R] | (:A:X) | + + Scenario: Merge relationship test09 + Given an empty graph + And having executed: + """ + CREATE (a:A{a: 1}), (b:B{a: 2}), (c:C{a: 2}) + """ + When executing query: + """ + MATCH (n) + MERGE (m:X{a: n.a}) + MERGE (n)-[r:R]->(m) + RETURN * + """ + Then the result should be: + | n | r | m | + | (:A{a: 1}) | [:R] | (:X{a: 1}) | + | (:B{a: 2}) | [:R] | (:X{a: 2}) | + | (:C{a: 2}) | [:R] | (:X{a: 2}) | + + Scenario: Merge relationship test10 + Given an empty graph + And having executed: + """ + CREATE (a:A{a: 1}), (b:B{a: 2}), (c:C{a: 2}) + """ + When executing query: + """ + MATCH (n) + MERGE (n)-[r:R]->(m:X{a: n.a}) + RETURN * + """ + Then the result should be: + | n | r | m | + | (:A{a: 1}) | [:R] | (:X{a: 1}) | + | (:B{a: 2}) | [:R] | (:X{a: 2}) | + | (:C{a: 2}) | [:R] | (:X{a: 2}) | + + Scenario: Merge OnCreate test01 + Given an empty graph + When executing query: + """ + MERGE (a:X) + ON CREATE SET a.a = 1 + RETURN * + """ + Then the result should be: + | a | + | (:X{a: 1}) | + + Scenario: Merge OnMatch test01 + Given an empty graph + And having executed: + """ + CREATE(:A), (:A), (:B) + """ + And having executed: + """ + MERGE (a:A) + ON MATCH SET a.a = 1 + """ + When executing query: + """ + MATCH (n) RETURN * + """ + Then the result should be: + | n | + | (:A{a: 1}) | + | (:A{a: 1}) | + | (:B) | + + Scenario: Merge with Unwind test01 + Given an empty graph + And having executed: + """ + CREATE ({a: 1}) + """ + And having executed: + """ + UNWIND [1, 2, 3] AS a + MERGE({a: a}) + """ + When executing query: + """ + MATCH (n) RETURN * + """ + Then the result should be: + | n | + | ({a: 1}) | + | ({a: 2}) | + | ({a: 3)) | + diff --git a/tck_engine/tests/memgraph_V1/features/string_operators.feature b/tck_engine/tests/memgraph_V1/features/string_operators.feature new file mode 100644 index 000000000..28fec96a5 --- /dev/null +++ b/tck_engine/tests/memgraph_V1/features/string_operators.feature @@ -0,0 +1,186 @@ +Feature: String operators + + Scenario: StartsWith test1 + Given an empty graph + And having executed + """ + CREATE(a{name: "ai'M'e"}), (b{name: "AiMe"}), (c{name: "aime"}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name STARTS WITH 'aim' + return n.name + """ + Then the result should be: + | n.name | + | 'aime' | + + Scenario: StartsWith test2 + Given an empty graph + And having executed + """ + CREATE(a{name: "ai'M'e"}), (b{name: "AiMe"}), (c{name: "aime"}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name STARTS WITH "ai'M" + return n.name + """ + Then the result should be: + | n.name | + | 'ai'M'e' | + + Scenario: StartsWith test3 + Given an empty graph + And having executed + """ + CREATE(a{name: 1}), (b{name: 2}), (c{name: null}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name STARTS WITH 1 + return n.name + """ + Then an error should be raised + + Scenario: StartsWith test5 + Given an empty graph + And having executed + """ + CREATE(a{name: 1}), (b{name: 2}), (c{name: null}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name STARTS WITH true + return n.name + """ + Then an error should be raised + + + Scenario: EndsWith test1 + Given an empty graph + And having executed + """ + CREATE(a{name: "ai'M'E"}), (b{name: "AiMe"}), (c{name: "aime"}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name ENDS WITH 'e' + return n.name + """ + Then the result should be: + | n.name | + | 'AiMe' | + | 'aime' | + + Scenario: EndsWith test2 + Given an empty graph + And having executed + """ + CREATE(a{name: "ai'M'e"}), (b{name: "AiMe"}), (c{name: "aime"}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name ENDS WITH "M'e" + return n.name + """ + Then the result should be: + | n.name | + | 'ai'M'e' | + + Scenario: EndsWith test3 + Given an empty graph + And having executed + """ + CREATE(a{name: 1}), (b{name: 2}), (c{name: null}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name ENDS WITH 1 + return n.name + """ + Then an error should be raised + + Scenario: EndsWith test5 + Given an empty graph + And having executed + """ + CREATE(a{name: 1}), (b{name: 2}), (c{name: null}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name ENDS WITH true + return n.name + """ + Then an error should be raised + + + Scenario: Contains test1 + Given an empty graph + And having executed + """ + CREATE(a{name: "ai'M'e"}), (b{name: "AiMe"}), (c{name: "aime"}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name CONTAINS 'iM' + return n.name + """ + Then the result should be: + | n.name | + | 'AiMe' | + + Scenario: Contains test2 + Given an empty graph + And having executed + """ + CREATE(a{name: "ai'M'e"}), (b{name: "AiMe"}), (c{name: "aime"}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name CONTAINS "i'M" + return n.name + """ + Then the result should be: + | n.name | + | 'ai'M'e' | + + Scenario: Contains test3 + Given an empty graph + And having executed + """ + CREATE(a{name: 1}), (b{name: 2}), (c{name: null}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name CONTAINS 1 + return n.name + """ + Then an error should be raised + + + Scenario: Contains test5 + Given an empty graph + And having executed + """ + CREATE(a{name: 1}), (b{name: 2}), (c{name: null}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name CONTAINS true + return n.name + """ + Then an error should be raised + diff --git a/tck_engine/tests/memgraph_V1/features/unstable.feature b/tck_engine/tests/memgraph_V1/features/unstable.feature index db0ea0a42..e6c396d0e 100644 --- a/tck_engine/tests/memgraph_V1/features/unstable.feature +++ b/tck_engine/tests/memgraph_V1/features/unstable.feature @@ -45,3 +45,64 @@ Feature: Unstable Then the result should be: | n | | true | + + Scenario: Keys test: + When executing query: + """ + RETURN KEYS( {true: 123, a: null, b: 'x', null: null} ) AS a + """ + Then the result should be: + | a | + | ['true', 'a', 'b', 'null'] | + + Scenario: StartsWith test4 + Given an empty graph + And having executed + """ + CREATE(a{name: 1}), (b{name: 2}), (c{name: null}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name STARTS WITH null + return n.name + """ + Then the result should be empty + + Scenario: EndsWith test4 + Given an empty graph + And having executed + """ + CREATE(a{name: 1}), (b{name: 2}), (c{name: null}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name ENDS WITH null + return n.name + """ + Then the result should be empty + + Scenario: Contains test4 + Given an empty graph + And having executed + """ + CREATE(a{name: 1}), (b{name: 2}), (c{name: null}) + """ + When executing query: + """ + MATCH (n) + WHERE n.name CONTAINS null + return n.name + """ + Then the result should be empty + + Scenario: E test: + When executing query: + """ + RETURN E() as n + """ + Then the result should be: + | n | + | 2.718281828459045 | + diff --git a/tck_engine/tests/memgraph_V1/features/with.feature b/tck_engine/tests/memgraph_V1/features/with.feature index dae2fd9cb..84d2cd225 100644 --- a/tck_engine/tests/memgraph_V1/features/with.feature +++ b/tck_engine/tests/memgraph_V1/features/with.feature @@ -147,3 +147,77 @@ Feature: With | av | | 6.5 | | 7.0 | + + Scenario: With test 11: + Given an empty graph + And having executed: + """ + CREATE(:A{a: 1}), (:B{a: 1}), (:C{a: 1}), (:D{a: 4}), (:E{a: 5}) + """ + When executing query: + """ + MATCH(n) WITH n.a AS a + ORDER BY a LIMIT 4 + RETURN a + """ + Then the result should be, in order: + | a | + | 1 | + | 1 | + | 1 | + | 4 | + + Scenario: With test 12: + Given an empty graph + And having executed: + """ + CREATE(:A{a: 1}), (:B{a: 5}), (:C{a: 2}), (:D{a: 3}), (:E{a: 5}) + """ + When executing query: + """ + MATCH(n) WITH n.a AS a + ORDER BY a SKIP 2 + RETURN a + """ + Then the result should be, in order: + | a | + | 3 | + | 5 | + | 5 | + + Scenario: With test 13: + Given an empty graph + And having executed: + """ + CREATE(:A{a: 1}), (:B{a: 5}), (:C{a: 2}), (:D{a: 3}), (:E{a: 5}) + """ + When executing query: + """ + MATCH(n) WITH n.a AS a + ORDER BY a + RETURN a + """ + Then the result should be, in order: + | a | + | 1 | + | 2 | + | 3 | + | 5 | + | 5 | + + Scenario: With test 14: + Given an empty graph + And having executed: + """ + CREATE(:A{a: 1}), (:B{a: 5}), (:C{a: 1}), (:D{a: 3}), (:E{a: 5}) + """ + When executing query: + """ + MATCH(n) WITH DISTINCT n.a AS a + RETURN a + """ + Then the result should be: + | a | + | 1 | + | 3 | + | 5 |